コード例 #1
0
        public ESFixture(IMessageSink messageSink)
        {
            _messageSink = messageSink;

            _elasticsearch = new ElasticsearchInside.Elasticsearch(c => c.SetElasticsearchStartTimeout(60)
                                                                   .EnableLogging()
                                                                   .LogTo(s => _messageSink.OnMessage(new Xunit.Sdk.DiagnosticMessage(s ?? string.Empty))));

            _elasticsearch.ReadySync();
        }
        public ClusterFixture(IMessageSink messageSink)
        {
            _messageSink = messageSink;

            _elasticsearch = new ElasticsearchInside.Elasticsearch(c => c.SetElasticsearchStartTimeout(6000)
                                                                   .EnableLogging()
                                                                   .LogTo(s => _messageSink.OnMessage(new Xunit.Sdk.DiagnosticMessage(s ?? string.Empty))));

            _elasticsearch.ReadySync();



            var builder = new TestClusterBuilder();

            // add the cluster id for this instance
            // this allows the silos to safely lookup shared data for this cluster deployment
            // without this we can only share data via static properties and that messes up parallel testing
            builder.ConfigureHostConfiguration(config =>
            {
                config.AddInMemoryCollection(new Dictionary <string, string>()
                {
                    { nameof(TestClusterId), TestClusterId },
                    { nameof(ESEndpoint), _elasticsearch.Url.ToString() }
                });
            });

            // a configurator allows the silos to configure themselves
            // at this time, configurators cannot take injected parameters
            // therefore we must other means of sharing objects as you can see above
            builder.AddSiloBuilderConfigurator <SiloBuilderConfigurator>();
            builder.AddClientBuilderConfigurator <ClientBuilderConfigurator>();

            Cluster = builder.Build();
            Cluster.Deploy();


            //var esTeleM = new ElasticSearchTelemetryConsumer(_elasticsearch.Url, "orleans-telemetry");
            //LogManager.TelemetryConsumers.Add(esTeleM);
            //LogManager.LogConsumers.Add(esTeleM);
        }