You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/24 14:55:59 UTC

[GitHub] [beam] nielm commented on a diff in pull request #22023: Fix SpannerIO flakes

nielm commented on code in PR #22023:
URL: https://github.com/apache/beam/pull/22023#discussion_r906145815


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIOWriteExceptionHandlingTest.java:
##########
@@ -171,9 +163,21 @@ public void testExceptionHandlingForSimpleWrite() throws InterruptedException {
     try {
       pipeline.run().waitUntilFinish();
     } finally {
-      verify(SpannerIO.WriteToSpannerFn.sleeper, times(callsToSleeper)).sleep(anyLong());
-      verify(serviceFactory.mockDatabaseClient(), times(callsToWrite))
-          .writeAtLeastOnceWithOptions(any(), any(Options.ReadQueryUpdateTransactionOption.class));
+      if (exceptionErrorcode == ErrorCode.DEADLINE_EXCEEDED) {
+        // Due to randomOffset retry is done by most likely but not always 9 times.
+        int sleepCalled =
+            Mockito.mockingDetails(SpannerIO.WriteToSpannerFn.sleeper).getInvocations().size();
+        assertTrue(sleepCalled >= 8);
+        assertTrue(sleepCalled <= 10);

Review Comment:
   That was more effort than I was prepared to do - I was just going to test that steeps >= 8 and  writes >= 9!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org