Пример #1
0
        public void Resource_specific_paths_do_not_require_any_suffixes()
        {
            var server = RavenConfiguration.CreateForServer(null);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}Deployment");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Storage.TempPath), $@"{_rootPathString}temp");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.TempPath), $@"{_rootPathString}indexes-temp");

            server.Initialize();

            var database = RavenConfiguration.CreateForDatabase(server, "Foo");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}MyDatabase");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Storage.TempPath), $@"{_rootPathString}my-temp-path");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.TempPath), $@"{_rootPathString}my-indexes-temp");

            database.Initialize();

            Assert.Equal(new PathSetting($@"{_rootPathString}MyDatabase").FullPath, database.Core.DataDirectory.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}my-temp-path").FullPath, database.Storage.TempPath.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}my-indexes-temp").FullPath, database.Indexing.TempPath.FullPath);
        }
Пример #2
0
        public void Default_database_path_settings()
        {
            var config = RavenConfiguration.CreateForTesting("foo", ResourceType.Database, _emptySettingFile);

            config.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            config.Initialize();

            Assert.Equal(new PathSetting("Databases/foo").FullPath, config.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting("Databases/foo/Indexes").FullPath, config.Indexing.StoragePath.FullPath);

            Assert.Null(config.Indexing.TempPath);

            Assert.Null(config.Storage.TempPath);

            // actual configuration is created in the following manner

            config = RavenConfiguration.CreateForDatabase(RavenConfiguration.CreateForServer(null, _emptySettingFile), "foo");

            config.Initialize();

            Assert.Equal(new PathSetting("Databases/foo").FullPath, config.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting("Databases/foo/Indexes").FullPath, config.Indexing.StoragePath.FullPath);

            Assert.Null(config.Indexing.TempPath);

            Assert.Null(config.Storage.TempPath);
        }
Пример #3
0
        protected RavenConfiguration CreateConfiguration(DatabaseRecord record)
        {
            Debug.Assert(_serverStore.Disposed == false);
            var config = RavenConfiguration.CreateForDatabase(_serverStore.Configuration, record.DatabaseName);

            foreach (var setting in record.Settings)
            {
                config.SetSetting(setting.Key, setting.Value);
            }

            config.Initialize();

            return(config);
        }
Пример #4
0
        public void CanParseNestedJsonObjectsFromSettingsJsonFile()
        {
            DoNotReuseServer();

            string settingsJsonFile = default;

            try
            {
                const string jsonWithNestedContent = @"{
                                                         ""ETL.MaxBatchSizeInMb"":77,
                                                         ""ETL"":
                                                         {
                                                            ""MaxNumberOfExtractedItems"":222,
                                                            ""MaxNumberOfExtractedDocuments"":333
                                                         },
                                                         ""ETL"":
                                                         {
                                                            ""SQL"":
                                                            {
                                                               ""CommandTimeoutInSec"":444
                                                            }
                                                         }
                                                      }";

                settingsJsonFile = Path.Combine($"{Path.GetDirectoryName(GetTempFileName())}", "settings.json");
                File.WriteAllText(settingsJsonFile, jsonWithNestedContent);

                var serverConfig = RavenConfiguration.CreateForServer(null, settingsJsonFile);
                serverConfig.Initialize();

                var databaseConfig = RavenConfiguration.CreateForDatabase(serverConfig, "dbName");
                databaseConfig.Initialize();

                Assert.Equal("77 MBytes", serverConfig.Etl.MaxBatchSize.ToString());
                Assert.Equal(222, serverConfig.Etl.MaxNumberOfExtractedItems);
                Assert.Equal(333, serverConfig.Etl.MaxNumberOfExtractedDocuments);
                Assert.Equal(444, serverConfig.Etl.SqlCommandTimeout.Value.GetValue(TimeUnit.Seconds));

                Assert.Equal("77 MBytes", databaseConfig.Etl.MaxBatchSize.ToString());
                Assert.Equal(222, databaseConfig.Etl.MaxNumberOfExtractedItems);
                Assert.Equal(333, databaseConfig.Etl.MaxNumberOfExtractedDocuments);
                Assert.Equal(444, databaseConfig.Etl.SqlCommandTimeout.Value.GetValue(TimeUnit.Seconds));
            }
            finally
            {
                File.Delete(settingsJsonFile);
            }
        }
Пример #5
0
        public void ShouldWork()
        {
            var server = RavenConfiguration.CreateForServer(null);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Storage.ForceUsing32BitsPager), "true");
            server.Initialize(); // should not throw

            Assert.True(server.Storage.ForceUsing32BitsPager);

            var database = RavenConfiguration.CreateForDatabase(server, "dbName");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Storage.ForceUsing32BitsPager), "true");

            var e = Assert.Throws <InvalidOperationException>(() => database.Initialize());

            Assert.Equal($"Configuration '{RavenConfiguration.GetKey(x => x.Storage.ForceUsing32BitsPager)}' can only be set at server level.", e.Message);
        }
Пример #6
0
        public void Null_path_database_setting_should_default_to_server_value()
        {
            var server = RavenConfiguration.CreateForServer(null);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), "/mnt/Raven/Data");

            server.Initialize();

            var database = RavenConfiguration.CreateForDatabase(server, "foo");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), null);

            database.Initialize();

            Assert.Equal(new PathSetting("/mnt/Raven/Data/Databases/foo").FullPath, database.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting("/mnt/Raven/Data/Databases/foo/Indexes").FullPath, database.Indexing.StoragePath.FullPath);
        }
Пример #7
0
        public void Should_create_data_in_directory_specified_at_server_level()
        {
            var server = RavenConfiguration.CreateForServer(null);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}RavenData");

            server.Initialize();

            var database = RavenConfiguration.CreateForDatabase(server, "Foo");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), @"Items");

            database.Initialize();

            Assert.Equal(new PathSetting($@"{_rootPathString}RavenData\Items").FullPath, database.Core.DataDirectory.FullPath);
        }
Пример #8
0
        public void Database_creation_using_relative_path_creates_directories_incorrectly()
        {
            var server = RavenConfiguration.CreateForServer(null);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");
            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), "RavenData");

            server.Initialize();

            var database = RavenConfiguration.CreateForDatabase(server, "foo");

            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");
            database.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), @"MyWork\MyDatabaseFolder");

            database.Initialize();

            Assert.Equal(new PathSetting("RavenData/MyWork/MyDatabaseFolder").FullPath, database.Core.DataDirectory.FullPath);
            Assert.Equal(new PathSetting("RavenData/MyWork/MyDatabaseFolder/Indexes").FullPath, database.Indexing.StoragePath.FullPath);
        }
Пример #9
0
        public void Inherits_server_settings_and_appends_resource_specific_suffix_paths()
        {
            var server = RavenConfiguration.CreateForServer(null);

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.RunInMemory), "true");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Core.DataDirectory), $@"{_rootPathString}Deployment");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Storage.TempPath), $@"{_rootPathString}temp");

            server.SetSetting(RavenConfiguration.GetKey(x => x.Indexing.TempPath), $@"{_rootPathString}indexes-temp");

            server.Initialize();

            var database = RavenConfiguration.CreateForDatabase(server, "Foo");

            database.Initialize();

            Assert.Equal(new PathSetting($@"{_rootPathString}Deployment\Databases\Foo").FullPath, database.Core.DataDirectory.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}temp\Databases\Foo").FullPath, database.Storage.TempPath.FullPath);

            Assert.Equal(new PathSetting($@"{_rootPathString}indexes-temp\Databases\Foo").FullPath, database.Indexing.TempPath.FullPath);
        }