Skip to content

Commit ee72777

Browse files
committed
#521 Add API method NBomberRunner.EnableStopTestForcibly
1 parent 07a4d9c commit ee72777

File tree

6 files changed

+85
-48
lines changed

6 files changed

+85
-48
lines changed

src/NBomber/Api/CSharp.fs

+33-23
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ type Scenario =
149149
/// Initializes scenario and all its dependencies.
150150
/// You can use it to prepare your target system, populate the database, or read and apply the JSON configuration for your scenario.
151151
/// Scenario init will be invoked before warm-up and bombing phases.
152-
/// If Scenario init throws an exception, the NBomber load test will stop the execution.
152+
/// If Scenario init throws an exception, the NBomber load test will stop the execution.
153153
/// </summary>
154154
/// <param name="scenario">Represent configuration data that is needed to build a scenario.</param>
155155
/// <param name="initFunc">Represent lambda function that will be invoked to start Scenario initialization.
@@ -162,7 +162,7 @@ type Scenario =
162162
/// Cleans scenario's resources and all its dependencies.
163163
/// This method should be used to clean the scenario's resources after the test finishes.
164164
/// Scenario clean will be invoked after warm-up and bombing phases.
165-
/// If Scenario clean throws an exception, the NBomber logs it and continues execution.
165+
/// If Scenario clean throws an exception, the NBomber logs it and continues execution.
166166
/// </summary>
167167
/// <param name="scenario">Represent configuration data that is needed to build a scenario.</param>
168168
/// <param name="cleanFunc">Represent lambda function that will be invoked to start Scenario cleaning.
@@ -172,7 +172,7 @@ type Scenario =
172172
{ scenario with Clean = Some cleanFunc.Invoke }
173173

174174
/// <summary>
175-
/// This method sets duration of warm-up phase.
175+
/// This method sets duration of warm-up phase.
176176
/// </summary>
177177
/// <param name="scenario">Represent configuration data that is needed to build a scenario.</param>
178178
/// <param name="duration">By default warm-up duration is 30 seconds.</param>
@@ -195,7 +195,7 @@ type Scenario =
195195
/// <param name="scenario">Represent configuration data that is needed to build a scenario.</param>
196196
/// <param name="loadSimulations">Default value is: Simulation.KeepConstant(copies: 1, during: TimeSpan.FromMinutes(1))</param>
197197
/// <example>
198-
/// <code>
198+
/// <code>
199199
/// scenario.WithLoadSimulations(
200200
/// Simulation.RampingConstant(copies: 50, during: TimeSpan.FromMinutes(1)) // ramp-up from 0 to 50 copies
201201
/// Simulation.KeepConstant(copies: 50, during: TimeSpan.FromMinutes(1))
@@ -212,7 +212,7 @@ type Scenario =
212212
/// For such cases, you can disable Scenario iteration auto restart.
213213
/// By default, when a Step returns a failed Response or unhandled exception was thrown,
214214
/// NBomber will automatically mark the whole iteration as failed and restart it.
215-
/// If you want to disable auto restart of Scenario iteration you should set 'shouldRestart: false'.
215+
/// If you want to disable auto restart of Scenario iteration you should set 'shouldRestart: false'.
216216
/// </summary>
217217
/// <param name="scenario">Represent configuration data that is needed to build a scenario.</param>
218218
/// <param name="shouldRestart">The default value is true.
@@ -223,10 +223,10 @@ type Scenario =
223223

