bianca-stanciu29 commented on code in PR #223:
URL: 
https://github.com/apache/cassandra-analytics/pull/223#discussion_r4006207527


##########
cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CassandraClusterInfoTest.java:
##########
@@ -63,6 +71,75 @@ void testTimeSkewAcceptable()
         .isThrownBy(() -> ci.validateTimeSkewWithLocalNow(range(10, 20), 
localNow));
     }
 
+    @Test
+    void testLoadBalancedClusterInfoUsesSidecarClientContactPointsForTimeSkew()
+    {
+        Instant localNow = Instant.now();
+        int allowanceMinutes = 10;
+
+        SidecarClient sidecarClient = mock(SidecarClient.class);
+        CassandraContext ctx = mock(CassandraContext.class);
+        when(ctx.getSidecarClient()).thenReturn(sidecarClient);
+        TimeSkewResponse tsr = new TimeSkewResponse(localNow.toEpochMilli(), 
allowanceMinutes);
+        
when(sidecarClient.timeSkew()).thenReturn(CompletableFuture.completedFuture(tsr));
+
+        CassandraClusterInfo ci = new 
LoadBalancedCassandraClusterInfo((BulkSparkConf) null, null)
+        {
+            @Override
+            protected CassandraContext buildCassandraContext()
+            {
+                return ctx;
+            }
+
+            @Override
+            public TokenRangeMapping<RingInstance> 
getTokenRangeMapping(boolean cached)
+            {
+                return TokenRangeMappingUtils.buildTokenRangeMapping(0, 
ImmutableMap.of("dc1", 3), 5);
+            }
+        };
+
+        assertThatNoException()
+        .describedAs("Load-balanced cluster info must use timeSkew() so load 
balancer contact points stay reachable")
+        .isThrownBy(() -> ci.validateTimeSkewWithLocalNow(range(10, 20), 
localNow));
+        verify(sidecarClient).timeSkew();
+        verify(sidecarClient, never()).timeSkew(anyList());
+    }
+
+    @Test
+    void 
testCreateSelectsLoadBalancedClusterInfoWhenSidecarBehindLoadBalancer()

Review Comment:
   Done, added the tests. The coordinated one checks `fromBulkSparkConf(...)` 
builds a `LoadBalancedCassandraClusterInfo` per cluster when the flag is on, 
and the executor one checks `BroadcastableClusterInfo.reconstruct()` returns 
one too. Also added the flag-off cases on both paths to catch the inverse 
regression.
   



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to