AMashenkov commented on code in PR #1832:
URL: https://github.com/apache/ignite-3/pull/1832#discussion_r1146188192


##########
modules/distribution-zones/src/test/java/org/apache/ignite/internal/distributionzones/DistributionZoneManagerConfigurationChangesTest.java:
##########
@@ -115,178 +98,46 @@ public void setUp() {
         DistributionZonesConfiguration zonesConfiguration = 
clusterCfgMgr.configurationRegistry()
                 .getConfiguration(DistributionZonesConfiguration.KEY);
 
-        MetaStorageManager metaStorageManager = mock(MetaStorageManager.class);
-
-        
when(metaStorageManager.appliedRevision(any())).thenReturn(completedFuture(0L));
+        vaultMgr = new VaultManager(new InMemoryVaultService());
 
         LogicalTopologyService logicalTopologyService = 
mock(LogicalTopologyService.class);
+        doNothing().when(logicalTopologyService).addEventListener(any());
+        
when(logicalTopologyService.logicalTopologyOnLeader()).thenReturn(completedFuture(new
 LogicalTopologySnapshot(1, Set.of())));
 
-        vaultMgr = mock(VaultManager.class);
-
-        when(vaultMgr.get(any())).thenReturn(completedFuture(null));
-
-        TablesConfiguration tablesConfiguration = 
mock(TablesConfiguration.class);
-
-        NamedConfigurationTree<TableConfiguration, TableView, TableChange> 
tables = mock(NamedConfigurationTree.class);
-
-        when(tablesConfiguration.tables()).thenReturn(tables);
-
-        NamedListView<TableView> value = mock(NamedListView.class);
+        keyValueStorage = spy(new SimpleInMemoryKeyValueStorage("test"));
 
-        when(tables.value()).thenReturn(value);
+        metaStorageManager = StandaloneMetaStorageManager.create(vaultMgr, 
keyValueStorage);
 
-        when(value.namedListKeys()).thenReturn(new ArrayList<>());
+        TablesConfiguration tablesConfiguration = mockTablesConfiguration();
 
         distributionZoneManager = new DistributionZoneManager(
                 zonesConfiguration,
                 tablesConfiguration,
                 metaStorageManager,
                 logicalTopologyService,
                 vaultMgr,
-                "node"
+                "test"
         );
 
-        clusterCfgMgr.start();
-
-        doNothing().when(logicalTopologyService).addEventListener(any());
-
-        
when(logicalTopologyService.logicalTopologyOnLeader()).thenReturn(completedFuture(new
 LogicalTopologySnapshot(1, Set.of())));
-
-        mockVaultZonesLogicalTopologyKey(nodes);
+        // Mock logical topology for distribution zone.
+        // vaultMgr.put(zonesLogicalTopologyKey(), toBytes(nodes));
+        keyValueStorage.put(zonesLogicalTopologyVersionKey().bytes(), 
longToBytes(1));

Review Comment:
   ```
    vaultMgr = mock(VaultManager.class);
           when(vaultMgr.get(any())).thenReturn(completedFuture(null));
           CompletableFuture<VaultEntry> fut = new CompletableFuture<>();;
           
           when(vaultMgr.get(zonesLogicalTopologyKey()))
                   .thenReturn(fut.completeAsync(
                           () -> new VaultEntry(zonesLogicalTopologyKey(), 
toBytes(nodes)),
                           CompletableFuture.delayedExecutor(1, 
TimeUnit.SECONDS)));
   
   ```
   Test fails if we delay future completion.
   That means DistributedZoneManager make some interactions with other 
components, that are not tested well.



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