Skip to content

Commit 14b6b47

Browse files
committed
fixed tests
1 parent d512852 commit 14b6b47

File tree

7 files changed

+10
-141
lines changed

7 files changed

+10
-141
lines changed

tests/NBomber.IntegrationTests/HintsAnalyzerTests.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ let ``HintsAnalyzer should be disabled by default`` () =
9292
return Response.ok()
9393
})
9494
|> Scenario.withLoadSimulations [LoadSimulation.KeepConstant(1, seconds 1)]
95+
|> Scenario.withoutWarmUp
9596
|> NBomberRunner.registerScenario
9697
|> NBomberRunner.runWithResult Seq.empty
9798
|> Result.getOk
@@ -106,6 +107,7 @@ let ``disableHintsAnalyzer should disable hints`` () =
106107
return Response.ok()
107108
})
108109
|> Scenario.withLoadSimulations [LoadSimulation.KeepConstant(1, seconds 1)]
110+
|> Scenario.withoutWarmUp
109111
|> NBomberRunner.registerScenario
110112
|> NBomberRunner.enableHintsAnalyzer false
111113
|> NBomberRunner.runWithResult Seq.empty

tests/NBomber.IntegrationTests/LoggingTests.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ let ``set min logger level should work correctly`` () =
3535
return Response.ok()
3636
})
3737
|> Scenario.withLoadSimulations [KeepConstant(1, TimeSpan.FromSeconds 3.0)]
38+
|> Scenario.withoutWarmUp
3839
|> NBomberRunner.registerScenario
3940
|> NBomberRunner.withLoggerConfig createLoggerConfig1
4041
|> NBomberRunner.run
@@ -46,6 +47,7 @@ let ``set min logger level should work correctly`` () =
4647
return Response.ok()
4748
})
4849
|> Scenario.withLoadSimulations [KeepConstant(1, TimeSpan.FromSeconds 3.0)]
50+
|> Scenario.withoutWarmUp
4951
|> NBomberRunner.registerScenario
5052
|> NBomberRunner.withLoggerConfig createLoggerConfig2
5153
|> NBomberRunner.run

tests/NBomber.IntegrationTests/NBomberRunnerTests.fs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ let ``withTargetScenarios should run only specified scenarios`` () =
2323
})
2424
|> Scenario.withInit(fun _ -> task { scn1Started <- true })
2525
|> Scenario.withLoadSimulations [KeepConstant(1, seconds 1)]
26+
|> Scenario.withoutWarmUp
2627

2728
let scn2 =
2829
Scenario.create("scn_2", fun ctx -> task {
@@ -31,6 +32,7 @@ let ``withTargetScenarios should run only specified scenarios`` () =
3132
})
3233
|> Scenario.withInit(fun _ -> task { scn2Started <- true })
3334
|> Scenario.withLoadSimulations [KeepConstant(1, seconds 1)]
35+
|> Scenario.withoutWarmUp
3436

3537
NBomberRunner.registerScenarios [scn1; scn2]
3638
|> NBomberRunner.withTargetScenarios ["scn_2"]
@@ -39,32 +41,3 @@ let ``withTargetScenarios should run only specified scenarios`` () =
3941

4042
test <@ scn1Started = false @>
4143
test <@ scn2Started @>
42-
43-
// [<Fact>]
44-
// let ``withDefaultStepTimeout should overrides default step timeout`` () =
45-
//
46-
// Scenario.create("timeout tests", fun ctx -> task {
47-
//
48-
// let! st = Step.run("step 1", ctx, fun () -> task {
49-
// do! Task.Delay(milliseconds 100)
50-
// return Response.ok()
51-
// })
52-
//
53-
// let! st = Step.run("step 2", ctx, fun () -> task {
54-
// do! Task.Delay(milliseconds 600)
55-
// return Response.ok()
56-
// })
57-
//
58-
// return Response.ok()
59-
// })
60-
// |> Scenario.withoutWarmUp
61-
// |> Scenario.withLoadSimulations [KeepConstant(copies = 1, during = seconds 5)]
62-
// |> NBomberRunner.registerScenario
63-
// |> NBomberRunner.withoutReports
64-
// |> NBomberRunner.withDefaultStepTimeout(milliseconds 500)
65-
// |> NBomberRunner.run
66-
// |> Result.getOk
67-
// |> fun stats ->
68-
// test <@ stats.ScenarioStats[0].GetStepStats("step 1").Fail.Request.Count = 0 @>
69-
// test <@ stats.ScenarioStats[0].GetStepStats("step 2").Fail.Request.Count > 0 @>
70-
// test <@ stats.ScenarioStats[0].GetStepStats("step 2").Fail.StatusCodes[0].StatusCode = Constants.TimeoutStatusCode @>

tests/NBomber.IntegrationTests/Plugins/PluginTests.fs

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -62,37 +62,7 @@ let ``WorkerPlugin Init, Start, Stop should be invoked once for Warmup and once
6262
test <@ List.rev invocationOrder = ["init"; "start"; "stop"; "start"; "stop"; "get_stats"; "get_hints"; "dispose"] @>
6363

6464
[<Fact>]
65-
let ``StartTest should be invoked once`` () =
66-
67-
let scenarios = PluginTestHelper.createScenarios()
68-
let mutable pluginStartTestInvokedCounter = 0
69-
70-
let plugin = {
71-
new IWorkerPlugin with
72-
member _.PluginName = "TestPlugin"
73-
member _.Init(_, _) = Task.CompletedTask
74-
75-
member _.Start() =
76-
pluginStartTestInvokedCounter <- pluginStartTestInvokedCounter + 1
77-
Task.CompletedTask
78-
79-
member _.GetHints() = Array.empty
80-
member _.GetStats(_) = Task.FromResult(new DataSet())
81-
member _.Stop() = Task.CompletedTask
82-
member _.Dispose() = ()
83-
}
84-
85-
NBomberRunner.registerScenarios scenarios
86-
|> NBomberRunner.withWorkerPlugins [plugin]
87-
|> NBomberRunner.run
88-
|> Result.mapError(fun x -> failwith x)
89-
|> ignore
90-
91-
test <@ pluginStartTestInvokedCounter = 1 @>
92-
93-
94-
[<Fact>]
95-
let ``StartTest should be invoked with infra config`` () =
65+
let ``Init should be invoked with infra config`` () =
9666

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

