Exemplo n.º 1
0
        public Expiration()
        {
            path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase);
            path = Path.Combine(path, "TestDb").Substring(6);
            Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
            var ravenConfiguration = new Raven.Database.Config.RavenConfiguration
            {
                Port = 8079,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                DataDirectory = path,
                Settings      =
                {
                    { "Raven/Expiration/DeleteFrequencySeconds", "1"                  },
                    { "Raven/ActiveBundles",                     "DocumentExpiration" }
                }
            };

            ravenConfiguration.PostInit();
            ravenDbServer = new RavenDbServer(
                ravenConfiguration);
            Raven.Bundles.Expiration.ExpirationReadTrigger.GetCurrentUtcDate = () => DateTime.UtcNow;
            documentStore = new DocumentStore
            {
                Url = "http://localhost:8079"
            };
            documentStore.Initialize();
        }
Exemplo n.º 2
0
 public CompressionAndEncryption()
 {
     path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase);
     path = Path.Combine(path, "TestDb").Substring(6);
     Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
     settings = new Raven.Database.Config.RavenConfiguration
     {
         Port = 8079,
         RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
         DataDirectory = path,
         Settings      =
         {
             { "Raven/Encryption/Key", "3w17MIVIBLSWZpzH0YarqRlR2+yHiv1Zq3TCWXLEMI8=" },
             { "Raven/ActiveBundles",  "Compression;Encryption"                       }
         }
     };
     ConfigureServer(settings);
     settings.PostInit();
     ravenDbServer = new RavenDbServer(settings);
     documentStore = new DocumentStore
     {
         Url = "http://localhost:8079"
     };
     documentStore.Initialize();
 }
Exemplo n.º 3
0
		public CompressionAndEncryption()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
			settings = new Raven.Database.Config.RavenConfiguration
			{
				Port = 8079,
				RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
				DataDirectory = path,
				Settings =
					{
						{"Raven/Encryption/Key", "3w17MIVIBLSWZpzH0YarqRlR2+yHiv1Zq3TCWXLEMI8="},
						{"Raven/ActiveBundles", "Compression;Encryption"}
					}
			};
			ConfigureServer(settings);
			settings.PostInit();
			ravenDbServer = new RavenDbServer(settings);
			documentStore = new DocumentStore
			{
				Url = "http://localhost:8079"
			};
			documentStore.Initialize();
		}
Exemplo n.º 4
0
        private RavenDbServer CreateServer(int port, string dataDirectory, bool removeDataDirectory = true)
        {
            Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);

            var serverConfiguration = new Raven.Database.Config.RavenConfiguration
            {
                Settings = { { "Raven/ActiveBundles", "replication" } },
                AnonymousUserAccessMode = Raven.Database.Server.AnonymousUserAccessMode.All,
                DataDirectory           = dataDirectory,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                RunInMemory            = false,
                Port                   = port,
                DefaultStorageTypeName = "esent"
            };

            if (removeDataDirectory)
            {
                IOExtensions.DeleteDirectory(serverConfiguration.DataDirectory);
            }

            var server = new RavenDbServer(serverConfiguration);

            serverConfiguration.PostInit();

            return(server);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
		public Expiration()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
			var ravenConfiguration = new Raven.Database.Config.RavenConfiguration
			{
				Port = 8079,
				RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
				DataDirectory = path,
				Settings =
					{
						{"Raven/Expiration/DeleteFrequencySeconds", "1"},
						{"Raven/ActiveBundles", "DocumentExpiration"}
					}
			};
			ravenConfiguration.PostInit();
			ravenDbServer = new RavenDbServer(
				ravenConfiguration);
			SystemTime.UtcDateTime = () => DateTime.UtcNow;
			documentStore = new DocumentStore
			{
				Url = "http://localhost:8079"
			};
			documentStore.Initialize();
		}
Exemplo n.º 7
0
        private IDocumentStore CreateStoreAtPort(int port, bool enableCompressionBundle = false, bool removeDataDirectory = true, Action <DocumentStore> configureStore = null, AnonymousUserAccessMode anonymousUserAccessMode = AnonymousUserAccessMode.Admin, bool enableAuthorization = false)
        {
            Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);
            var serverConfiguration = new Raven.Database.Config.RavenConfiguration
            {
                Settings = { { "Raven/ActiveBundles", "replication" + (enableCompressionBundle ? ";compression" : string.Empty) } },
                AnonymousUserAccessMode = anonymousUserAccessMode,
                DataDirectory           = "Data #" + stores.Count,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                RunInMemory            = true,
                Port                   = port,
                DefaultStorageTypeName = RavenTest.GetDefaultStorageType()
            };

            ConfigureServer(serverConfiguration);
            if (removeDataDirectory)
            {
                IOExtensions.DeleteDirectory(serverConfiguration.DataDirectory);
            }

            serverConfiguration.PostInit();
            var ravenDbServer = new RavenDbServer(serverConfiguration);

            servers.Add(ravenDbServer);

            if (enableAuthorization)
            {
                RavenTestBase.EnableAuthentication(ravenDbServer.Database);
                ConfigureServer(serverConfiguration);
            }

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

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

            stores.Add(documentStore);

            ConfigureDatbase(ravenDbServer.Database);
            return(documentStore);
        }
