From a5f211f7d82d22f6c5d55d0a8fc5119d948a5e47 Mon Sep 17 00:00:00 2001 From: Jaroslaw Grabowski Date: Mon, 14 Jun 2021 11:12:38 +0200 Subject: [PATCH] STAR-571 fix *SnichTests (#197) Migrate to commit log initialization implemented by ServerTestUtils that is race free. Files were removed by the cleanup that followed CL init. (cherry picked from commit 37e2e3d52aae414c521110efdf5bf1bb20c37fad) (cherry picked from commit 5d10d16c88458a1ae655e59575658b7cd74c3ea6) (cherry picked from commit bb4a904a5a8c9957f2a32b326b96b6039c66cdf0) (cherry picked from commit fa0293a51ebfafe173cc526d929dbdfd7b1c78b7) (cherry picked from commit 2f5313d865390839ee87fd37762d006c97442a38) (cherry picked from commit 8889b2ace12bf748c2dbf638d112aba2497abec9) (cherry picked from commit f32f43d9fc696ce843070d6ec7d2322225652320) --- test/unit/org/apache/cassandra/ServerTestUtils.java | 1 + .../apache/cassandra/locator/AlibabaCloudSnitchTest.java | 6 ++---- .../org/apache/cassandra/locator/CloudstackSnitchTest.java | 6 ++---- test/unit/org/apache/cassandra/locator/Ec2SnitchTest.java | 6 ++---- .../org/apache/cassandra/locator/GoogleCloudSnitchTest.java | 6 ++---- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/test/unit/org/apache/cassandra/ServerTestUtils.java b/test/unit/org/apache/cassandra/ServerTestUtils.java index efa461e0aec3..cd286685c274 100644 --- a/test/unit/org/apache/cassandra/ServerTestUtils.java +++ b/test/unit/org/apache/cassandra/ServerTestUtils.java @@ -141,6 +141,7 @@ public static void cleanupAndLeaveDirs() throws IOException mkdirs(); // Creates the directories if they does not exists cleanup(); // Ensure that the directories are all empty CommitLog.instance.restartUnsafe(); + CommitLog.instance.segmentManager.awaitManagementTasksCompletion(); } /** diff --git a/test/unit/org/apache/cassandra/locator/AlibabaCloudSnitchTest.java b/test/unit/org/apache/cassandra/locator/AlibabaCloudSnitchTest.java index 04540cfdc517..809037e283d9 100644 --- a/test/unit/org/apache/cassandra/locator/AlibabaCloudSnitchTest.java +++ b/test/unit/org/apache/cassandra/locator/AlibabaCloudSnitchTest.java @@ -25,6 +25,7 @@ import org.junit.BeforeClass; import org.junit.Test; +import org.apache.cassandra.ServerTestUtils; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.commitlog.CommitLog; @@ -47,10 +48,7 @@ public static void setup() throws Exception { System.setProperty(Gossiper.Props.DISABLE_THREAD_VALIDATION, "true"); DatabaseDescriptor.daemonInitialization(); - CommitLog.instance.start(); - CommitLog.instance.segmentManager.awaitManagementTasksCompletion(); - mkdirs(); - cleanup(); + ServerTestUtils.cleanupAndLeaveDirs(); Keyspace.setInitialized(); StorageService.instance.initServer(0); } diff --git a/test/unit/org/apache/cassandra/locator/CloudstackSnitchTest.java b/test/unit/org/apache/cassandra/locator/CloudstackSnitchTest.java index 51e83718825a..7f7a07e3f374 100644 --- a/test/unit/org/apache/cassandra/locator/CloudstackSnitchTest.java +++ b/test/unit/org/apache/cassandra/locator/CloudstackSnitchTest.java @@ -26,6 +26,7 @@ import org.junit.BeforeClass; import org.junit.Test; +import org.apache.cassandra.ServerTestUtils; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.commitlog.CommitLog; @@ -48,10 +49,7 @@ public static void setup() throws Exception { System.setProperty(Gossiper.Props.DISABLE_THREAD_VALIDATION, "true"); DatabaseDescriptor.daemonInitialization(); - CommitLog.instance.start(); - CommitLog.instance.segmentManager.awaitManagementTasksCompletion(); - mkdirs(); - cleanup(); + ServerTestUtils.cleanupAndLeaveDirs(); Keyspace.setInitialized(); StorageService.instance.initServer(0); } diff --git a/test/unit/org/apache/cassandra/locator/Ec2SnitchTest.java b/test/unit/org/apache/cassandra/locator/Ec2SnitchTest.java index a7f503d1bdef..a555e0662015 100644 --- a/test/unit/org/apache/cassandra/locator/Ec2SnitchTest.java +++ b/test/unit/org/apache/cassandra/locator/Ec2SnitchTest.java @@ -29,6 +29,7 @@ import org.junit.BeforeClass; import org.junit.Test; +import org.apache.cassandra.ServerTestUtils; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.commitlog.CommitLog; @@ -65,10 +66,7 @@ public static void setup() throws Exception { System.setProperty(Gossiper.Props.DISABLE_THREAD_VALIDATION, "true"); DatabaseDescriptor.daemonInitialization(); - CommitLog.instance.start(); - CommitLog.instance.segmentManager.awaitManagementTasksCompletion(); - mkdirs(); - cleanup(); + ServerTestUtils.cleanupAndLeaveDirs(); Keyspace.setInitialized(); StorageService.instance.initServer(0); } diff --git a/test/unit/org/apache/cassandra/locator/GoogleCloudSnitchTest.java b/test/unit/org/apache/cassandra/locator/GoogleCloudSnitchTest.java index 67192bdfa5de..5a8589022241 100644 --- a/test/unit/org/apache/cassandra/locator/GoogleCloudSnitchTest.java +++ b/test/unit/org/apache/cassandra/locator/GoogleCloudSnitchTest.java @@ -27,6 +27,7 @@ import org.junit.BeforeClass; import org.junit.Test; +import org.apache.cassandra.ServerTestUtils; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.commitlog.CommitLog; @@ -49,10 +50,7 @@ public static void setup() throws Exception { System.setProperty(Gossiper.Props.DISABLE_THREAD_VALIDATION, "true"); DatabaseDescriptor.daemonInitialization(); - CommitLog.instance.start(); - CommitLog.instance.segmentManager.awaitManagementTasksCompletion(); - mkdirs(); - cleanup(); + ServerTestUtils.cleanupAndLeaveDirs(); Keyspace.setInitialized(); StorageService.instance.initServer(0); }