Exemple #1
0
        public void ShouldThrowExceptionForUnknownStrategy()
        {
            var configuration = new ConfigurationBuilder().Build();

            configuration.Properties["Server:Retry:Strategy"] = "any_unknown_value";
            var factory = new RequestExecuterFactory(configuration);

            factory.Invoking((f) => f.Create()).Should().Throw <Exception>().WithMessage("*any_unknown_value*");
        }
Exemple #2
0
        public void ShouldCreateNoneExecuter()
        {
            var configuration = new ConfigurationBuilder().Build();

            configuration.Properties["Server:Retry:Strategy"] = "none";
            var executer = new RequestExecuterFactory(configuration).Create();

            executer.Should().BeOfType <NoneRetryRequestExecuter>();
        }
Exemple #3
0
        public void ConfigurableLinearRetry()
        {
            var configuration = new ConfigurationBuilder().Build();

            configuration.Properties["Server:Retry:Strategy"]    = "linear";
            configuration.Properties["Server:Retry:MaxAttempts"] = 5;
            configuration.Properties["Server:Retry:Delay"]       = 6000; //secs
            var executer = new RequestExecuterFactory(configuration).Create() as LinearRetryRequestExecuter;

            executer.MaxRetryAttemps.Should().Be(5);
            executer.Delay.Should().Be(6000);
        }
Exemple #4
0
        public void ConfigurableExponentialRetry()
        {
            var configuration = new ConfigurationBuilder().Build();

            configuration.Properties["Server:Retry:Strategy"]    = "exponential";
            configuration.Properties["Server:Retry:MaxAttempts"] = 5;
            configuration.Properties["Server:Retry:BaseIndex"]   = 6;
            var executer = new RequestExecuterFactory(configuration).Create() as ExponentialRetryRequestExecuter;

            executer.MaxRetryAttemps.Should().Be(5);
            executer.BaseIndex.Should().Be(6);
        }
Exemple #5
0
        public void ShouldCreateDefaultExponentialExecuter()
        {
            var configuration = new ConfigurationBuilder().Build();
            var factory       = new RequestExecuterFactory(configuration);
            var executer      = factory.Create();

            executer.Should().BeOfType <ExponentialRetryRequestExecuter>();
            var exponentialExecuter = executer as ExponentialRetryRequestExecuter;

            exponentialExecuter.MaxRetryAttemps.Should().Be(3);
            exponentialExecuter.BaseIndex.Should().Be(2);
        }
Exemple #6
0
        public void ShouldCreateLinearExecuter()
        {
            var configuration = new ConfigurationBuilder().Build();

            configuration.Properties["Server:Retry:Strategy"] = "linear";
            var factory  = new RequestExecuterFactory(configuration);
            var executer = factory.Create();

            executer.Should().BeOfType <LinearRetryRequestExecuter>();
            var exponentialExecuter = executer as LinearRetryRequestExecuter;

            exponentialExecuter.MaxRetryAttemps.Should().Be(3);
            exponentialExecuter.Delay.Should().Be(5000);
        }
Exemple #7
0
        public LaunchReporter Build(int suitesPerLaunch, int testsPerSuite, int logsPerTest)
        {
            var launchReporter = new LaunchReporter(Service, null, RequestExecuterFactory?.Create(), ExtensionManager);

            var launchDateTime = DateTime.UtcNow;

            launchReporter.Start(new StartLaunchRequest
            {
                Name      = "ReportPortal Shared",
                StartTime = launchDateTime,
                Mode      = LaunchMode.Debug
            });

            for (int i = 0; i < suitesPerLaunch; i++)
            {
                var suiteNode = launchReporter.StartChildTestReporter(new StartTestItemRequest
                {
                    Name      = $"Suite {i}",
                    StartTime = launchDateTime.AddMilliseconds(-1),
                    Type      = TestItemType.Suite
                });

                for (int j = 0; j < testsPerSuite; j++)
                {
                    var testNode = suiteNode.StartChildTestReporter(new StartTestItemRequest
                    {
                        Name      = $"Test {j}",
                        StartTime = launchDateTime,
                        Type      = TestItemType.Step
                    });

                    for (int l = 0; l < logsPerTest; l++)
                    {
                        testNode.Log(new CreateLogItemRequest
                        {
                            Level = LogLevel.Info,
                            Text  = $"Log message #{l}",
                            Time  = launchDateTime
                        });
                    }

                    testNode.Finish(new FinishTestItemRequest
                    {
                        EndTime = launchDateTime,
                        Status  = Status.Passed
                    });
                }

                suiteNode.Finish(new FinishTestItemRequest
                {
                    EndTime = launchDateTime,
                    Status  = Status.Passed
                });
            }

            launchReporter.Finish(new FinishLaunchRequest
            {
                EndTime = launchDateTime
            });

            return(launchReporter);
        }