jacek-lewandowski commented on code in PR #1804:
URL: https://github.com/apache/cassandra/pull/1804#discussion_r960413881


##########
test/distributed/org/apache/cassandra/distributed/test/SchemaTest.java:
##########
@@ -95,25 +107,54 @@ private void selectSilent(Cluster cluster, String name)
     @Test
     public void schemaReset() throws Throwable
     {
+        CassandraRelevantProperties.MIGRATION_DELAY.setLong(10000);
+        CassandraRelevantProperties.SCHEMA_PULL_INTERVAL.setLong(10000);
         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));
 
+            // now we have a table tbl in the schema of both nodes
+
             cluster.get(2).shutdown().get();
 
-            // when schema is removed and there is no other node to fetch it 
from, node 1 should be left with clean schema
-            cluster.get(1).runOnInstance(() -> 
Schema.instance.resetLocalSchema());
+            Awaitility.await().atMost(Duration.ofSeconds(30)) // wait until 
node 1 notices that node 2 is dead
+                      .until(() -> cluster.get(1).callOnInstance(() -> 
Gossiper.instance.getLiveMembers().stream().allMatch(e -> 
e.equals(FBUtilities.getBroadcastAddressAndPort()))));
+
+            // when there is no node to fetch the schema from, reset local 
schema should immediately fail
+            
Assertions.assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> {
+                cluster.get(1).runOnInstance(() -> 
Schema.instance.resetLocalSchema());

Review Comment:
   > Please ignore this last suggestion, I forgot that method references don't 
work in the dtest framework.
   
   heh... yes, I struggled this problem some time ago. 
`runElsewhere(Schema.instance::resetLocalSchema)` means more or less:
   ```java
   Schema schema = Schema.instance;
   runElsewhere(() -> schema.resetLocalSchema());
   ```
   so it is something completely different :-)
   



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