224224
/// <summary>
225225
/// This method overrides the default value of MaxFailCount for Scenario.
226-
/// MaxFailCount is incremented on every failure or failed Response.
226+
/// MaxFailCount is incremented on every failure or failed Response.
227227
/// When a scenario reaches MaxFailCount, NBomber will stop the whole load test.
228228
/// In the case of cluster mode, MaxFailCount is tracked per each NBomber instance exclusively.
229-
/// It doesn't aggregate across the cluster. So if on any NBomber node MaxFailCount is reached, NBomber will stop the whole load test.
229+
/// It doesn't aggregate across the cluster. So if on any NBomber node MaxFailCount is reached, NBomber will stop the whole load test.
230230
/// </summary>
231231
/// <param name="scenario">Represent configuration data that is needed to build a scenario.</param>
232232
/// <param name="maxFailCount">The default value is 5_000.</param>
@@ -239,7 +239,7 @@ type Scenario =
239239
[<Extension>]
240240
type NBomberRunner =
241241

242-
/// Registers scenarios in NBomber environment.
242+
/// Registers scenarios in NBomber environment.
243243
static member RegisterScenarios([<ParamArray>]scenarios: ScenarioProps[]) =
244244
scenarios |> Seq.toList |> FSharp.NBomberRunner.registerScenarios
245245

@@ -261,7 +261,7 @@ type NBomberRunner =
261261
context |> FSharp.NBomberRunner.withTargetScenarios(names)
262262

263263
/// <summary>
264-
/// Sets test suite name.
264+
/// Sets test suite name.
265265
/// </summary>
266266
/// <param name="context">NBomberContext</param>
267267
/// <param name="testSuite">Default value is: "nbomber_default_test_suite_name".</param>
@@ -270,7 +270,7 @@ type NBomberRunner =
270270
context |> FSharp.NBomberRunner.withTestSuite(testSuite)
271271

272272
/// <summary>
273-
/// Sets test name.
273+
/// Sets test name.
274274
/// </summary>
275275
/// <param name="context">NBomberContext</param>
276276
/// <param name="testName">Default value is: "nbomber_default_test_name".</param>
@@ -279,7 +279,7 @@ type NBomberRunner =
279279
context |> FSharp.NBomberRunner.withTestName(testName)
280280

281281
/// <summary>
282-
/// Sets output report file name.
282+
/// Sets output report file name.
283283
/// </summary>
284284
/// <param name="context">NBomberContext</param>
285285
/// <param name="reportFileName">Default name: "nbomber_report-{CurrentTime}"</param>
@@ -288,7 +288,7 @@ type NBomberRunner =
288288
context |> FSharp.NBomberRunner.withReportFileName(reportFileName)
289289

290290
/// <summary>
291-
/// Sets output report folder path.
291+
/// Sets output report folder path.
292292
/// </summary>
293293
/// <param name="context">NBomberContext</param>
294294
/// <param name="reportFolderPath">Default folder path: "./reports".</param>
@@ -312,15 +312,15 @@ type NBomberRunner =
312312
context |> FSharp.NBomberRunner.withoutReports
313313

314314
/// <summary>
315-
/// Sets real-time reporting interval.
315+
/// Sets real-time reporting interval.
316316
/// </summary>
317317
/// <param name="context">NBomberContext</param>
318318
/// <param name="interval">Default value: 10 sec, min value: 5 sec</param>
319319
[<Extension>]
320320
static member WithReportingInterval(context: NBomberContext, interval: TimeSpan) =
321321
context |> FSharp.NBomberRunner.withReportingInterval interval
322322

323-
/// Sets reporting sinks.
323+
/// Sets reporting sinks.
324324
/// ReportingSink provides functionality for saving real-time and final statistics.
325325
[<Extension>]
326326
static member WithReportingSinks(context: NBomberContext, [<ParamArray>]reportingSinks: IReportingSink[]) =
@@ -352,16 +352,16 @@ type NBomberRunner =
352352
context |> FSharp.NBomberRunner.loadConfig(path)
353353

