Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
MHKarami97 committed Oct 29, 2024
1 parent acd850a commit b65c2cc
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions _posts/2024-10-28-load_test_with_nbomber.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,26 @@ public class ApiTest(ApiModel apiModel, LoadTestModel loadConfig, CreatorRule cr

protected override ScenarioProps CreateStep()
{
return Scenario.Create(loadConfig.Name, async _ =>
return Scenario.Create(loadConfig.Name, async context =>
{
try
{
context.Logger.Information("the current session id {0}", context.TestInfo.SessionId);

if (context.InvocationNumber > 10)
{
context.Logger.Debug("the current Scenario copy was invoked more than 10 times");
}

if (context.NodeInfo.CurrentOperation == OperationType.Bombing)
{
context.Logger.Debug("Bombing!!!");
}
else if (context.NodeInfo.CurrentOperation == OperationType.WarmUp)
{
context.Logger.Debug("Warm Up!!!");
}

var model = _creator.Build();

var request = Http.CreateRequest(apiModel.Method, apiModel.Address)
Expand Down Expand Up @@ -282,13 +298,19 @@ public class ApiTest(ApiModel apiModel, LoadTestModel loadConfig, CreatorRule cr
return Response.Fail(message: ex.Message);
}
})
.WithClean(_ =>
.WithInit(context =>
{
context.Logger.Information("init");

return Task.CompletedTask;
})
.WithClean(context =>
{
try
{
_httpClient.Dispose();

Console.WriteLine("httpClient disposed after test");
context.Logger.Information("cleaned");
}
catch (Exception e)
{
Expand Down

0 comments on commit b65c2cc

Please sign in to comment.