zhangmeng916 commented on a change in pull request #869: Replace customized view cache with property cache URL: https://github.com/apache/helix/pull/869#discussion_r397455323
########## File path: helix-core/src/test/java/org/apache/helix/integration/spectator/TestRoutingTableProvider.java ########## @@ -308,19 +327,53 @@ public void testGetRoutingTableSnapshot() { routingTableProvider.getRoutingTableSnapshot(PropertyType.CUSTOMIZEDVIEW, "typeA"); Assert.assertEquals(routingTableSnapshot.getPropertyType(), PropertyType.CUSTOMIZEDVIEW); Assert.assertEquals(routingTableSnapshot.getCustomizedStateType(), "typeA"); + routingTableSnapshot = routingTableProvider.getRoutingTableSnapshot(PropertyType.CUSTOMIZEDVIEW, "typeB"); Assert.assertEquals(routingTableSnapshot.getPropertyType(), PropertyType.CUSTOMIZEDVIEW); Assert.assertEquals(routingTableSnapshot.getCustomizedStateType(), "typeB"); - Map<String, Map<String, RoutingTableSnapshot>> routingTableSnapshots = - routingTableProvider.getRoutingTableSnapshots(); - Assert.assertEquals(routingTableSnapshots.size(), 2); - Assert.assertEquals(routingTableSnapshots.get(PropertyType.CUSTOMIZEDVIEW.name()).size(), 2); + // Make sure snapshot information is correct + // Check resources are in a correct state + boolean isRoutingTableUpdatedProperly = TestHelper.verify(() -> { + Map<String, Map<String, RoutingTableSnapshot>> routingTableSnapshots = + routingTableProvider.getRoutingTableSnapshots(); + RoutingTableSnapshot routingTableSnapshotTypeA = + routingTableSnapshots.get(PropertyType.CUSTOMIZEDVIEW.name()).get("typeA"); + RoutingTableSnapshot routingTableSnapshotTypeB = + routingTableSnapshots.get(PropertyType.CUSTOMIZEDVIEW.name()).get("typeB"); + String typeAp1h1 = "noState"; + String typeAp1h2 = "noState"; + String typeAp2h1 = "noState"; + String typeAp3h2 = "noState"; + String typeBp1h2 = "noState"; + String typeBp1h4 = "noState"; + try { + typeAp1h1 = routingTableSnapshotTypeA.getCustomizeViews().iterator().next() + .getStateMap("p1").get("h1"); + typeAp1h2 = routingTableSnapshotTypeA.getCustomizeViews().iterator().next() + .getStateMap("p1").get("h2"); + typeAp2h1 = routingTableSnapshotTypeA.getCustomizeViews().iterator().next() + .getStateMap("p2").get("h1"); + typeAp3h2 = routingTableSnapshotTypeA.getCustomizeViews().iterator().next() + .getStateMap("p3").get("h2"); + typeBp1h2 = routingTableSnapshotTypeB.getCustomizeViews().iterator().next() + .getStateMap("p1").get("h3"); + typeBp1h4 = routingTableSnapshotTypeB.getCustomizeViews().iterator().next() + .getStateMap("p1").get("h4"); + } catch (Exception e) { + // ok because RoutingTable has not been updated yet + } + return (routingTableSnapshots.size() == 2 + && routingTableSnapshots.get(PropertyType.CUSTOMIZEDVIEW.name()).size() == 2 + && typeAp1h1.equals("testState1") && typeAp1h2.equals("testState1") + && typeAp2h1.equals("testState2") && typeAp3h2.equals("testState3") + && typeBp1h2.equals("testState3") && typeBp1h4.equals("testState2")); + }, TestHelper.WAIT_DURATION); + Assert.assertTrue(isRoutingTableUpdatedProperly); Review comment: Please also add message in the assertion for easy understanding. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org For additional commands, e-mail: reviews-h...@helix.apache.org