internal static ISiloHostBuilder Configure(ISiloHostBuilder hostBuilder, string databaseName = null)
        {
            if (!TestDefaultConfiguration.GetValue("CosmosDBEndpoint", out string cosmosDBEndpoint) ||
                !TestDefaultConfiguration.GetValue("CosmosDBKey", out string cosmosDBKey))
            {
                throw new IndexConfigurationException("CosmosDB connection values are not specified");
            }

            hostBuilder.AddMemoryGrainStorage(IndexingTestConstants.GrainStore)
            .AddMemoryGrainStorage(IndexingTestConstants.MemoryStore)
            .AddMemoryGrainStorage("PubSubStore")            // PubSubStore service is run for silo startup
            .AddMemoryGrainStorage(IndexingConstants.INDEXING_WORKFLOWQUEUE_STORAGE_PROVIDER_NAME)
            .AddMemoryGrainStorage(IndexingConstants.INDEXING_STORAGE_PROVIDER_NAME)
            .AddSimpleMessageStreamProvider(IndexingConstants.INDEXING_STREAM_PROVIDER_NAME)
            .ConfigureLogging(loggingBuilder =>
            {
                loggingBuilder.SetMinimumLevel(LogLevel.Information);
                loggingBuilder.AddDebug();
            })
            .ConfigureApplicationParts(parts =>
            {
                parts.AddApplicationPart(typeof(BaseIndexingFixture).Assembly);
                parts.AddApplicationPart(typeof(ISimpleGrain).Assembly);
                parts.AddApplicationPart(typeof(SimpleGrain).Assembly);
            });

            return(databaseName != null
                ? hostBuilder.AddCosmosDBGrainStorage(IndexingTestConstants.CosmosDBGrainStorage, opt =>
            {
                opt.AccountEndpoint = cosmosDBEndpoint;
                opt.AccountKey = cosmosDBKey;
                opt.ConnectionMode = Microsoft.Azure.Documents.Client.ConnectionMode.Gateway;
                opt.DropDatabaseOnInit = true;
                opt.AutoUpdateStoredProcedures = true;
                opt.CanCreateResources = true;
                opt.DB = databaseName;
                opt.InitStage = ServiceLifecycleStage.RuntimeStorageServices;
                opt.StateFieldsToIndex.AddRange(GetStateFieldsToIndex());
            })
                : hostBuilder);
        }
Example #2
0
        internal static ISiloHostBuilder Configure(ISiloHostBuilder hostBuilder, string databaseName = null)
        {
            string cosmosDBEndpoint = string.Empty, cosmosDBKey = string.Empty;

            if (databaseName != null)
            {
                if (!TestDefaultConfiguration.GetValue("CosmosDBEndpoint", out cosmosDBEndpoint) ||
                    !TestDefaultConfiguration.GetValue("CosmosDBKey", out cosmosDBKey))
                {
                    throw new IndexConfigurationException("CosmosDB connection values are not specified");
                }
            }

            hostBuilder.AddMemoryGrainStorage(IndexingTestConstants.GrainStore)
            .AddMemoryGrainStorage("PubSubStore")            // PubSubStore service is needed for the streams underlying OrleansQueryResults
            .ConfigureLogging(loggingBuilder =>
            {
                loggingBuilder.SetMinimumLevel(LogLevel.Information);
                loggingBuilder.AddDebug();
            })
            .ConfigureApplicationParts(parts =>
            {
                parts.AddApplicationPart(typeof(BaseIndexingFixture).Assembly).WithReferences();
                parts.AddApplicationPart(typeof(ISimpleGrain).Assembly).WithReferences();
                parts.AddApplicationPart(typeof(SimpleGrain).Assembly).WithReferences();
            });
            return(databaseName != null
                ? hostBuilder.AddCosmosDBGrainStorage(IndexingTestConstants.CosmosDBGrainStorage, opt =>
            {
                opt.AccountEndpoint = cosmosDBEndpoint;
                opt.AccountKey = cosmosDBKey;
                opt.ConnectionMode = Microsoft.Azure.Documents.Client.ConnectionMode.Gateway;
                opt.DropDatabaseOnInit = true;
                opt.AutoUpdateStoredProcedures = true;
                opt.CanCreateResources = true;
                opt.DB = databaseName;
                opt.InitStage = ServiceLifecycleStage.RuntimeStorageServices;
                opt.StateFieldsToIndex.AddRange(GetDSMIStateFieldsToIndex());
            })
                : hostBuilder);
        }