-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added example with ScenarioCompletionTimeout
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
examples/Demo/Features/Timeouts/ScenarioCompletionTimeout.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using NBomber.CSharp; | ||
|
||
namespace Demo.Features.Timeouts; | ||
|
||
public class ScenarioCompletionTimeout | ||
{ | ||
public void Run() | ||
{ | ||
// When NBomber finishes load tests, it waits for all running scenarios to complete their tasks. | ||
|
||
var scenario = Scenario.Create("scenario_1", async context => | ||
{ | ||
await Task.Delay(8_000); // set 8 sec, but the duration of the scenario is only 1 sec. | ||
return Response.Ok(); | ||
}) | ||
.WithoutWarmUp() | ||
.WithLoadSimulations(Simulation.KeepConstant(copies: 1, during: TimeSpan.FromSeconds(1))); // set 1 sec duration | ||
|
||
var result = | ||
NBomberRunner | ||
.RegisterScenarios(scenario) | ||
.WithScenarioCompletionTimeout(TimeSpan.FromSeconds(10)) // we set 10 sec to wait | ||
.Run(); | ||
|
||
Console.WriteLine(result.AllOkCount == 1 | ||
? "Scenario completed" | ||
: "Scenario not completed" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters