Skip to content

Commit f384235

Browse files
authored
Make testRetriesEventuallySucceed more reliable (#1779)
Motivation: `testRetriesEventuallySucceed` fails infrequently. When attempting a retry, the executor checks whether it's safe for the broadcast sequence to be replayed, it does so after removing all subscribers. However, there is a timing window between invalidating subscribers and checking whether it's safe in which a subscribtion can be registered. For retries, this can happen if the server responds before the client has subscribed. In practice this is very unlikely to happen because of network latency. Modifications: Have the server in the test consume the inbound stream before failing, this ensures the subscribtion is created by the time the client realises the call has failed. Result: Test passes more reliably
1 parent 7bb2506 commit f384235

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Tests/GRPCCoreTests/Call/Client/Internal/ClientRPCExecutorTests+Retries.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ extension ClientRPCExecutorTests {
3838
}
3939

4040
func testRetriesEventuallySucceed() async throws {
41-
let harness = self.makeHarnessForRetries(rejectUntilAttempt: 3, withCode: .unavailable)
41+
let harness = self.makeHarnessForRetries(
42+
rejectUntilAttempt: 3,
43+
withCode: .unavailable,
44+
consumeInboundStream: true
45+
)
4246
try await harness.bidirectional(
4347
request: ClientRequest.Stream(metadata: ["foo": "bar"]) {
4448
try await $0.write([0])

0 commit comments

Comments
 (0)