You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "parakhnr (via GitHub)" <gi...@apache.org> on 2023/05/02 23:49:45 UTC

[GitHub] [helix] parakhnr commented on a diff in pull request #2476: Refactor TestRoutingTableProvider

parakhnr commented on code in PR #2476:
URL: https://github.com/apache/helix/pull/2476#discussion_r1183141335


##########
helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProvider.java:
##########
@@ -298,21 +284,26 @@ public void testCustomizedViewWithoutType() {
   public void testCustomizedViewCorrectConstructor() throws Exception {
     Map<PropertyType, List<String>> sourceDataTypes = new HashMap<>();
     sourceDataTypes.put(PropertyType.CUSTOMIZEDVIEW, Arrays.asList("typeA"));
-    MockRoutingTableProvider routingTableProvider =
-        new MockRoutingTableProvider(_spectator, sourceDataTypes);
+    CountDownLatch countDownLatch = new CountDownLatch(1);
+    RoutingTableProvider routingTableProvider =
+        new RoutingTableProvider(_spectator, sourceDataTypes) {
+          @Override
+          public void onCustomizedViewChange(List<CustomizedView> customizedViewList,
+              NotificationContext changeContext){
+            countDownLatch.countDown();
+            super.onCustomizedViewChange(customizedViewList, changeContext);
+          }
+        };
 
     CustomizedView customizedView = new CustomizedView(TEST_DB);
     customizedView.setState("p1", "h1", "testState");
 
     // Clear the flag before writing to the Customized View Path
-    customizedViewChangeCalled.getAndSet(false);
     String customizedViewPath = PropertyPathBuilder.customizedView(CLUSTER_NAME, "typeA", TEST_DB);
     _spectator.getHelixDataAccessor().getBaseDataAccessor().set(customizedViewPath,
         customizedView.getRecord(), AccessOption.PERSISTENT);
 
-    boolean onCustomizedViewChangeCalled =
-        TestHelper.verify(() -> customizedViewChangeCalled.get(), WAIT_DURATION);
-    Assert.assertTrue(onCustomizedViewChangeCalled);
+    Assert.assertTrue(countDownLatch.await(5000, TimeUnit.MILLISECONDS));

Review Comment:
   nit: Should we use `WAIT_DURATION` instead of `5000`.



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org