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

            if (this.siloIdx == 0)
            {
                // Setup configuration
                this.builder = new TestClusterBuilder(1);
                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.ClusterConfiguration.AddMemoryStorageProvider("Default");

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

                    waitDelay = TestCluster.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 = TestCluster.StartOrleansSilo(cluster, siloIdx, testClusterOptions, sources);
            }

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

            return(silo);
        }
        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);
        }
Beispiel #3
0
        private async Task <SiloHandle> StartSilo(DirectoryInfo rootDir)
        {
            string siloName;

            Silo.SiloType siloType;
            if (this.siloIdx == 0)
            {
                // First silo
                siloName = Silo.PrimarySiloName;
                siloType = Silo.SiloType.Primary;
                // Setup configuration
                this.options = new TestClusterOptions(SiloCount);
                options.ClusterConfiguration.Globals.AssumeHomogenousSilosForTesting = false;
                options.ClusterConfiguration.Globals.TypeMapRefreshInterval          = refreshInterval;
                options.ClusterConfiguration.Globals.DefaultVersionSelectorStrategy  = VersionSelectorStrategy;
                options.ClusterConfiguration.Globals.DefaultCompatibilityStrategy    = CompatibilityStrategy;
                options.ClientConfiguration.Gateways = options.ClientConfiguration.Gateways.Take(1).ToList(); // Only use primary gw
                options.ClusterConfiguration.AddMemoryStorageProvider("Default");
                waitDelay = TestCluster.GetLivenessStabilizationTime(options.ClusterConfiguration.Globals, false);
            }
            else
            {
                // Secondary Silo
                siloName = $"Secondary_{siloIdx}";
                siloType = Silo.SiloType.Secondary;
            }

            var silo = AppDomainSiloHandle.Create(
                siloName,
                siloType,
                typeof(TestVersionGrains.VersionGrainsSiloBuilderFactory),
                this.options.ClusterConfiguration,
                this.options.ClusterConfiguration.Overrides[siloName],
                applicationBase: rootDir.FullName);

            if (this.siloIdx == 0)
            {
                // If it was the first silo, setup the client
                Client = new ClientBuilder()
                         .ConfigureApplicationParts(parts => parts.AddFromAppDomain().AddFromApplicationBaseDirectory())
                         .UseConfiguration(options.ClientConfiguration)
                         .Build();
                await Client.Connect();

                ManagementGrain = Client.GetGrain <IManagementGrain>(0);
            }

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

            return(silo);
        }
Beispiel #4
0
        protected async Task DeployCluster()
        {
            this.options = new TestClusterOptions(2);
            options.ClusterConfiguration.Globals.AssumeHomogenousSilosForTesting = false;
            options.ClusterConfiguration.Globals.TypeMapRefreshInterval          = refreshInterval;
            options.ClusterConfiguration.Globals.DefaultVersionSelectorStrategy  = VersionSelectorStrategy;
            options.ClusterConfiguration.Globals.DefaultCompatibilityStrategy    = CompatibilityStrategy;
            options.ClientConfiguration.Gateways.RemoveAt(1); // Only use primary gw

            waitDelay = TestCluster.GetLivenessStabilizationTime(options.ClusterConfiguration.Globals, false);

            await StartSiloV1();

            Client = new ClientBuilder().UseConfiguration(options.ClientConfiguration).Build();
            await Client.Connect();
        }
Beispiel #5
0
        private async Task <bool> WaitForClusterSize(int expectedSize)
        {
            var mgmtGrain = this.Client.GetGrain <IManagementGrain>(0);
            var timeout   = TestCluster.GetLivenessStabilizationTime(new Orleans.Configuration.MembershipOptions());
            var stopWatch = Stopwatch.StartNew();

            do
            {
                var hosts = await mgmtGrain.GetHosts();

                if (hosts.Count == expectedSize)
                {
                    stopWatch.Stop();
                    return(true);
                }
                await Task.Delay(500);
            }while (stopWatch.Elapsed < timeout);
            return(false);
        }
        /// <summary>
        /// Get the timeout value to use to wait for the silo liveness sub-system to detect and act on any recent cluster membership changes.
        /// </summary>
        public static TimeSpan GetLivenessStabilizationTime(GlobalConfiguration config, bool didKill = false)
        {
            var clusterMembershipOptions = new ClusterMembershipOptions()
            {
                NumMissedTableIAmAliveLimit = config.NumMissedTableIAmAliveLimit,
                LivenessEnabled             = config.LivenessEnabled,
                ProbeTimeout                = config.ProbeTimeout,
                TableRefreshTimeout         = config.TableRefreshTimeout,
                DeathVoteExpirationTimeout  = config.DeathVoteExpirationTimeout,
                IAmAliveTablePublishTimeout = config.IAmAliveTablePublishTimeout,
                MaxJoinAttemptTime          = config.MaxJoinAttemptTime,
                ValidateInitialConnectivity = config.ValidateInitialConnectivity,
                NumMissedProbesLimit        = config.NumMissedProbesLimit,
                UseLivenessGossip           = config.UseLivenessGossip,
                NumProbedSilos              = config.NumProbedSilos,
                NumVotesForDeathDeclaration = config.NumVotesForDeathDeclaration,
            };

            return(TestCluster.GetLivenessStabilizationTime(clusterMembershipOptions, didKill));
        }
Beispiel #7
0
        public UpgradeTests()
        {
            // Setup dll references
            // If test run from cmdlime
            if (Directory.Exists(AssemblyGrainsV1Build))
            {
                assemblyGrainsV1Dir = new DirectoryInfo(AssemblyGrainsV1Build);
                assemblyGrainsV2Dir = new DirectoryInfo(AssemblyGrainsV2Build);
            }
            // If test run from VS
            else
            {
                // If not run from vnext
                if (Directory.Exists(AssemblyGrainsV1Vs))
                {
                    assemblyGrainsV1Dir = new DirectoryInfo(AssemblyGrainsV1Vs);
                    assemblyGrainsV2Dir = new DirectoryInfo(AssemblyGrainsV2Vs);
                }
                else
                {
                    // vnext
                    var target = @"\net462";
                    assemblyGrainsV1Dir = new DirectoryInfo(@"..\" + AssemblyGrainsV1Vs + target);
                    assemblyGrainsV2Dir = new DirectoryInfo(@"..\" + AssemblyGrainsV2Vs + target);
                }
            }

            this.options = new TestClusterOptions(2);
            options.ClusterConfiguration.Globals.AssumeHomogenousSilosForTesting = false;
            options.ClusterConfiguration.Globals.TypeMapRefreshInterval          = refreshInterval;
            options.ClientConfiguration.Gateways.RemoveAt(1); // Only use primary gw

            waitDelay = TestCluster.GetLivenessStabilizationTime(options.ClusterConfiguration.Globals, false);

            StartSiloV1();
            client = new ClientBuilder().UseConfiguration(options.ClientConfiguration).Build();
            client.Connect().Wait();
        }
        private static async Task <bool> WaitForClusterSizeAsync(TestCluster cluster, int expectedSize)
        {
            var managementGrain = cluster.Client.GetGrain <IManagementGrain>(0);

            var timeout = TestCluster.GetLivenessStabilizationTime(new ClusterMembershipOptions());

            var stopWatch = Stopwatch.StartNew();

            do
            {
                var hosts = await managementGrain.GetHosts();

                if (hosts.Count == expectedSize)
                {
                    stopWatch.Stop();
                    return(true);
                }

                await Task.Delay(100);
            }while (stopWatch.Elapsed < timeout);

            return(false);
        }