Skip to content

Commit

Permalink
Speculative fix for flakey AsyncTestingEventLoop test (#2873)
Browse files Browse the repository at this point in the history
### Motivation:

We're seeing some very rare failures from this test in CI runs but I
cannot reproduce locally. The test relies on timing to some degree and
the interaction of scheduling tasks at shutdown.

### Modifications:

The `AsyncTestingEventLoop` has an `executeInContext` function which
puts the closure on the backing dispatch queue and blocks. In this
instance it might be a good way to make sure that all the previous work
has happened.

### Result:

(Hopefully) less flakey test.
  • Loading branch information
simonjbeaumont authored Sep 9, 2024
1 parent d2713ab commit a26c6dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
try await group.waitForAll()
}

XCTAssertGreaterThan(tasksRun.load(ordering: .acquiring), 1)
try await eventLoop.executeInContext {
XCTAssertGreaterThan(tasksRun.load(ordering: .acquiring), 1)
}
}

func testShutdownCancelsRemainingScheduledTasks() async {
Expand Down

0 comments on commit a26c6dc

Please sign in to comment.