コード例 #1
0
        public async void ExploreSolution_GetAllReservations_LoadTest()
        {
            string   baseUrl        = "https://exploresolutionapi.azurewebsites.net";
            string   loginUrl       = baseUrl + "/api/Authentication/request";
            string   getAllToursUrl = baseUrl + "/api/reservations/GetAllReservations";
            TimeSpan warmUp         = TimeSpan.FromMinutes(1);

            IStep loginStep = Auth(loginUrl);

            var getAllReservations = HttpStep.Create("getReservations", async(context) =>
            {
                var responseContent = context.Data as HttpResponseMessage;
                var authToken       = await responseContent.Content.ReadAsStringAsync();
                return(Http.CreateRequest("GET", getAllToursUrl)
                       .WithHeader("Authorization", $"Bearer {authToken}"));
                //.WithCheck(async response =>
                //{
                //    return response.IsSuccessStatusCode ? Response.Ok() : Response.Fail();
                //});
            });

            var influxConfig = InfluxDbSinkConfig.Create("https://westeurope-1.azure.cloud2.influxdata.com", dbName: "*****@*****.**");
            var influxDb     = new InfluxDBSink(influxConfig);

            var scenario = ScenarioBuilder.CreateScenario("Get All Reservations", new[] { loginStep, getAllReservations })
                           .WithWarmUpDuration(warmUp)
                           .WithLoadSimulations(new[]
            {
                Simulation.RampPerSec(10, TimeSpan.FromMinutes(1))
            });

            var nodeStats = NBomberRunner.RegisterScenarios(scenario).Run();
        }
コード例 #2
0
        public static void Run()
        {
            var step = Step.Create("step", async context =>
            {
                await Task.Delay(TimeSpan.FromSeconds(0.1));
                return(Response.Ok(sizeBytes: 100));
            });

            var scenario = ScenarioBuilder
                           .CreateScenario("simple_scenario", step)
                           .WithoutWarmUp()
                           .WithLoadSimulations(Simulation.KeepConstant(1, TimeSpan.FromMinutes(1)));

            var influxConfig = InfluxDbSinkConfig.Create("http://localhost:8086", dbName: "default");
            var influxDb     = new InfluxDBSink(influxConfig);

            NBomberRunner
            .RegisterScenarios(scenario)
            .WithTestSuite("reporting")
            .WithTestName("influx_test")
            .WithReportingSinks(
                reportingSinks: new[] { influxDb },
                sendStatsInterval: TimeSpan.FromSeconds(10)
                )
            .Run();
        }