Skip to content

Commit ddeb0d2

Browse files
committed
improve unit test reliability
1 parent 97594b3 commit ddeb0d2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/test/kotlin/com/onepeloton/locust4k/examples/ExampleAppTest.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ExampleAppTest : TestcontainersBase() {
2929
// when
3030
LogMessageWaitStrategy()
3131
.withRegEx(".* Shutting down Locust Worker.*\\s")
32-
.withStartupTimeout(Duration.ofSeconds(5))
32+
.withStartupTimeout(Duration.ofSeconds(10))
3333
.waitUntilReady(locustWorkerExampleContainer)
3434

3535
val workerLogs = locustWorkerExampleContainer.logs
@@ -80,7 +80,7 @@ class ExampleAppTest : TestcontainersBase() {
8080
// when
8181
LogMessageWaitStrategy()
8282
.withRegEx(".* Shutting down Locust Worker.*\\s")
83-
.withStartupTimeout(Duration.ofSeconds(5))
83+
.withStartupTimeout(Duration.ofSeconds(10))
8484
.waitUntilReady(locustWorkerExampleContainer)
8585

8686
val workerLogs = locustWorkerExampleContainer.logs
@@ -128,16 +128,25 @@ class ExampleAppTest : TestcontainersBase() {
128128
.waitUntilReady(locustMasterContainer)
129129

130130
// when
131-
repeat(2) {
131+
val repeatTimes = 2
132+
for (i in 1..repeatTimes) {
132133
startLoadTest(locustMasterContainer)
133134

134135
LogMessageWaitStrategy()
136+
.withTimes(i)
135137
.withRegEx(".* Spawning Complete message from controller.*\\s")
136138
.withStartupTimeout(Duration.ofSeconds(5))
137139
.waitUntilReady(locustWorkerExampleContainer)
138140

139141
stopLoadTest(locustMasterContainer)
142+
143+
LogMessageWaitStrategy()
144+
.withTimes(i)
145+
.withRegEx(".* Ack message from controller.*\\s")
146+
.withStartupTimeout(Duration.ofSeconds(5))
147+
.waitUntilReady(locustWorkerExampleContainer)
140148
}
149+
141150
val workerLogs = locustWorkerExampleContainer.logs
142151

143152
// then

0 commit comments

Comments
 (0)