You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/08/15 23:17:34 UTC

[GitHub] [helix] kaisun2000 commented on issue #1277: Fix flaky test TestCustomizedViewAggregation.testCustomizedViewAggregation

kaisun2000 commented on issue #1277:
URL: https://github.com/apache/helix/issues/1277#issuecomment-674456719


   ``` 
    private void validateAggregationSnapshot() throws Exception {
       boolean result = TestHelper.verify(new TestHelper.Verifier() {
         @Override
         public boolean verify() {
           Map<String, Map<String, RoutingTableSnapshot>> routingTableSnapshots =
               _routingTableProvider.getRoutingTableSnapshots();
   
           // Get customized view snapshot
           Map<String, RoutingTableSnapshot> fullCustomizedViewSnapshot =
               routingTableSnapshots.get(PropertyType.CUSTOMIZEDVIEW.name());
   
           if (fullCustomizedViewSnapshot.isEmpty() && !_routingTableProviderDataSources.isEmpty()) {
             return false;
           }
   
           for (String customizedStateType : fullCustomizedViewSnapshot.keySet()) {
             if (!_routingTableProviderDataSources.contains(customizedStateType)) {
               return false;
             }
   
             // Get per customized state type snapshot
             RoutingTableSnapshot customizedViewSnapshot =
                 fullCustomizedViewSnapshot.get(customizedStateType);
   
             // local per customized state type map
             Map<String, Map<String, Map<String, String>>> localSnapshot =
                 _localCustomizedView.getOrDefault(customizedStateType, Maps.newHashMap());
   
             Collection<CustomizedView> customizedViews = customizedViewSnapshot.getCustomizeViews();
   
             // If a customized state is not set to be aggregated in config, but is enabled in routing table provider, it will show up in customized view returned to user, but will be empty
             if (!_aggregationEnabledTypes.contains(customizedStateType)
                 && customizedViews.size() != 0) {
               return false;
             }
   
             if (_aggregationEnabledTypes.contains(customizedStateType)
                 && customizedViews.size() != localSnapshot.size()) {
               return false;
             }
   
             // Get per resource snapshot
             for (CustomizedView resourceCustomizedView : customizedViews) {
               ZNRecord record = resourceCustomizedView.getRecord();
               Map<String, Map<String, String>> resourceStateMap = record.getMapFields();
   
               // Get local per resource map
               Map<String, Map<String, String>> localPerResourceCustomizedView = localSnapshot
                   .getOrDefault(resourceCustomizedView.getResourceName(), Maps.newHashMap());
   
               if (resourceStateMap.size() != localPerResourceCustomizedView.size()) {
                 return false;
               }
   
               // Get per partition snapshot
               for (String partitionName : resourceStateMap.keySet()) {
                 Map<String, String> stateMap =
                     resourceStateMap.getOrDefault(partitionName, Maps.newTreeMap());
   
                 // Get local per partition map
                 Map<String, String> localStateMap =
                     localPerResourceCustomizedView.getOrDefault(partitionName, Maps.newTreeMap());
   
                 if (stateMap.isEmpty() && !localStateMap.isEmpty()) {
                   return false;
                 }
   
                 for (String instanceName : stateMap.keySet()) {
                   // Per instance value
                   String stateMapValue = stateMap.get(instanceName);
                   String localStateMapValue = localStateMap.get(instanceName);
                   if (!stateMapValue.equals(localStateMapValue)) {
                     return false;
                   }
                 }
               }
             }
           }
           return true;
         }
       }, TestHelper.WAIT_DURATION);
   
       Assert.assertTrue(result);  -------> failed here, TestHelper.WAIT_DURATION is 20s by default.
   ```
   
   More likely than not, the issue is 20s is not long enough. 
   
   Action is to ad log and enable longer WAIT_DURATION.


----------------------------------------------------------------
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:
users@infra.apache.org



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