12494
test <@ isNull serilogConfig = false @>
12595

126-
[<Fact>]
127-
let ``GetStats should be invoked only one time when final stats fetching`` () =
128-
129-
let scenarios = PluginTestHelper.createScenarios()
130-
let mutable pluginGetStatsInvokedCounter = 0
131-
132-
let plugin = {
133-
new IWorkerPlugin with
134-
member _.PluginName = "TestPlugin"
135-
member _.Init(_, _) = Task.CompletedTask
136-
member _.Start() = Task.CompletedTask
137-
138-
member _.GetStats(stats) =
139-
pluginGetStatsInvokedCounter <- pluginGetStatsInvokedCounter + 1
140-
Task.FromResult(new DataSet())
141-
142-
member _.GetHints() = Array.empty
143-
member _.Stop() = Task.CompletedTask
144-
member _.Dispose() = ()
145-
}
146-
147-
NBomberRunner.registerScenarios scenarios
148-
|> NBomberRunner.withWorkerPlugins [plugin]
149-
|> NBomberRunner.run
150-
|> Result.mapError(fun x -> failwith x)
151-
|> ignore
152-
153-
test <@ pluginGetStatsInvokedCounter = 1 @>
154-
155-
[<Fact>]
156-
let ``StopTest should be invoked once`` () =
157-
158-
let scenarios = PluginTestHelper.createScenarios()
159-
let mutable pluginFinishTestInvokedCounter = 0
160-
161-
let plugin = {
162-
new IWorkerPlugin with
163-
member _.PluginName = "TestPlugin"
164-
member _.Init(_, _) = Task.CompletedTask
165-
member _.Start() = Task.CompletedTask
166-
member _.GetStats(_) = Task.FromResult(new DataSet())
167-
member _.GetHints() = Array.empty
168-
member _.Stop() =
169-
pluginFinishTestInvokedCounter <- pluginFinishTestInvokedCounter + 1
170-
Task.CompletedTask
171-
member _.Dispose() = ()
172-
}
173-
174-
NBomberRunner.registerScenarios scenarios
175-
|> NBomberRunner.withWorkerPlugins [plugin]
176-
|> NBomberRunner.run
177-
|> Result.mapError(fun x -> failwith x)
178-
|> ignore
179-
180-
test <@ pluginFinishTestInvokedCounter = 1 @>
181-
18296
[<Fact>]
18397
let ``PluginStats should return empty data set in case of execution timeout`` () =
18498
let inMemorySink = new InMemorySink()

tests/NBomber.IntegrationTests/Reporting/ReportingSinkTests.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,6 @@ let ``ReportingSink Init, Start, Stop should be invoked once for Warmup and once
324324
|> Result.mapError failwith
325325
|> ignore
326326

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

tests/NBomber.IntegrationTests/ScenarioTests/ValidationTests.fs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let ``applyScenariosSettings() should override initial settings if the scenario
1818
let duration1 = seconds 50
1919

2020
let scnName2 = "scenario_1"
21-
let duration2 = seconds 5
21+
let duration2 = seconds 80
2222

2323
let settings = {
2424
ScenarioName = scnName1
@@ -106,26 +106,3 @@ let ``ScenarioSettings should be validated on duplicates `` () =
106106
|> NBomberRunner.run
107107
|> Result.getError
108108
|> fun error -> test <@ error.Contains("Scenario names are not unique in JSON config") @>
109-
110-
// [<Fact>]
111-
// let ``withStepTimeout should set step timeout`` () =
112-
//
113-
// let step1 = Step.create("step_1", timeout = seconds 2, execute = fun context -> task {
114-
// do! Task.Delay(seconds 4)
115-
// return Response.ok()
116-
// })
117-
//
118-
// Scenario.create "1" [step1]
119-
// |> Scenario.withoutWarmUp
120-
// |> Scenario.withLoadSimulations [KeepConstant(1, seconds 10)]
121-
// |> NBomberRunner.registerScenario
122-
// |> NBomberRunner.withoutReports
123-
// |> NBomberRunner.run
124-
// |> Result.getOk
125-
// |> NodeStats.getScenarioStats "1"
126-
// |> ScenarioStats.getStepStats "step_1"
127-
// |> fun stepsStats ->
128-
// test <@ stepsStats.Ok.Request.Count = 0 @>
129-
// test <@ stepsStats.Fail.Request.Count > 0 @>
130-
// test <@ stepsStats.Fail.StatusCodes[0].StatusCode = NBomber.Constants.TimeoutStatusCode @>
131-
// test <@ stepsStats.Fail.StatusCodes[0].Count = stepsStats.Fail.Request.Count @>

tests/NBomber.IntegrationTests/ScenarioTests/WarmUpTests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ let ``Warmup should have no effect on stats`` () =
3232

3333
return Response.ok()
3434
})
35-
|> Scenario.withWarmUpDuration(seconds 3)
35+
|> Scenario.withWarmUpDuration(seconds 1)
3636
|> Scenario.withLoadSimulations [KeepConstant(copies = 1, during = seconds 1)]
3737
|> NBomberRunner.registerScenario
3838
|> NBomberRunner.withoutReports

0 commit comments

Comments
 (0)