ekaterinadimitrova2 commented on code in PR #1850:
URL: https://github.com/apache/cassandra/pull/1850#discussion_r966475214


##########
test/distributed/org/apache/cassandra/distributed/test/SchemaTest.java:
##########
@@ -86,4 +98,58 @@ private void selectSilent(Cluster cluster, String name)
             assertTrue(causeIsUnknownColumn);
         }
     }
+
+    @Test
+    public void schemaReset() throws Throwable
+    {
+        int delay = 5000;
+        CassandraRelevantProperties.MIGRATION_DELAY.setInt(delay);
+        CassandraRelevantProperties.SCHEMA_PULL_INTERVAL_MS.setInt(delay);
+
+        try (Cluster cluster = init(Cluster.build(2).withConfig(cfg -> 
cfg.with(Feature.GOSSIP, Feature.NETWORK)).start()))
+        {
+            cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk INT 
PRIMARY KEY, v TEXT)");
+
+            assertTrue(cluster.get(1).callOnInstance(() -> 
Schema.instance.getTableMetadata(KEYSPACE, "tbl") != null));
+            assertTrue(cluster.get(2).callOnInstance(() -> 
Schema.instance.getTableMetadata(KEYSPACE, "tbl") != null));
+
+            cluster.get(2).shutdown().get();
+
+            Awaitility.await()
+                      .atMost(ofSeconds(30))
+                      .until(() -> cluster
+                                   .get(1)
+                                   .callOnInstance(() -> Gossiper.instance
+                                                         .getLiveMembers()
+                                                         .stream()
+                                                         .allMatch(addr -> 
addr.equals(FBUtilities.getBroadcastAddressAndPort()))));
+
+            // when schema is removed and there is no other node to fetch it 
from, node 1 should be left with clean schema
+            //noinspection Convert2MethodRef
+            cluster.get(1).runOnInstance(() -> 
StorageService.instance.resetLocalSchema());
+            assertTrue(cluster.get(1).callOnInstance(() -> 
Schema.instance.getTableMetadata(KEYSPACE, "tbl") == null));
+
+            // sleep slightly longer than the schema pull interval
+            Uninterruptibles.sleepUninterruptibly((int) (delay * 1.2), 
TimeUnit.MILLISECONDS);

Review Comment:
   Do we need this sleep actually or only the one after start?



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


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

Reply via email to