Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AntyaDev committed Jan 12, 2023
1 parent d512852 commit b6fd14d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 88 deletions.
88 changes: 1 addition & 87 deletions tests/NBomber.IntegrationTests/Plugins/PluginTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,7 @@ let ``WorkerPlugin Init, Start, Stop should be invoked once for Warmup and once
test <@ List.rev invocationOrder = ["init"; "start"; "stop"; "start"; "stop"; "get_stats"; "get_hints"; "dispose"] @>

[<Fact>]
let ``StartTest should be invoked once`` () =

let scenarios = PluginTestHelper.createScenarios()
let mutable pluginStartTestInvokedCounter = 0

let plugin = {
new IWorkerPlugin with
member _.PluginName = "TestPlugin"
member _.Init(_, _) = Task.CompletedTask

member _.Start() =
pluginStartTestInvokedCounter <- pluginStartTestInvokedCounter + 1
Task.CompletedTask

member _.GetHints() = Array.empty
member _.GetStats(_) = Task.FromResult(new DataSet())
member _.Stop() = Task.CompletedTask
member _.Dispose() = ()
}

NBomberRunner.registerScenarios scenarios
|> NBomberRunner.withWorkerPlugins [plugin]
|> NBomberRunner.run
|> Result.mapError(fun x -> failwith x)
|> ignore

test <@ pluginStartTestInvokedCounter = 1 @>


[<Fact>]
let ``StartTest should be invoked with infra config`` () =
let ``Init should be invoked with infra config`` () =

let scenarios = PluginTestHelper.createScenarios()
let mutable pluginConfig = Unchecked.defaultof<_>
Expand Down Expand Up @@ -123,62 +93,6 @@ let ``StartTest should be invoked with infra config`` () =

test <@ isNull serilogConfig = false @>

[<Fact>]
let ``GetStats should be invoked only one time when final stats fetching`` () =

let scenarios = PluginTestHelper.createScenarios()
let mutable pluginGetStatsInvokedCounter = 0

let plugin = {
new IWorkerPlugin with
member _.PluginName = "TestPlugin"
member _.Init(_, _) = Task.CompletedTask
member _.Start() = Task.CompletedTask

member _.GetStats(stats) =
pluginGetStatsInvokedCounter <- pluginGetStatsInvokedCounter + 1
Task.FromResult(new DataSet())

member _.GetHints() = Array.empty
member _.Stop() = Task.CompletedTask
member _.Dispose() = ()
}

NBomberRunner.registerScenarios scenarios
|> NBomberRunner.withWorkerPlugins [plugin]
|> NBomberRunner.run
|> Result.mapError(fun x -> failwith x)
|> ignore

test <@ pluginGetStatsInvokedCounter = 1 @>

[<Fact>]
let ``StopTest should be invoked once`` () =

let scenarios = PluginTestHelper.createScenarios()
let mutable pluginFinishTestInvokedCounter = 0

let plugin = {
new IWorkerPlugin with
member _.PluginName = "TestPlugin"
member _.Init(_, _) = Task.CompletedTask
member _.Start() = Task.CompletedTask
member _.GetStats(_) = Task.FromResult(new DataSet())
member _.GetHints() = Array.empty
member _.Stop() =
pluginFinishTestInvokedCounter <- pluginFinishTestInvokedCounter + 1
Task.CompletedTask
member _.Dispose() = ()
}

NBomberRunner.registerScenarios scenarios
|> NBomberRunner.withWorkerPlugins [plugin]
|> NBomberRunner.run
|> Result.mapError(fun x -> failwith x)
|> ignore

test <@ pluginFinishTestInvokedCounter = 1 @>

[<Fact>]
let ``PluginStats should return empty data set in case of execution timeout`` () =
let inMemorySink = new InMemorySink()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,5 +324,6 @@ let ``ReportingSink Init, Start, Stop should be invoked once for Warmup and once
|> Result.mapError failwith
|> ignore

test <@ saveRealtimeStatsCounter > 0 @>
test <@ List.rev invocationOrder = ["init"; "start"; "stop"; "start"; "stop"; "save_final_stats"; "dispose"] @>

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let ``Warmup should have no effect on stats`` () =

return Response.ok()
})
|> Scenario.withWarmUpDuration(seconds 3)
|> Scenario.withWarmUpDuration(seconds 1)
|> Scenario.withLoadSimulations [KeepConstant(copies = 1, during = seconds 1)]
|> NBomberRunner.registerScenario
|> NBomberRunner.withoutReports
Expand Down

0 comments on commit b6fd14d

Please sign in to comment.