scwhittle commented on code in PR #39646:
URL: https://github.com/apache/beam/pull/39646#discussion_r3728059323
##########
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:
can you verify no new interactions on the channel not used for all of these?
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/grpc/stubs/FailoverChannel.java:
##########
@@ -426,11 +445,12 @@ private void onPrimaryStateChanged() {
if (newState == ConnectivityState.READY || newState ==
ConnectivityState.IDLE) {
if (state.markPrimaryReady()) {
LOG.info(
- "[channel-{}] Primary channel recovered; switching back from
fallback.", channelId);
+ "[channel-{}] Primary channel observed healthy during state change
registration; switching back from fallback.",
Review Comment:
this isn't during registration but after notification
--
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]