tkalkirill commented on code in PR #2254:
URL: https://github.com/apache/ignite-3/pull/2254#discussion_r1279429960


##########
modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java:
##########
@@ -104,74 +128,59 @@ public void setUp() {
 
         when(schManager.schemaRegistry(anyLong(), 
anyInt())).thenReturn(completedFuture(null));
 
-        indexManager = new IndexManager(tablesConfig, schManager, 
tableManagerMock);
-        indexManager.start();
+        String nodeName = "test";
 
-        assertThat(
-                tablesConfig.tables().get("tName")
-                        .change(tableChange -> ((ExtendedTableChange) 
tableChange).changeSchemaId(1)),
-                willCompleteSuccessfully()
-        );
-    }
+        vaultManager = new VaultManager(new InMemoryVaultService());
 
-    @AfterEach
-    void tearDown() throws Exception {
-        if (indexManager != null) {
-            indexManager.stop();
-        }
-    }
+        metaStorageManager = StandaloneMetaStorageManager.create(vaultManager, 
new SimpleInMemoryKeyValueStorage(nodeName));
 
-    @Test
-    void configurationChangedWhenCreateIsInvoked() {
-        String indexName = "idx";
+        clockWaiter = new ClockWaiter(nodeName, clock);
+
+        catalogManager = new CatalogManagerImpl(new 
UpdateLogImpl(metaStorageManager), clockWaiter);
 
-        assertThat(indexManager.createIndexAsync("sName", indexName, "tName", 
true, indexChange -> {
-            SortedIndexChange sortedIndexChange = 
indexChange.convert(SortedIndexChange.class);
-
-            sortedIndexChange.changeColumns(columns -> {
-                columns.create("c1", columnChange -> 
columnChange.changeAsc(true));
-                columns.create("c2", columnChange -> 
columnChange.changeAsc(false));
-            });
-
-            sortedIndexChange.changeTableId(tableId());
-        }), willCompleteSuccessfully());
-
-        var expected = List.of(
-                Map.of(
-                        "columns", List.of(
-                                Map.of(
-                                        "asc", true,
-                                        "name", "c1"
-                                ),
-                                Map.of(
-                                        "asc", false,
-                                        "name", "c2"
-                                )
-                        ),
-                        "name", indexName,
-                        "type", "SORTED",
-                        "uniq", false,
-                        "tableId", tableId(),
-                        "id", 1
-                )
+        indexManager = new IndexManager(
+                tablesConfig,
+                schManager,
+                tableManagerMock,
+                catalogManager,
+                metaStorageManager,
+                mock(Consumer.class)
         );
 
-        assertSameObjects(expected, toMap(tablesConfig.indexes().value()));
-    }
+        vaultManager.start();
+        metaStorageManager.start();
+        clockWaiter.start();
+        catalogManager.start();
+        indexManager.start();
+
+        assertThat(metaStorageManager.deployWatches(), 
willCompleteSuccessfully());
 
-    @Test
-    public void createIndexWithEmptyName() {
         assertThat(
-                indexManager.createIndexAsync("sName", "", "tName", true, 
indexChange -> {/* doesn't matter */}),
-                willThrowFast(IgniteInternalException.class, "Index name 
should be at least 1 character long")
+                catalogManager.createTable(
+                        CreateTableParams.builder()
+                                .schemaName(DEFAULT_SCHEMA_NAME)
+                                .zone(DEFAULT_ZONE_NAME)
+                                .tableName(TABLE_NAME)
+                                .columns(List.of(
+                                        
ColumnParams.builder().name("c1").type(STRING).build(),
+                                        
ColumnParams.builder().name("c2").type(STRING).build()
+                                ))
+                                .colocationColumns(List.of("c1"))
+                                .primaryKeyColumns(List.of("c1"))
+                                .build()
+                ),
+                willBe(nullValue())
         );
     }
 
-    @Test
-    public void dropNonExistingIndex() {
-        assertThat(
-                indexManager.dropIndexAsync("sName", "nonExisting", true),
-                willThrowFast(IndexNotFoundException.class, "Index does not 
exist [name=\"sName\".\"nonExisting\"]")
+    @AfterEach
+    void tearDown() throws Exception {
+        IgniteUtils.closeAll(
+                vaultManager == null ? null : vaultManager::stop,
+                metaStorageManager == null ? null : metaStorageManager::stop,
+                clockWaiter == null ? null : clockWaiter::stop,
+                catalogManager == null ? null : catalogManager::stop,
+                indexManager == null ? null : indexManager::stop

Review Comment:
   fix it



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