PragmaticFlow / NBomber

Modern and flexible load testing framework for Pull and Push scenarios, designed to test any system regardless a protocol (HTTP/WebSockets/AMQP etc) or a semantic model (Pull/Push).

Home Page:https://nbomber.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add possibility to have appropriate statistics for collection of http calls

destructorvad opened this issue · comments

Hello
I want to have collection of http calls inside same scenario. here is my code:

  var scenario = Scenario.Create("Create_assets_with_data", async context =>
            {
                await Step.Run("Create_asset", context, async () =>
                {
                    for (int i = 0; i < 20; i++)
                    {
                        var request =
                            Http.CreateRequest("Post", $"/api/import/assets")
                                .WithHeader("Authorization", AuthorizationHeader)
                                .WithBody(Body);

                        var response = await Http.Send(httpClient, request);
                    }
                    return Response.Ok();
                });

                return Response.Ok();
            })
            .WithInit(Init);

The problem with this code - it has no actually correct statistics (RPS, Failed requests count etc)
Other option - is to have step for each of http call - but I don't like this idea - since logically its same step.
I would greatly appreciate any ideas.

Hi @destructorvad
Can you please elaborate on what statistics you are looking for?
Maybe some examples that you have seen in other tools?

Also question, why not to wrap Step.Run in your for loop?

@AntyaDev I dont have examples in other tools - but I have following code:

 await Step.Run("Create_structural_element_and_structural_objects", context, async () =>
                {
                    foreach (var structuralElementDto in data.StructuralElements)
                    {
                        var response = await Http.Send(httpClient, GetRequest(structuralElementDto));
                        if (createStructuralElementResponse.IsError) return Response.Fail();
                    }
                    return Response.Ok();
                });

Here is statistics result:
| name | Create_structural_element_and_structural_objects |
+--------------------+---------------------------------------------------------------+
| request count | all = 2, ok = 2, RPS = 2 |
+--------------------+---------------------------------------------------------------+
| latency | min = 4897.34, mean = 4921.34, max = 4944.81, StdDev = 24.58 |
+--------------------+---------------------------------------------------------------+
| latency percentile | p50 = 4898.81, p75 = 4947.97, p95 = 4947.97, p99 = 4947.97 |

What I want to see in statistics:

Number of actual http calls, mean, latency for every http call - now I see it for the whole step. As a variant - return not one response from step - but collection of responses (it can be used for per request statistics)

Also question, why not to wrap Step.Run in your for loop?

Do you mean one step per every http call ?

Yeah, something like this?

foreach (var structuralElementDto in data.StructuralElements)
{
    Step.Run("Create_structural_element_and_structural_objects"
}

I understand that maybe it's not so convenient compared to your proposal, but keep in mind that NBomber doesn't know much about HTTP/WebSockets/gRPC, etc. Conceptually NBomber knows only about step/scenario abstraction.

Does it make sense?

Ok, thanks for your help :)