From b65c2cc88d88f5b0ef1838be9d63dff55380cb8a Mon Sep 17 00:00:00 2001 From: mhkarami97 Date: Tue, 29 Oct 2024 16:44:18 +0330 Subject: [PATCH] fixed --- _posts/2024-10-28-load_test_with_nbomber.md | 28 ++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/_posts/2024-10-28-load_test_with_nbomber.md b/_posts/2024-10-28-load_test_with_nbomber.md index a6f580e..7e70e0b 100644 --- a/_posts/2024-10-28-load_test_with_nbomber.md +++ b/_posts/2024-10-28-load_test_with_nbomber.md @@ -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) @@ -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) {