354354
/// <summary>
355-
/// Loads infrastructure configuration by file path or by HTTP URL.
356-
/// </summary>
355+
/// Loads infrastructure configuration by file path or by HTTP URL.
356+
/// </summary>
357357
/// <param name="context"></param>
358358
/// <param name="path">File path or HTTP URL to JSON config.</param>
359359
/// <example>
360360
/// <code>
361361
/// // load by file path
362362
/// NBomberRunner.LoadInfraConfig("./my-test/infra-config.json")
363363
/// // load by URL
364-
/// NBomberRunner.LoadInfraConfig("https://my-test/infra-config.json")
364+
/// NBomberRunner.LoadInfraConfig("https://my-test/infra-config.json")
365365
/// </code>
366366
/// </example>
367367
[<Extension>]
@@ -376,7 +376,7 @@ type NBomberRunner =
376376
[<Extension>]
377377
static member WithMinimumLogLevel(context: NBomberContext, level: LogEventLevel) =
378378
context |> FSharp.NBomberRunner.withMinimumLogLevel level
379-
379+
380380
/// <summary>
381381
/// Sets logger configuration.
382382
/// Make sure that you always return a new instance of LoggerConfiguration.
@@ -396,14 +396,24 @@ type NBomberRunner =
396396

397397
/// <summary>
398398
/// This method enables or disables hints analyzer.
399-
/// Hints analyzer - analyzes statistics at the end of the test to provide hints in case of finding the wrong usage of NBomber or some environmental issues.
400-
/// </summary>
399+
/// Hints analyzer - analyzes statistics at the end of the test to provide hints in case of finding the wrong usage of NBomber or some environmental issues.
400+
/// </summary>
401401
/// <param name="context">NBomberContext</param>
402402
/// <param name="enable">The default value is false.</param>
403403
[<Extension>]
404404
static member EnableHintsAnalyzer(context: NBomberContext, enable: bool) =
405405
context |> FSharp.NBomberRunner.enableHintsAnalyzer enable
406406

407+
/// <summary>
408+
/// This method enables or disables to forcibly halt all tests at the end of the simulation even though NBomber is overloaded.
409+
/// Use when you need to stop your test at a precise time even if your NBomber is overloaded and can have a short lag.
410+
/// </summary>
411+
/// <param name="context">NBomberContext</param>
412+
/// <param name="enable">The default value is false.</param>
413+
[<Extension>]
414+
static member EnableStopTestForcibly(context: NBomberContext, enable: bool) =
415+
context |> FSharp.NBomberRunner.enableStopTestForcibly enable
416+
407417
/// Runs scenarios.
408418
[<Extension>]
409419
static member Run(context: NBomberContext) =
@@ -412,7 +422,7 @@ type NBomberRunner =
412422
| Error msg -> failwith msg
413423

414424
/// <summary>
415-
/// Runs scenarios with CLI arguments.
425+
/// Runs scenarios with CLI arguments.
416426
/// </summary>
417427
/// <param name="context">NBomberContext</param>
418428
/// <param name="args">CLI args</param>
@@ -433,7 +443,7 @@ type NBomberRunner =
433443
type Simulation =
434444

435445
/// <summary>
436-
/// Adds or removes a given number of Scenario copies(instances) with a linear ramp over a given duration.
446+
/// Adds or removes a given number of Scenario copies(instances) with a linear ramp over a given duration.
437447
/// Each Scenario copy behaves like a long-running thread that runs continually(by specified duration) and will be destroyed when the current load simulation stops.
438448
/// Use it for a smooth ramp up and ramp down.
439449
/// Usually, this simulation type is used to test databases, message brokers, or any other system that works with a static client's pool of connections and reuses them.
@@ -476,7 +486,7 @@ type Simulation =
476486
/// </summary>
477487
/// <param name="rate">The injection rate of Scenario copies. It configures how many concurrent copies will be injected at a time.</param>
478488
/// <param name="interval">The injection interval. It configures the interval between injections. </param>
479-
/// <param name="during">The duration of load simulation.</param>
489+
/// <param name="during">The duration of load simulation.</param>
480490
static member Inject(rate: int, interval: TimeSpan, during: TimeSpan) =
481491
LoadSimulation.Inject(rate, interval, during)
482492

0 commit comments

Comments
 (0)