test(build): gate the maxConcurrent-1 test instead of racing a sleep
The build of branch-a slept one second while the test asserted, without any synchronization, that branch-b was still PENDING. Under CPU contention on the mih09 host the sleep could elapse first, so branch-b was already RUNNING or SUCCESS when the assertion ran. branch-a now blocks until the test creates a gate file, and the test first waits for branch-a to be RUNNING; the PENDING assertion no longer depends on timing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
3b095fd04a
commit
9221550a2a
@@ -505,6 +505,8 @@ class BuildExecutorTest : FunSpec() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("with maxConcurrent 1 a second branch stays PENDING until the first finished") {
|
test("with maxConcurrent 1 a second branch stays PENDING until the first finished") {
|
||||||
|
// branch-a blocks on a gate file the test creates, so the PENDING assertion
|
||||||
|
// below cannot race the first build finishing on a loaded machine
|
||||||
val h =
|
val h =
|
||||||
Harness(
|
Harness(
|
||||||
"""
|
"""
|
||||||
@@ -512,7 +514,7 @@ class BuildExecutorTest : FunSpec() {
|
|||||||
maxConcurrent: 1
|
maxConcurrent: 1
|
||||||
branches:
|
branches:
|
||||||
branch-a:
|
branch-a:
|
||||||
buildCommand: "sleep 1"
|
buildCommand: "until [ -f gate ]; do sleep 0.05; done"
|
||||||
cleanCommand: ""
|
cleanCommand: ""
|
||||||
branch-b:
|
branch-b:
|
||||||
buildCommand: "echo ok"
|
buildCommand: "echo ok"
|
||||||
@@ -523,8 +525,13 @@ class BuildExecutorTest : FunSpec() {
|
|||||||
h.executor.startBuild(h.repo, "branch-a", "sha-a")
|
h.executor.startBuild(h.repo, "branch-a", "sha-a")
|
||||||
h.executor.startBuild(h.repo, "branch-b", "sha-b")
|
h.executor.startBuild(h.repo, "branch-b", "sha-b")
|
||||||
|
|
||||||
|
eventually(30.seconds) {
|
||||||
|
h.repository.latestFor("branch-a")?.status shouldBe BuildStatus.RUNNING
|
||||||
|
}
|
||||||
h.repository.latestFor("branch-b")?.status shouldBe BuildStatus.PENDING
|
h.repository.latestFor("branch-b")?.status shouldBe BuildStatus.PENDING
|
||||||
|
|
||||||
|
Files.createFile(h.workingDir.resolve("gate"))
|
||||||
|
|
||||||
awaitStatus(h, "branch-b", BuildStatus.SUCCESS)
|
awaitStatus(h, "branch-b", BuildStatus.SUCCESS)
|
||||||
awaitStatus(h, "branch-a", BuildStatus.SUCCESS)
|
awaitStatus(h, "branch-a", BuildStatus.SUCCESS)
|
||||||
val transitions = h.events.map { it.result.branch to it.result.status }
|
val transitions = h.events.map { it.result.branch to it.result.status }
|
||||||
|
|||||||
Reference in New Issue
Block a user