jiajunwang commented on a change in pull request #635: Fix a potential issue in 
the ResourceChangeSnapshot.
URL: https://github.com/apache/helix/pull/635#discussion_r352814127
 
 

 ##########
 File path: 
helix-core/src/test/java/org/apache/helix/controller/changedetector/TestResourceChangeDetector.java
 ##########
 @@ -359,22 +359,21 @@ public void testIgnoreControllerGeneratedFields() {
         .addResource(CLUSTER_NAME, resourceName, NUM_PARTITIONS, STATE_MODEL);
     IdealState idealState = 
_dataAccessor.getProperty(_keyBuilder.idealStates(resourceName));
     idealState.setRebalanceMode(IdealState.RebalanceMode.FULL_AUTO);
+    idealState.getRecord().getMapFields().put("Partition1", new HashMap<>());
     _dataAccessor.updateProperty(_keyBuilder.idealStates(resourceName), 
idealState);
-
     _dataProvider.notifyDataChange(ChangeType.CLUSTER_CONFIG);
     _dataProvider.notifyDataChange(ChangeType.IDEAL_STATE);
     _dataProvider.refresh(_dataAccessor);
 
+    // Test with ignore option to be true
     ResourceChangeDetector changeDetector = new ResourceChangeDetector(true);
     changeDetector.updateSnapshots(_dataProvider);
-
-    // Now, modify the field that is modifying by Helix logic
-    idealState.getRecord().getMapFields().put("Extra_Change", new HashMap<>());
-    _dataAccessor.updateProperty(_keyBuilder.idealStates(NEW_RESOURCE_NAME), 
idealState);
+    // Now, modify the field
+    idealState.getRecord().getMapFields().put("Partition1", 
Collections.singletonMap("foo", "bar"));
+    _dataAccessor.updateProperty(_keyBuilder.idealStates(resourceName), 
idealState);
     _dataProvider.notifyDataChange(ChangeType.IDEAL_STATE);
     _dataProvider.refresh(_dataAccessor);
     changeDetector.updateSnapshots(_dataProvider);
-
     Assert.assertEquals(changeDetector.getChangeTypes(),
         Collections.singleton(ChangeType.IDEAL_STATE));
 
 Review comment:
   Yes and no. The change type is directly propagated from the cluster cache. 
So it records whatever events have been processed. For our usage, we need to 
compare the content anyway. So cleaning this list seems to be:
   1. not necessary.
   2. may cause some potential problems since we might remove the content 
prematurely. It is better to make the judge in the caller logic.

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


With regards,
Apache Git Services

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

Reply via email to