Example #1
0
        private async Task <SiloHandle> StartSilo(DirectoryInfo rootDir)
        {
            SiloHandle silo;

            if (this.siloIdx == 0)
            {
                // Setup configuration
                this.builder = new TestClusterBuilder(1)
                {
                    CreateSiloAsync = AppDomainSiloHandle.Create
                };
                TestDefaultConfiguration.ConfigureTestCluster(this.builder);
                builder.Options.ApplicationBaseDirectory = rootDir.FullName;
                builder.AddSiloBuilderConfigurator <VersionGrainsSiloBuilderConfigurator>();
                builder.ConfigureLegacyConfiguration(legacy =>
                {
                    legacy.ClusterConfiguration.Globals.ExpectedClusterSize             = SiloCount;
                    legacy.ClusterConfiguration.Globals.AssumeHomogenousSilosForTesting = false;
                    legacy.ClusterConfiguration.Globals.TypeMapRefreshInterval          = refreshInterval;
                    legacy.ClusterConfiguration.Globals.DefaultVersionSelectorStrategy  = VersionSelectorStrategy;
                    legacy.ClusterConfiguration.Globals.DefaultCompatibilityStrategy    = CompatibilityStrategy;

                    legacy.ClientConfiguration.Gateways = legacy.ClientConfiguration.Gateways.Take(1).ToList(); // Only use primary gw

                    waitDelay = TestClusterLegacyUtils.GetLivenessStabilizationTime(legacy.ClusterConfiguration.Globals, false);
                });

                this.cluster = builder.Build();
                await this.cluster.DeployAsync();

                silo = this.cluster.Primary;
            }
            else
            {
                var configBuilder = new ConfigurationBuilder();
                foreach (var source in cluster.ConfigurationSources)
                {
                    configBuilder.Add(source);
                }
                var testClusterOptions = new TestClusterOptions();
                configBuilder.Build().Bind(testClusterOptions);

                // Override the root directory.
                var sources = new IConfigurationSource[]
                {
                    new MemoryConfigurationSource {
                        InitialData = new TestClusterOptions {
                            ApplicationBaseDirectory = rootDir.FullName
                        }.ToDictionary()
                    }
                };

                silo = await TestCluster.StartSiloAsync(cluster, siloIdx, testClusterOptions, sources);
            }

            this.deployedSilos.Add(silo);
            this.siloIdx++;

            return(silo);
        }
Example #2
0
        private async Task <SiloHandle> StartSilo(FileInfo grainAssembly)
        {
            SiloHandle silo;

            if (this.siloIdx == 0)
            {
                // Setup configuration
                this.builder            = new TestClusterBuilder(1);
                builder.CreateSiloAsync = StandaloneSiloHandle.Create;
                TestDefaultConfiguration.ConfigureTestCluster(this.builder);
                builder.AddSiloBuilderConfigurator <VersionGrainsSiloBuilderConfigurator>();
                builder.AddClientBuilderConfigurator <VersionGrainsClientConfigurator>();
                builder.Properties[nameof(SiloCount)]               = this.SiloCount.ToString();
                builder.Properties[nameof(RefreshInterval)]         = RefreshInterval.ToString();
                builder.Properties[nameof(VersionSelectorStrategy)] = this.VersionSelectorStrategy.Name;
                builder.Properties[nameof(CompatibilityStrategy)]   = this.CompatibilityStrategy.Name;
                builder.Properties["GrainAssembly"] = grainAssembly.FullName;
                builder.Properties[StandaloneSiloHandle.ExecutablePathConfigKey] = grainAssembly.FullName;
                waitDelay = TestCluster.GetLivenessStabilizationTime(new ClusterMembershipOptions(), didKill: false);

                this.cluster = builder.Build();
                await this.cluster.DeployAsync();

                silo = this.cluster.Primary;
            }
            else
            {
                var configBuilder = new ConfigurationBuilder();
                foreach (var source in cluster.ConfigurationSources)
                {
                    configBuilder.Add(source);
                }
                var testClusterOptions = new TestClusterOptions();
                configBuilder.Build().Bind(testClusterOptions);

                // Override the root directory.
                var sources = new IConfigurationSource[]
                {
                    new MemoryConfigurationSource
                    {
                        InitialData = new Dictionary <string, string>
                        {
                            [StandaloneSiloHandle.ExecutablePathConfigKey] = grainAssembly.FullName
                        }
                    }
                };

                silo = await TestCluster.StartSiloAsync(cluster, siloIdx, testClusterOptions, sources);
            }

            this.deployedSilos.Add(silo);
            this.siloIdx++;

            return(silo);
        }