kaisun2000 opened a new issue #1254:
URL: https://github.com/apache/helix/issues/1254


   If testCurrentStatesSelectiveUpdate() runs before testUpdateOnNotification() 
and then testSelectiveUpdates(). testSelectiveUpdates() would fail.
   
   The reason is that testCurrentStatesSelectiveUpdate() stop one participant.  
Thus the code in testSelectiveUpdate() constructing RoutingDataCache, the 
external view of "TestDb" would be version 1. Later, 
`_gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB_1", _replica);` is 
invoked, controller would calculate best possible again. This would write 
TestDb external view to version 2. Thus, 
`Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW),` would 
fail due to version 2 not match existing version 1 in the cache. 
   
   We need to ensure testCurrentStatesSelectiveUpdate always run later.
   
   ```
     public void testSelectiveUpdates()
         throws Exception {
       MockZkHelixDataAccessor accessor =
           new MockZkHelixDataAccessor(CLUSTER_NAME, new 
ZkBaseDataAccessor<ZNRecord>(_gZkClient));
   
       RoutingDataCache cache =
           new RoutingDataCache("CLUSTER_" + TestHelper.getTestClassName(), 
PropertyType.EXTERNALVIEW);
       cache.refresh(accessor);
       Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 1);
   
       accessor.clearReadCounters();
   
       // refresh again should read nothing
       cache.refresh(accessor);
       Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0);
   
       // refresh again should read nothing
       cache.notifyDataChange(HelixConstants.ChangeType.EXTERNAL_VIEW);
       cache.refresh(accessor);
       Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0);
   
       // add new resources
       _gSetupTool.addResourceToCluster(CLUSTER_NAME, "TestDB_1", 1, 
STATE_MODEL);
       _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB_1", _replica);
   
       Thread.sleep(100);
       ZkHelixClusterVerifier _clusterVerifier =
           new 
BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
       Assert.assertTrue(_clusterVerifier.verifyByPolling());
   
       accessor.clearReadCounters();
   
       // refresh again should read only new current states and new idealstate
       cache.notifyDataChange(HelixConstants.ChangeType.EXTERNAL_VIEW);
       cache.refresh(accessor);
       Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW),
   
   ```
   


----------------------------------------------------------------
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:
[email protected]



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

Reply via email to