From c9cf66bcd8308b0012c02fa1d7abd07e583183e4 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Fri, 15 Dec 2023 14:53:37 -0500 Subject: [PATCH] test: increasing timeout in testServerStreamingStart (#2308) Fixes https://github.com/googleapis/sdk-platform-java/issues/1678 The assertion error tells `latch.await(2, TimeUnit.SECONDS)` did not return true. https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#await-long-java.util.concurrent.TimeUnit- > Returns: > true if the count reached zero and false if the waiting time elapsed before the count reached zero Under a multithreading test, there's no guarantee that `latch.await(2, TimeUnit.SECONDS)` finishes within 2 second. Increasing the value to 60 second to (drastically) reduce the flakiness. --- .../httpjson/HttpJsonDirectServerStreamingCallableTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java index 3b5312e01b..82c8e3e0c2 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java @@ -200,9 +200,9 @@ public void testServerStreamingStart() throws InterruptedException { Truth.assertThat(moneyObserver.controller).isNotNull(); // wait for the task to complete, otherwise it may interfere with other tests, since they share - // the same MockService and unfinished request in this tes may start readind messages designated - // for other tests. - Truth.assertThat(latch.await(2, TimeUnit.SECONDS)).isTrue(); + // the same MockService and unfinished request in this test may start reading messages + // designated for other tests. + Truth.assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue(); } @Test