Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 93ff90a

Browse files
test: deflake goaway test to account for last vRpc being rejected
Change-Id: Ife308c3cd8dd693909cdd9af4f02a9ec63c16071
1 parent d5565b5 commit 93ff90a

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

  • google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/session

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/session/SessionImplTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.cloud.bigtable.data.v2.internal.test_helpers.StatusSubject.assertThat;
2020
import static com.google.cloud.bigtable.data.v2.internal.test_helpers.VRpcResultSubject.assertThat;
2121
import static com.google.common.truth.Truth.assertThat;
22+
import static com.google.common.truth.Truth.assertWithMessage;
2223
import static org.junit.jupiter.api.Assertions.assertThrows;
2324

2425
import com.google.bigtable.v2.CloseSessionRequest;
@@ -201,6 +202,8 @@ void sessionGoAwayTest() throws Exception {
201202

202203
// Send vRPCs until after a goaway time
203204
Stopwatch stopwatch = Stopwatch.createStarted();
205+
int numUncommittedErrors = 0;
206+
int numOk = 0;
204207
while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < goAwayDelay.toMillis()) {
205208
VRpc<SessionFakeScriptedRequest, SessionFakeScriptedResponse> rpc =
206209
session.newCall(FakeDescriptor.SCRIPTED);
@@ -209,9 +212,24 @@ void sessionGoAwayTest() throws Exception {
209212
SessionFakeScriptedRequest.newBuilder().setTag(0).build(),
210213
VRpcCallContext.create(Deadline.after(1, TimeUnit.MINUTES), true, tracer),
211214
f);
212-
f.get();
215+
try {
216+
f.get();
217+
numOk++;
218+
} catch (VRpcException e) {
219+
if (e.getResult().getState() == State.UNCOMMITED) {
220+
numUncommittedErrors++;
221+
}
222+
}
213223
}
214224

225+
assertWithMessage("Sanity check that some vRpcs succeeded prior to the goaway")
226+
.that(numOk)
227+
.isGreaterThan(0);
228+
assertWithMessage(
229+
"Sanity check possibly only the last vRpc was rejected with an uncommited error")
230+
.that(numUncommittedErrors)
231+
.isAtMost(1);
232+
215233
assertThat(sessionListener.popUntil(GoAwayResponse.class)).isInstanceOf(GoAwayResponse.class);
216234

217235
// Make sure we can't send vrpc after receiving goaway

0 commit comments

Comments
 (0)