Exemple #1
0
        private IDocumentStore CreateStoreAtPort(int port, Action <DocumentStore> configureStore = null)
        {
            Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);
            var serverConfiguration = new Raven.Database.Config.RavenConfiguration
            {
                Settings = { { "Raven/ActiveBundles", "replication" } },
                AnonymousUserAccessMode = Raven.Database.Server.AnonymousUserAccessMode.All,
                DataDirectory           = "Data #" + servers.Count,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                RunInMemory            = true,
                Port                   = port,
                DefaultStorageTypeName = RavenTest.GetDefaultStorageType()
            };

            ConfigureServer(serverConfiguration);
            IOExtensions.DeleteDirectory(serverConfiguration.DataDirectory);
            serverConfiguration.PostInit();
            var ravenDbServer = new RavenDbServer(serverConfiguration);

            servers.Add(ravenDbServer);

            var documentStore = new DocumentStore {
                Url = ravenDbServer.Database.Configuration.ServerUrl
            };

            ConfigureStore(documentStore);
            if (configureStore != null)
            {
                configureStore(documentStore);
            }
            documentStore.Initialize();

            stores.Add(documentStore);
            return(documentStore);
        }
Exemple #2
0
        public void Dispose()
        {
            var err = new List <Exception>();

            foreach (var documentStore in stores)
            {
                try
                {
                    documentStore.Dispose();
                }
                catch (Exception e)
                {
                    err.Add(e);
                }
            }

            foreach (var ravenDbServer in servers)
            {
                try
                {
                    ravenDbServer.Dispose();
                    IOExtensions.DeleteDirectory(ravenDbServer.Database.Configuration.DataDirectory);
                }
                catch (Exception e)
                {
                    err.Add(e);
                }
            }

            if (err.Count > 0)
            {
                throw new AggregateException(err);
            }
        }
Exemple #3
0
        public IDocumentStore ResetDatabase(int index)
        {
            stores[index].Dispose();

            var previousServer = servers[index];

            previousServer.Dispose();
            IOExtensions.DeleteDirectory(previousServer.Database.Configuration.DataDirectory);

            return(CreateStoreAtPort(previousServer.Database.Configuration.Port));
        }
        public HttpResponseMessage InfoPackage()
        {
            if (CanExposeConfigOverTheWire() == false)
            {
                return(GetEmptyMessage(HttpStatusCode.Forbidden));
            }

            var tempFileName = Path.Combine(Database.Configuration.TempPath, Path.GetRandomFileName());

            try
            {
                using (var file = new FileStream(tempFileName, FileMode.Create))
                    using (var package = new ZipArchive(file, ZipArchiveMode.Create))
                    {
                        DebugInfoProvider.CreateInfoPackageForDatabase(package, Database, RequestManager, ClusterManager);
                    }

                var response = new HttpResponseMessage();

                response.Content = new StreamContent(new FileStream(tempFileName, FileMode.Open, FileAccess.Read))
                {
                    Headers =
                    {
                        ContentDisposition = new ContentDispositionHeaderValue("attachment")
                        {
                            FileName       = string.Format("Debug-Info-{0}.zip",SystemTime.UtcNow),
                        },
                        ContentType        = new MediaTypeHeaderValue("application/octet-stream")
                    }
                };

                return(response);
            }
            finally
            {
                IOExtensions.DeleteFile(tempFileName);
            }
        }