Exemplo n.º 8
0
        public VersioningTest()
        {
            path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning)).CodeBase);
            path = Path.Combine(path, "TestDb").Substring(6);
            Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
            var cfg = new Raven.Database.Config.RavenConfiguration
            {
                Port          = 8079,
                DataDirectory = path,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                Settings =
                {
                    { "Raven/ActiveBundles", "Versioning" }
                }
            };

            cfg.PostInit();
            ravenDbServer = new RavenDbServer(cfg);
            documentStore = new DocumentStore
            {
                Url = "http://localhost:8079"
            };
            documentStore.Initialize();
            using (var s = documentStore.OpenSession())
            {
                s.Store(new Raven.Bundles.Versioning.Data.VersioningConfiguration
                {
                    Exclude = true,
                    Id      = "Raven/Versioning/Users",
                });
                s.Store(new Raven.Bundles.Versioning.Data.VersioningConfiguration
                {
                    Exclude = true,
                    Id      = "Raven/Versioning/Comments",
                });
                s.Store(new Raven.Bundles.Versioning.Data.VersioningConfiguration
                {
                    Exclude      = false,
                    Id           = "Raven/Versioning/DefaultConfiguration",
                    MaxRevisions = 5
                });
                s.SaveChanges();
            }
        }
Exemplo n.º 9
0
		public VersioningTest()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
			var cfg = new Raven.Database.Config.RavenConfiguration
			          	{
			          		Port = 8079,
			          		DataDirectory = path,
			          		RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
			          		Settings =
			          			{
			          				{"Raven/ActiveBundles", "Versioning"}
			          			}
			          	};
			cfg.PostInit();
			ravenDbServer = new RavenDbServer(cfg);
			documentStore = new DocumentStore
			{
				Url = "http://localhost:8079"
			};
			documentStore.Initialize();
			using(var s = documentStore.OpenSession())
			{
				s.Store(new Raven.Bundles.Versioning.Data.VersioningConfiguration
				{
					Exclude = true,
					Id = "Raven/Versioning/Users",
				});
				s.Store(new Raven.Bundles.Versioning.Data.VersioningConfiguration
				{
					Exclude = true,
					Id = "Raven/Versioning/Comments",
				});
				s.Store(new Raven.Bundles.Versioning.Data.VersioningConfiguration
				{
					Exclude = false,
					Id = "Raven/Versioning/DefaultConfiguration",
					MaxRevisions = 5
				});
				s.SaveChanges();
			}
		}
Exemplo n.º 10
0
		public Compression()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
			var config = new Raven.Database.Config.RavenConfiguration
			             	{
			             		Port = 8079,
			             		RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
			             		DataDirectory = path,
								Settings = {{"Raven/ActiveBundles", "Compression"}}
			             	};
			config.PostInit();
			ravenDbServer = new RavenDbServer(config);
			documentStore = new DocumentStore
			{
				Url = "http://localhost:8079"
			};
			documentStore.Initialize();
		}
Exemplo n.º 11
0
        public Compression()
        {
            path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase);
            path = Path.Combine(path, "TestDb").Substring(6);
            Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
            var config = new Raven.Database.Config.RavenConfiguration
            {
                Port = 8079,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                DataDirectory = path,
                Settings      = { { "Raven/ActiveBundles", "Compression" } }
            };

            config.PostInit();
            ravenDbServer = new RavenDbServer(config);
            documentStore = new DocumentStore
            {
                Url = "http://localhost:8079"
            };
            documentStore.Initialize();
        }
Exemplo n.º 12
0
        public void StartDatabase(int index)
        {
            var previousServer = servers[index];

            Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(previousServer.Database.Configuration.Port);
            var serverConfiguration = new Raven.Database.Config.RavenConfiguration
            {
                Settings = { { "Raven/ActiveBundles", "replication" } },
                AnonymousUserAccessMode = Raven.Database.Server.AnonymousUserAccessMode.All,
                DataDirectory           = previousServer.Database.Configuration.DataDirectory,
                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                RunInMemory            = previousServer.Database.Configuration.RunInMemory,
                Port                   = previousServer.Database.Configuration.Port,
                DefaultStorageTypeName = RavenTest.GetDefaultStorageType()
            };

            ConfigureServer(serverConfiguration);

            serverConfiguration.PostInit();
            var ravenDbServer = new RavenDbServer(serverConfiguration);

            servers[index] = ravenDbServer;
        }
Exemplo n.º 13
0
		private RavenDbServer CreateServer(int port, string dataDirectory, bool removeDataDirectory = true)
		{
			Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);

			var serverConfiguration = new Raven.Database.Config.RavenConfiguration
			{
				Settings = { { "Raven/ActiveBundles", "replication" } },
                AnonymousUserAccessMode = Raven.Database.Server.AnonymousUserAccessMode.Admin,
				DataDirectory = dataDirectory,
				RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
				RunInMemory = false,
				Port = port,
				DefaultStorageTypeName = "esent"
			};

			if (removeDataDirectory)
				IOExtensions.DeleteDirectory(serverConfiguration.DataDirectory);

			var server = new RavenDbServer(serverConfiguration);
			serverConfiguration.PostInit();

			return server;
		}