public void StartClustersIfNeeded(int numclusters, ITestOutputHelper output)
        {
            this.output = output;

            if (MultiCluster.Clusters.Count != numclusters)
            {
                if (MultiCluster.Clusters.Count > 0)
                {
                    MultiCluster.StopAllClientsAndClusters();
                }


                output.WriteLine("Creating {0} clusters and clients...", numclusters);
                this.numclusters = numclusters;

                Assert.True(numclusters >= 2);

                var stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();

                // use a random global service id for testing purposes
                var globalserviceid = Guid.NewGuid();
                random = new Random();

                System.Threading.ThreadPool.SetMaxThreads(8, 8);

                // Create clusters and clients
                Cluster = new string[numclusters];
                Client  = new ClientWrapper[numclusters];
                for (int i = 0; i < numclusters; i++)
                {
                    var clustername = Cluster[i] = ((char)('A' + i)).ToString();
                    MultiCluster.NewGeoCluster(globalserviceid, clustername, 1,
                                               cfg => LogConsistencyProviderConfiguration.ConfigureLogConsistencyProvidersForTesting(TestDefaultConfiguration.DataConnectionString, cfg));
                    Client[i] = this.MultiCluster.NewClient(clustername, 0, ClientWrapper.Factory);
                }

                output.WriteLine("Clusters and clients are ready (elapsed = {0})", stopwatch.Elapsed);

                // wait for configuration to stabilize
                MultiCluster.WaitForLivenessToStabilizeAsync().WaitWithThrow(TimeSpan.FromMinutes(1));

                Client[0].InjectClusterConfiguration(Cluster);
                MultiCluster.WaitForMultiClusterGossipToStabilizeAsync(false).WaitWithThrow(TimeSpan.FromMinutes(System.Diagnostics.Debugger.IsAttached ? 60 : 1));

                stopwatch.Stop();
                output.WriteLine("Multicluster is ready (elapsed = {0}).", stopwatch.Elapsed);
            }
            else
            {
                output.WriteLine("Reusing existing {0} clusters and clients.", numclusters);
            }
        }
Ejemplo n.º 2
0
        public BasicLogTestGrainTests() :
            base(
                new TestingSiloOptions
        {
            StartFreshOrleans = true,
            StartPrimary      = true,
            StartSecondary    = false,
            SiloConfigFile    = new FileInfo("OrleansConfigurationForTesting.xml"),
            AdjustConfig      = cfg => LogConsistencyProviderConfiguration.ConfigureLogConsistencyProvidersForTesting(TestDefaultConfiguration.DataConnectionString, cfg)
        }
                )

        {
            this.random = new Random();
        }