Example #1
0
        static async Task RunFailoverTestScenarioAsync(string clusterConnection, Uri serviceName)
        {
            TimeSpan maxServiceStabilizationTimeout = TimeSpan.FromSeconds(180);
            PartitionSelector randomPartitionSelector = PartitionSelector.RandomOf(serviceName);

            // Create FabricClient with connection & security information here.
            FabricClient fabricClient = new FabricClient(clusterConnection);

            // The Chaos Test Scenario should run at least 60 minutes or up until it fails.
            TimeSpan timeToRun = TimeSpan.FromMinutes(60);
            FailoverTestScenarioParameters scenarioParameters = new FailoverTestScenarioParameters(
              randomPartitionSelector,
              timeToRun,
              maxServiceStabilizationTimeout);

            // Other related parameters:
            // Pause between two iterations for a random duration bound by this value.
            // scenarioParameters.WaitTimeBetweenIterations = TimeSpan.FromSeconds(30);
            // Pause between concurrent actions for a random duration bound by this value.
            // scenarioParameters.WaitTimeBetweenFaults = TimeSpan.FromSeconds(10);

            // Create the scenario class and execute it asynchronously.
            FailoverTestScenario chaosScenario = new FailoverTestScenario(fabricClient, scenarioParameters);

            try
            {
                await chaosScenario.ExecuteAsync(CancellationToken.None);
            }
            catch (AggregateException ae)
            {
                throw ae.InnerException;
            }
        }
Example #2
0
        /// <summary>
        /// Executes a fail over test scenario.
        /// </summary>
        /// <param name="serviceName">Uri containing the service name.</param>
        /// <param name="handler">Progress changed handler.</param>
        /// <param name="duration">Duration of the test.</param>
        /// <param name="stabilization">Duration of the stabilization period.</param>
        /// <param name="token">CancellationToken instance.</param>
        /// <returns>Task instance.</returns>
        private async Task ExecuteFailoverTestScenarioAsync(Uri serviceName, ProgressChangedEventHandler handler, TimeSpan stabilization, CancellationToken token)
        {
            Console.WriteLine($"Starting Failover scenario test on {serviceName.AbsoluteUri} lasting {_duration.TotalMinutes} minutes.");

            FailoverTestScenarioParameters ftsp = new FailoverTestScenarioParameters(PartitionSelector.RandomOf(serviceName), _duration, stabilization);

            FailoverTestScenario fts = new FailoverTestScenario(_client, ftsp);

            fts.ProgressChanged += handler;

            try
            {
                await fts.ExecuteAsync(token);
            }
            catch (AggregateException ex) { CommonExceptionHandler.OutputInnerExceptions(ex); }
            catch (Exception ex) { Console.WriteLine($"FaultTest.RunAsync Exception: {ex.Message} at {ex.StackTrace}"); }
        }
Example #3
0
        static async Task RunFailoverTestScenarioAsync(string clusterConnection, Uri serviceName)
        {
            TimeSpan          maxClusterStabilizationTimeout = TimeSpan.FromSeconds(180);
            PartitionSelector randomPartitionSelector        = PartitionSelector.RandomOf(serviceName);

            FabricClient fabricClient = new FabricClient(clusterConnection);

            TimeSpan timeToRun = TimeSpan.FromMinutes(60);
            FailoverTestScenarioParameters scenarioParameters = new FailoverTestScenarioParameters(
                randomPartitionSelector,
                timeToRun,
                maxClusterStabilizationTimeout);

            FailoverTestScenario failoverScenario = new FailoverTestScenario(fabricClient, scenarioParameters);

            try
            {
                await failoverScenario.ExecuteAsync(CancellationToken.None);
            }
            catch (AggregateException ae)
            {
                throw ae.InnerException;
            }
        }