File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 31
31
<PackageReference Include =" Bogus" Version =" 34.0.2" />
32
32
<PackageReference Include =" Dapper.Contrib" Version =" 2.0.78" />
33
33
<PackageReference Include =" LiteDB" Version =" 5.0.15" />
34
- <PackageReference Include =" NBomber" Version =" 5.2.0 " />
34
+ <PackageReference Include =" NBomber" Version =" 5.2.1 " />
35
35
<PackageReference Include =" NBomber.Data" Version =" 5.0.0" />
36
36
<PackageReference Include =" NBomber.Http" Version =" 5.0.0" />
37
37
<PackageReference Include =" NBomber.Sinks.InfluxDB" Version =" 5.0.0" />
Original file line number Diff line number Diff line change
1
+ using NBomber . CSharp ;
2
+
3
+ namespace Demo . Features . Timeouts ;
4
+
5
+ public class ScenarioCompletionTimeout
6
+ {
7
+ public void Run ( )
8
+ {
9
+ // When NBomber finishes load tests, it waits for all running scenarios to complete their tasks.
10
+
11
+ var scenario = Scenario . Create ( "scenario_1" , async context =>
12
+ {
13
+ await Task . Delay ( 8_000 ) ; // set 8 sec, but the duration of the scenario is only 1 sec.
14
+ return Response . Ok ( ) ;
15
+ } )
16
+ . WithoutWarmUp ( )
17
+ . WithLoadSimulations ( Simulation . KeepConstant ( copies : 1 , during : TimeSpan . FromSeconds ( 1 ) ) ) ; // set 1 sec duration
18
+
19
+ var result =
20
+ NBomberRunner
21
+ . RegisterScenarios ( scenario )
22
+ . WithScenarioCompletionTimeout ( TimeSpan . FromSeconds ( 10 ) ) // we set 10 sec to wait
23
+ . Run ( ) ;
24
+
25
+ Console . WriteLine ( result . AllOkCount == 1
26
+ ? "Scenario completed"
27
+ : "Scenario not completed"
28
+ ) ;
29
+ }
30
+ }
Original file line number Diff line number Diff line change 8
8
using Demo . Features . ElasticsearchLogger ;
9
9
using Demo . Features . RealtimeReporting . CustomReportingSink ;
10
10
using Demo . Features . RealtimeReporting . InfluxDB ;
11
+ using Demo . Features . Timeouts ;
11
12
using Demo . HelloWorld ;
12
13
using Demo . HelloWorld . LoadSimulation ;
13
14
using Demo . HTTP ;
18
19
// -------------------------------
19
20
// -----Hello World examples -----
20
21
// -------------------------------
21
- // new HelloWorldExample().Run();
22
+ new HelloWorldExample ( ) . Run ( ) ;
22
23
// new ScenarioWithInit().Run();
23
24
// new ScenarioWithSteps().Run();
24
25
// new StepsShareData().Run();
44
45
// new CustomReportingExample().Run();
45
46
// new ElasticsearchExample().Run();
46
47
48
+ // ---- Timeouts ----
49
+ // new ScenarioCompletionTimeout().Run();
50
+
47
51
// ----------------
48
52
// ----- HTTP -----
49
53
// ----------------
70
74
// ---------------------
71
75
// ----- Cluster -------
72
76
// ---------------------
73
- new AutoClusterExample ( ) . Run ( ) ;
77
+ // new AutoClusterExample().Run();
74
78
You can’t perform that action at this time.
0 commit comments