alievmirza commented on code in PR #1426:
URL: https://github.com/apache/ignite-3/pull/1426#discussion_r1052223469


##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java:
##########
@@ -328,44 +297,40 @@ void testTriggerKeyNotPropagatedAfterZoneUpdate() throws 
Exception {
 
         assertZonesChangeTriggerKey(100);
 
-        assertDataNodesForZone(1, clusterNodes);
+        assertDataNodesForZone(1, nodes);
     }
 
     @Test
     void testZoneDeleteDoNotRemoveMetaStorageKey() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        mockCmgLocalNodes(clusterNodes);
-
-        distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build());
+        distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();
 
-        assertDataNodesForZone(1, clusterNodes);
+        assertDataNodesForZone(1, nodes);
 
-        keyValueStorage.put(zonesChangeTriggerKey().bytes(), 
ByteUtils.longToBytes(100));
+        keyValueStorage.put(zonesChangeTriggerKey().bytes(), longToBytes(100));
 
-        distributionZoneManager.dropZone(ZONE_NAME);
+        distributionZoneManager.dropZone(ZONE_NAME).get();
 
         verify(keyValueStorage, timeout(1000).times(2)).invoke(any());
 
-        assertDataNodesForZone(1, clusterNodes);
+        assertDataNodesForZone(1, nodes);
     }
 
