Skip to content

Commit b724bfa

Browse files
test: deflake goaway test to account for last vRpc being rejected (#2870)
Change-Id: Ife308c3cd8dd693909cdd9af4f02a9ec63c16071 Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Rollback plan is reviewed and LGTMed - [ ] All new data plane features have a completed end to end testing plan Fixes #<issue_number_goes_here> ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
1 parent 6e17eeb commit b724bfa

1 file changed

Lines changed: 18 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: 18 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,23 @@ 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("Ensure that some vRpcs succeeded prior to the goaway")
226+
.that(numOk)
227+
.isGreaterThan(0);
228+
assertWithMessage("Ensure that only the last vRpc could be rejected with an uncommited error")
229+
.that(numUncommittedErrors)
230+
.isAtMost(1);
231+
215232
assertThat(sessionListener.popUntil(GoAwayResponse.class)).isInstanceOf(GoAwayResponse.class);
216233

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

0 commit comments

Comments
 (0)