parveensania commented on code in PR #39646:
URL: https://github.com/apache/beam/pull/39646#discussion_r3797664473
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/windmill/client/grpc/stubs/FailoverChannelTest.java:
##########
@@ -290,6 +291,91 @@ public void testStateFallbackAfterPrimaryNotReady() {
verify(mockFallbackChannel).newCall(any(), any());
}
+ @Test
+ public void testTimeoutThresholdDecreaseTriggersFallbackEarlier() {
+ ManagedChannel mockChannel = mock(ManagedChannel.class);
+ ManagedChannel mockFallbackChannel = mock(ManagedChannel.class);
+ when(mockChannel.newCall(any(), any())).thenReturn(mock(ClientCall.class));
+ when(mockFallbackChannel.newCall(any(),
any())).thenReturn(mock(ClientCall.class));
+ // Simulate primary being TRANSIENT_FAILURE from the start.
+
when(mockChannel.getState(false)).thenReturn(ConnectivityState.TRANSIENT_FAILURE);
+
+ AtomicLong time = new AtomicLong(0);
+ // Start with 10s timeout
+ AtomicLong timeoutThreshold = new AtomicLong(TimeUnit.SECONDS.toNanos(10));
+
+ // Constructor seeds timer at time=0.
+ FailoverChannel failoverChannel =
+ FailoverChannel.forTest(
+ mockChannel, mockFallbackChannel, null, time::get, 0L,
timeoutThreshold::get);
+
+ // Call at time=0. elapsed 0 <= 10s -> false.
+ failoverChannel.newCall(methodDescriptor, CallOptions.DEFAULT);
+ verify(mockChannel).newCall(any(), any());
Review Comment:
Done. Updated the tests.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]