-    private LogicalTopologySnapshot mockCmgLocalNodes(Set<ClusterNode> 
clusterNodes) {
-        LogicalTopologySnapshot logicalTopologySnapshot = 
mock(LogicalTopologySnapshot.class);
-
-        
when(cmgManager.logicalTopology()).thenReturn(completedFuture(logicalTopologySnapshot));
-
-        when(logicalTopologySnapshot.nodes()).thenReturn(clusterNodes);
+    private void mockVaultZonesLogicalTopologyKey(Set<String> nodes) {
+        byte[] newLogicalTopology = toBytes(nodes);
 
-        return logicalTopologySnapshot;
+        when(vaultMgr.get(zonesLogicalTopologyKey()))
+                .thenReturn(completedFuture(new 
VaultEntry(zonesLogicalTopologyKey(), newLogicalTopology)));
     }
 
-    private void assertDataNodesForZone(int zoneId, @Nullable Set<ClusterNode> 
clusterNodes) throws InterruptedException {
-        byte[] nodes = clusterNodes == null
-                ? null
-                : 
ByteUtils.toBytes(clusterNodes.stream().map(ClusterNode::name).collect(Collectors.toSet()));
+    private void assertDataNodesForZone(int zoneId, @Nullable Set<String> 
expectedNodes) throws InterruptedException {
+        if (expectedNodes == null) {
+            
assertNull(keyValueStorage.get(zoneDataNodesKey(zoneId).bytes()).value());
+        } else {
+            Set<String> actual = 
fromBytes(keyValueStorage.get(zoneDataNodesKey(zoneId).bytes()).value());
 
-        assertTrue(waitForCondition(() -> 
Arrays.equals(keyValueStorage.get(zoneDataNodesKey(zoneId).bytes()).value(), 
nodes), 1000));
+            assertTrue(expectedNodes.containsAll(actual));
+            assertTrue(expectedNodes.size() == actual.size());

Review Comment:
   assertEquals(expectedNodes.size(), actual.size());



##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java:
##########
@@ -196,65 +207,42 @@ public void tearDown() throws Exception {
 
     @Test
     void testDataNodesPropagationAfterZoneCreation() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        mockCmgLocalNodes(clusterNodes);
-
         distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();
 
-        assertDataNodesForZone(1, clusterNodes);
+        assertDataNodesForZone(1, nodes);
 
         assertZonesChangeTriggerKey(1);
     }
 
     @Test
     void testTriggerKeyPropagationAfterZoneUpdate() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        LogicalTopologySnapshot logicalTopologySnapshot = 
mockCmgLocalNodes(clusterNodes);
-
         distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();

Review Comment:
   lets add at the beginning of the test 
   
   ```
   assertNull(keyValueStorage.get(zonesChangeTriggerKey().bytes()).value());
   ```



##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java:
##########
@@ -196,65 +207,42 @@ public void tearDown() throws Exception {
 
     @Test
     void testDataNodesPropagationAfterZoneCreation() throws Exception {

Review Comment:
   lets add at the beginning of the test 
   ```
   assertDataNodesForZone(1, null);
   ```



##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZoneManager.java:
##########
@@ -524,4 +541,136 @@ private void initMetaStorageKeysOnStart() {
             }
         });
     }
+
+    private void initDataNodesFromVaultManager() {

Review Comment:
   Javadoc



##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java:
##########
@@ -264,10 +252,6 @@ void testSeveralZoneCreationsUpdatesTriggerKey() throws 
Exception {
 
     @Test
     void testSeveralZoneUpdatesUpdatesTriggerKey() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        mockCmgLocalNodes(clusterNodes);
-
         distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();

Review Comment:
   lets add at the beginning of the test
   
   ```
   assertNull(keyValueStorage.get(zonesChangeTriggerKey().bytes()).value());
   ```



##########
modules/core/src/main/java/org/apache/ignite/lang/ErrorGroups.java:
##########
@@ -334,6 +334,9 @@ public static class DistributionZones {
 
         /** Distribution zone rename error. */
         public static final int ZONE_RENAME_ERR = 
DISTRIBUTION_ZONES_ERR_GROUP.registerErrorCode(3);
+
+        /** Distribution zone update error. */

Review Comment:
   This is a too wide exception, what does it mean "Distribution zone update"? 
You use this exception when you try to init DistributionZoneManager, we don't 
have any zone that is being updated.



##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java:
##########
@@ -196,65 +207,42 @@ public void tearDown() throws Exception {
 
     @Test
     void testDataNodesPropagationAfterZoneCreation() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        mockCmgLocalNodes(clusterNodes);
-
         distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();
 
-        assertDataNodesForZone(1, clusterNodes);
+        assertDataNodesForZone(1, nodes);
 
         assertZonesChangeTriggerKey(1);
     }
 
     @Test
     void testTriggerKeyPropagationAfterZoneUpdate() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        LogicalTopologySnapshot logicalTopologySnapshot = 
mockCmgLocalNodes(clusterNodes);
-
         distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();
 
         assertZonesChangeTriggerKey(1);
 
-        var clusterNodes2 = Set.of(
-                new ClusterNode("1", "name1", null),
-                new ClusterNode("2", "name2", null)
-        );
-
-        when(logicalTopologySnapshot.nodes()).thenReturn(clusterNodes2);
-
         distributionZoneManager.alterZone(
                 ZONE_NAME,
                 new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).dataNodesAutoAdjust(100).build()
         ).get();
 
         assertZonesChangeTriggerKey(2);
 
-        assertDataNodesForZone(1, clusterNodes);
+        assertDataNodesForZone(1, nodes);
     }
 
     @Test
     void testZoneDeleteRemovesMetaStorageKey() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        mockCmgLocalNodes(clusterNodes);
-
-        distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build());
+        distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();
 
-        assertDataNodesForZone(1, clusterNodes);
+        assertDataNodesForZone(1, nodes);
 
-        distributionZoneManager.dropZone(ZONE_NAME);
+        distributionZoneManager.dropZone(ZONE_NAME).get();
 
         assertTrue(waitForCondition(() -> 
keyValueStorage.get(zoneDataNodesKey(1).bytes()).value() == null, 5000));
     }
 
     @Test
     void testSeveralZoneCreationsUpdatesTriggerKey() throws Exception {
-        Set<ClusterNode> clusterNodes = Set.of(new ClusterNode("1", "name1", 
null));
-
-        mockCmgLocalNodes(clusterNodes);
-
         distributionZoneManager.createZone(new 
DistributionZoneConfigurationParameters.Builder(ZONE_NAME).build()).get();

Review Comment:
   lets add at the beginning of the test
   
   ```
   assertNull(keyValueStorage.get(zonesChangeTriggerKey().bytes()).value());
   ```



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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to