Skip to content

Commit

Permalink
Fix flaky test testTasksScheduledDuringShutdownAreAutomaticallyCancel… (
Browse files Browse the repository at this point in the history
#3036)

…ledOrNotScheduledAnymore

# Motivation

This task was flaky and hit the assertion with the count being 1

# Modification

This changes the expectation to greater than 0 since we can always
guarantee that one scheduled task is run but due to timing windows it
might be that we shutdown the EL before the second task is enqueued
which meant it was immediately failed.

# Result

One less flaky test
  • Loading branch information
FranzBusch authored Dec 19, 2024
1 parent 7dea8e7 commit 56f9b7c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
}
}

func testTasksScheduledDuringShutdownAreAutomaticallyCancelled() async throws {
func testTasksScheduledDuringShutdownAreAutomaticallyCancelledOrNotScheduled() async throws {
let eventLoop = NIOAsyncTestingEventLoop()
let tasksRun = ManagedAtomic(0)

Expand Down Expand Up @@ -511,7 +511,7 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase {
}

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

Expand Down

0 comments on commit 56f9b7c

Please sign in to comment.