public DocumentStoreTestConfiguration(String engineVersion = "v3", String tenantId = "tests")
        {
            if (engineVersion != "v3")
            {
                throw new NotSupportedException("Only v3 is supported with this version of NES");
            }
            EngineVersion      = engineVersion;
            IsApiServer        = true;
            IsWorker           = false;
            IsReadmodelBuilder = true;

            QueueConnectionString = ConfigurationManager.ConnectionStrings["ds.queue"].ConnectionString;
            LogsConnectionString  = ConfigurationManager.ConnectionStrings["log"].ConnectionString;

            QueueInfoList = new Core.Jobs.QueueManager.QueueInfo[] { };

            QueueJobsPollInterval   = 100; //poll each 100 milliseconds.
            QueueStreamPollInterval = 1000;
            IsQueueManager          = false;
            TenantSettings.Add(new TestTenantSettings(tenantId));
            BucketInfo = new List <BucketInfo>()
            {
                new BucketInfo()
                {
                    Slots = new[] { "*" }, BufferSize = 10
                }
            };
            Boost = "true";
            DelayedStartInMilliseconds = 1000;
            ForcedGcSecondsInterval    = 0;
            EngineSlots           = new String[] { "*" };
            PollingMsInterval     = 100;
            AllowedFileTypes      = "pdf|xls|xlsx|docx|doc|ppt|pptx|pps|ppsx|rtf|odt|ods|odp|htmlzip|eml|msg|jpeg|jpg|png|zip|txt".Split('|');
            IsDeduplicationActive = true;
            StorageType           = StorageType.GridFs;
        }
        private void Configure()
        {
            GetStorageConfiguration();

            var tenants = ConfigurationServiceClient.Instance.GetStructuredSetting("tenants");

            foreach (string tenant in tenants) // conversion from dynamic array
            {
                TenantSettings.Add(new DocumentStoreTenantSettings(tenant, this));
            }

            IsDeduplicationActive = "true".Equals(ConfigurationServiceClient.Instance.GetSetting("deduplication-active", "true"), StringComparison.OrdinalIgnoreCase);
            var allowedFileList = ConfigurationServiceClient.Instance.GetSetting("allowed-file-types", "pdf|xls|xlsx|docx|doc|ppt|pptx|pps|ppsx|rtf|odt|ods|odp|htmlzip|eml|msg|jpeg|jpg|png|zip");

            AllowedFileTypes = allowedFileList != "*" ? allowedFileList.Split('|') : null;

            QueueConnectionString = ConfigurationServiceClient.Instance.GetSetting("connectionStrings.ds-queues");
            LogsConnectionString  = ConfigurationServiceClient.Instance.GetSetting("connectionStrings.ds-logs");

            IsApiServer        = GetBool("api");
            IsWorker           = GetBool("worker");
            IsReadmodelBuilder = GetBool("projections");
            IsQueueManager     = GetBool("queueManager");

            JobsManagement = JsonConvert.DeserializeObject <JobsManagementConfiguration>(
                ConfigurationServiceClient.Instance.GetSetting("jobsManagement"));
            QueueStreamPollInterval = GetInt32("queues.stream-poll-interval-ms", 1000);
            QueueJobsPollInterval   = GetInt32("queues.jobs-poll-interval-ms", 1000);
            List <QueueInfo> queueInfoList = new List <QueueInfo>();

            if (IsQueueManager)
            {
                FillQueueList(queueInfoList);
            }
            QueueInfoList = queueInfoList.ToArray();

            //App.config configuration
            var apiBindings = ConfigurationServiceClient.Instance.GetStructuredSetting("api-bindings");

            foreach (var binding in apiBindings)
            {
                AddServerAddress((string)binding);
            }

            var metersOptions = ConfigurationServiceClient.Instance.GetStructuredSetting("meters");

            foreach (var binding in metersOptions)
            {
                AddMetersOptions((string)binding.Name, (string)binding.Value);
            }

            EngineVersion = ConfigurationServiceClient.Instance.GetSetting("nes-engine-version", "v3");
            ConfigurationServiceClient.Instance.WithArraySetting("poller-buckets", buckets =>
            {
                if (buckets != null)
                {
                    BucketInfo = buckets.Select(b => new BucketInfo()
                    {
                        Slots      = b.slots.ToString().Split(','),
                        BufferSize = (Int32)b.buffer,
                    }).ToList();
                }
                else
                {
                    //No bucket configured, just start with a single bucket for all slots.
                    BucketInfo = new List <BucketInfo>()
                    {
                        new BucketInfo()
                        {
                            BufferSize = 5000, Slots = new [] { "*" }
                        }
                    };
                }
            });
            Rebuild     = "true".Equals(ConfigurationServiceClient.Instance.GetSetting("rebuild", "false"), StringComparison.OrdinalIgnoreCase);
            NitroMode   = "true".Equals(ConfigurationServiceClient.Instance.GetSetting("nitro-mode", "false"), StringComparison.OrdinalIgnoreCase);
            EngineSlots = ConfigurationServiceClient.Instance.GetSetting("engine-slots", "*").Split(',');

            PollingMsInterval          = Int32.Parse(ConfigurationServiceClient.Instance.GetSetting("polling-interval-ms", "1000"));
            ForcedGcSecondsInterval    = Int32.Parse(ConfigurationServiceClient.Instance.GetSetting("memory-collect-seconds", "0"));
            DelayedStartInMilliseconds = Int32.Parse(ConfigurationServiceClient.Instance.GetSetting("poller-delayed-start", "2000"));

            Boost = ConfigurationServiceClient.Instance.GetSetting("engine-multithread", "false");

            // import from filesystem
            var fileQueue     = ConfigurationServiceClient.Instance.GetStructuredSetting("file-queue");
            var listOfFolders = new List <string>();

            foreach (var folder in fileQueue)
            {
                listOfFolders.Add((string)folder);
            }
            MonitorFolders(listOfFolders.ToArray());

            EnableSnapshotCache = "true".Equals(ConfigurationServiceClient.Instance.GetSetting("enable-snapshot-cache", "true"), StringComparison.OrdinalIgnoreCase);
            EnableSingleAggregateRepositoryCache = "true".Equals(ConfigurationServiceClient.Instance.GetSetting("enable-single-aggregate-repository-cache", "true"), StringComparison.OrdinalIgnoreCase);
            DisableRepositoryLockOnAggregateId   = "true".Equals(ConfigurationServiceClient.Instance.GetSetting("disable-lock-on-aggregate-id", "false"), StringComparison.OrdinalIgnoreCase);
        }