zstan commented on a change in pull request #441:
URL: https://github.com/apache/ignite-3/pull/441#discussion_r752218191



##########
File path: 
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTablesApiTest.java
##########
@@ -104,97 +114,308 @@
 
     /** Cluster nodes. */
     private List<Ignite> clusterNodes;
-
+    
     /**
      * Before each.
      */
     @BeforeEach
     void beforeEach(TestInfo testInfo) throws Exception {
         String metastorageNodeName = IgniteTestUtils.testNodeName(testInfo, 0);
-
+        
         clusterNodes = IntStream.range(0, 
nodesBootstrapCfg.size()).mapToObj(value -> {
                     String nodeName = IgniteTestUtils.testNodeName(testInfo, 
value);
-
+                    
                     return IgnitionManager.start(
                             nodeName,
                             
nodesBootstrapCfg.get(value).apply(metastorageNodeName),
                             workDir.resolve(nodeName));
                 }
         ).collect(Collectors.toList());
     }
-
+    
     /**
      * After each.
      */
     @AfterEach
     void afterEach() throws Exception {
         IgniteUtils.closeAll(ItUtils.reverse(clusterNodes));
     }
+    
+    /**
+     * Trys to create a table which is already created.
+     *
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testTableAlreadyCreated() throws Exception {
+        clusterNodes.forEach(ign -> 
assertNull(ign.tables().table(TABLE_NAME)));
+        
+        Ignite ignite0 = clusterNodes.get(0);
+        
+        Table tbl = createTable(ignite0, SCHEMA, SHORT_TABLE_NAME);
+        
+        assertThrows(TableAlreadyExistsException.class,
+                () -> createTable(ignite0, SCHEMA, SHORT_TABLE_NAME));
+        
+        assertEquals(tbl, createTableIfNotExists(ignite0, SCHEMA, 
SHORT_TABLE_NAME));
+    }
 
     /**
-     * Checks that if a table would be created/dropped into any cluster node, 
this is visible to all other nodes.
+     * Trys to create a table which is already created from lagged node.
      *
      * @throws Exception If failed.
      */
     @Test
-    public void testCreateDropTable() throws Exception {
+    @Disabled("IGNITE-15891 Configuration use local state cache internally, 
but have to look at consensus")
+    public void testTableAlreadyCreatedFromLaggedNode() throws Exception {
         clusterNodes.forEach(ign -> 
assertNull(ign.tables().table(TABLE_NAME)));
 
+        Ignite ignite0 = clusterNodes.get(0);
+
         Ignite ignite1 = clusterNodes.get(1);
 
-        WatchListenerInhibitor ignite1Inhibitor = 
WatchListenerInhibitor.metastorageEventsInhibitor(ignite1);
+        WatchListenerInhibitor ignite1Inhibitor = 
metastorageEventsInhibitor(ignite1);
 
         ignite1Inhibitor.startInhibit();
 
-        Table table = createTable(clusterNodes.get(0), SCHEMA, 
SHORT_TABLE_NAME);
+        createTable(ignite0, SCHEMA, SHORT_TABLE_NAME);
+    
+        CompletableFuture createTblFut = CompletableFuture.runAsync(() -> 
createTable(ignite1, SCHEMA, SHORT_TABLE_NAME));
+        CompletableFuture createTblIfNotExistsFut = CompletableFuture
+                .runAsync(() -> createTableIfNotExists(ignite1, SCHEMA, 
SHORT_TABLE_NAME));
 
-        IgniteUuid tblId = ((TableImpl) table).tableId();
+        for (Ignite ignite : clusterNodes) {
+            if (ignite != ignite1) {
+                assertThrows(TableAlreadyExistsException.class,
+                        () -> createTable(ignite, SCHEMA, SHORT_TABLE_NAME));
 
+                assertNotNull(createTableIfNotExists(ignite, SCHEMA, 
SHORT_TABLE_NAME));
+            }
+        }
+
+        assertFalse(createTblFut.isDone());
+        assertFalse(createTblIfNotExistsFut.isDone());
+
+        ignite1Inhibitor.stopInhibit();
+
+        assertThrows(TableAlreadyExistsException.class, () -> {
+            try {
+                createTblFut.get(10, TimeUnit.SECONDS);
+            } catch (ExecutionException e) {
+                throw e.getCause();
+            }
+        });
+
+        assertNotNull(createTblIfNotExistsFut.get(10, TimeUnit.SECONDS));
+    }
+
+    /**
+     * Trys to create an index which is already created.
+     *
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testAddIndex() throws Exception {
+        clusterNodes.forEach(ign -> 
assertNull(ign.tables().table(TABLE_NAME)));
+
+        Ignite ignite0 = clusterNodes.get(0);
+
+        createTable(ignite0, SCHEMA, SHORT_TABLE_NAME);
+
+        addIndex(ignite0, SCHEMA, SHORT_TABLE_NAME);

Review comment:
       I don`t like the method, implicitly creates the index, it would be 
useful to append additional param: indexName.




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