You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by yc...@apache.org on 2024/02/13 22:12:27 UTC
(cassandra-analytics) branch trunk updated: CASSANDRA-19285 Fix flaky Host replacement tests and shrink tests
This is an automated email from the ASF dual-hosted git repository.
ycai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-analytics.git
The following commit(s) were added to refs/heads/trunk by this push:
new c3e8803 CASSANDRA-19285 Fix flaky Host replacement tests and shrink tests
c3e8803 is described below
commit c3e8803b3331bc7ef81797ac52a8417524f67edc
Author: Yifan Cai <yc...@apache.org>
AuthorDate: Tue Feb 13 09:52:57 2024 -0800
CASSANDRA-19285 Fix flaky Host replacement tests and shrink tests
The flakiness is caused by inspecting a class whose classloader is already closed. The fix is to include the those classes in the sharedClassLoader, so that the classLoader is not closed during the test.
patch by Yifan Cai; reviewed by Francisco Guerrero for CASSANDRA-19285
---
.../spark/bulkwriter/SidecarDataTransferApi.java | 3 +-
.../testing/JvmDTestSharedClassesPredicate.java | 47 ++++++++++++++++++++++
.../cassandra/testing/CassandraTestTemplate.java | 2 +
.../cassandra/analytics/BulkWriteTtlTest.java | 2 +
.../analytics/QuoteIdentifiersReadTest.java | 2 +
.../analytics/QuoteIdentifiersWriteTest.java | 2 +
.../cassandra/analytics/ResiliencyTestBase.java | 4 +-
.../analytics/data/ClearSnapshotTest.java | 2 +
8 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/SidecarDataTransferApi.java b/cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/SidecarDataTransferApi.java
index 6ddba7a..b6a492b 100644
--- a/cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/SidecarDataTransferApi.java
+++ b/cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/SidecarDataTransferApi.java
@@ -31,6 +31,7 @@ import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.sidecar.client.SidecarClient;
import org.apache.cassandra.sidecar.client.SidecarInstanceImpl;
import org.apache.cassandra.sidecar.client.request.ImportSSTableRequest;
+import org.apache.cassandra.sidecar.common.data.MD5Digest;
import org.apache.cassandra.sidecar.common.data.SSTableImportResponse;
import org.apache.cassandra.spark.common.MD5Hash;
import org.apache.cassandra.spark.common.client.ClientException;
@@ -79,7 +80,7 @@ public class SidecarDataTransferApi implements DataTransferApi
maybeQuotedIdentifier(bridge, conf.quoteIdentifiers, conf.table),
uploadId,
componentName,
- fileHash.toString(),
+ new MD5Digest(fileHash.toString()),
componentFile.toAbsolutePath().toString())
.get();
}
diff --git a/cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/sidecar/testing/JvmDTestSharedClassesPredicate.java b/cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/sidecar/testing/JvmDTestSharedClassesPredicate.java
new file mode 100644
index 0000000..d4772d0
--- /dev/null
+++ b/cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/sidecar/testing/JvmDTestSharedClassesPredicate.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.sidecar.testing;
+
+import java.util.function.Predicate;
+
+import org.apache.cassandra.distributed.impl.AbstractCluster;
+
+/**
+ * Predicate to instruct the JVM DTest framework on the classes should be loaded by the shared classloader.
+ */
+public class JvmDTestSharedClassesPredicate implements Predicate<String>
+{
+ public static final JvmDTestSharedClassesPredicate INSTANCE = new JvmDTestSharedClassesPredicate();
+
+ private static final Predicate<String> EXTRA = className -> {
+ // Those classes can be reached by Spark SizeEstimator, when it estimates the broadcast variable.
+ // In the test scenario containing cassandra instance shutdown, there is a chance that it pick the class
+ // that is loaded by the closed instance classloader, causing the following exception.
+ // java.lang.IllegalStateException: Can't load <CLASS>. Instance class loader is already closed.
+ return className.equals("org.apache.cassandra.utils.concurrent.Ref$OnLeak")
+ || className.startsWith("org.apache.cassandra.metrics.RestorableMeter");
+ };
+ private static final Predicate<String> DELEGATE = AbstractCluster.SHARED_PREDICATE.or(EXTRA);
+
+ @Override
+ public boolean test(String s)
+ {
+ return DELEGATE.test(s);
+ }
+}
diff --git a/cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/testing/CassandraTestTemplate.java b/cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/testing/CassandraTestTemplate.java
index 527d1c7..bda6650 100644
--- a/cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/testing/CassandraTestTemplate.java
+++ b/cassandra-analytics-integration-framework/src/main/java/org/apache/cassandra/testing/CassandraTestTemplate.java
@@ -43,6 +43,7 @@ import org.apache.cassandra.distributed.api.IUpgradeableInstance;
import org.apache.cassandra.distributed.api.TokenSupplier;
import org.apache.cassandra.distributed.shared.ClusterUtils;
import org.apache.cassandra.distributed.shared.Versions;
+import org.apache.cassandra.sidecar.testing.JvmDTestSharedClassesPredicate;
import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;
@@ -175,6 +176,7 @@ public class CassandraTestTemplate implements TestTemplateInvocationContextProvi
.withVersion(requestedVersion)
.withDCs(dcCount)
.withDataDirCount(annotation.numDataDirsPerInstance())
+ .withSharedClasses(JvmDTestSharedClassesPredicate.INSTANCE)
.withConfig(config -> annotationToFeatureList(annotation).forEach(config::with));
TokenSupplier tokenSupplier = TokenSupplier.evenlyDistributedTokens(finalNodeCount,
clusterBuilder.getTokenCount());
diff --git a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/BulkWriteTtlTest.java b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/BulkWriteTtlTest.java
index 65e23c9..74f9b3e 100644
--- a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/BulkWriteTtlTest.java
+++ b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/BulkWriteTtlTest.java
@@ -32,6 +32,7 @@ import org.apache.cassandra.distributed.api.SimpleQueryResult;
import org.apache.cassandra.distributed.api.TokenSupplier;
import org.apache.cassandra.distributed.shared.Uninterruptibles;
import org.apache.cassandra.distributed.shared.Versions;
+import org.apache.cassandra.sidecar.testing.JvmDTestSharedClassesPredicate;
import org.apache.cassandra.sidecar.testing.QualifiedName;
import org.apache.cassandra.spark.bulkwriter.TTLOption;
import org.apache.cassandra.spark.bulkwriter.WriterOptions;
@@ -108,6 +109,7 @@ class BulkWriteTtlTest extends SharedClusterSparkIntegrationTestBase
.withVersion(requestedVersion)
.withDCs(1)
.withDataDirCount(1)
+ .withSharedClasses(JvmDTestSharedClassesPredicate.INSTANCE)
.withConfig(config -> config.with(Feature.NATIVE_PROTOCOL)
.with(Feature.GOSSIP)
.with(Feature.JMX));
diff --git a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersReadTest.java b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersReadTest.java
index 774e5f6..65721a5 100644
--- a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersReadTest.java
+++ b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersReadTest.java
@@ -37,6 +37,7 @@ import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.api.TokenSupplier;
import org.apache.cassandra.distributed.shared.Versions;
+import org.apache.cassandra.sidecar.testing.JvmDTestSharedClassesPredicate;
import org.apache.cassandra.sidecar.testing.QualifiedName;
import org.apache.cassandra.testing.TestVersion;
import org.apache.spark.sql.Dataset;
@@ -119,6 +120,7 @@ class QuoteIdentifiersReadTest extends SharedClusterSparkIntegrationTestBase
.withVersion(requestedVersion)
.withDCs(1)
.withDataDirCount(1)
+ .withSharedClasses(JvmDTestSharedClassesPredicate.INSTANCE)
.withConfig(config -> config.with(Feature.NATIVE_PROTOCOL)
.with(Feature.GOSSIP)
.with(Feature.JMX));
diff --git a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersWriteTest.java b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersWriteTest.java
index 6dcbeda..3acbcb1 100644
--- a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersWriteTest.java
+++ b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/QuoteIdentifiersWriteTest.java
@@ -41,6 +41,7 @@ import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.api.TokenSupplier;
import org.apache.cassandra.distributed.shared.Versions;
+import org.apache.cassandra.sidecar.testing.JvmDTestSharedClassesPredicate;
import org.apache.cassandra.sidecar.testing.QualifiedName;
import org.apache.cassandra.spark.bulkwriter.WriterOptions;
import org.apache.cassandra.testing.TestVersion;
@@ -143,6 +144,7 @@ class QuoteIdentifiersWriteTest extends SharedClusterSparkIntegrationTestBase
.withVersion(requestedVersion)
.withDCs(1)
.withDataDirCount(1)
+ .withSharedClasses(JvmDTestSharedClassesPredicate.INSTANCE)
.withConfig(config -> config.with(Feature.NATIVE_PROTOCOL)
.with(Feature.GOSSIP)
.with(Feature.JMX));
diff --git a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/ResiliencyTestBase.java b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/ResiliencyTestBase.java
index 9a39f8a..4394a0b 100644
--- a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/ResiliencyTestBase.java
+++ b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/ResiliencyTestBase.java
@@ -51,6 +51,7 @@ import org.apache.cassandra.distributed.api.SimpleQueryResult;
import org.apache.cassandra.distributed.api.TokenSupplier;
import org.apache.cassandra.distributed.impl.AbstractCluster;
import org.apache.cassandra.distributed.shared.Versions;
+import org.apache.cassandra.sidecar.testing.JvmDTestSharedClassesPredicate;
import org.apache.cassandra.sidecar.testing.QualifiedName;
import org.apache.cassandra.spark.bulkwriter.DecoratedKey;
import org.apache.cassandra.spark.bulkwriter.Tokenizer;
@@ -97,7 +98,8 @@ public abstract class ResiliencyTestBase extends SharedClusterSparkIntegrationTe
.withDCs(dcCount)
.withDataDirCount(configuration.numDataDirsPerInstance)
.withConfig(config -> configuration.features.forEach(config::with))
- .withTokenSupplier(tokenSupplier);
+ .withTokenSupplier(tokenSupplier)
+ .withSharedClasses(JvmDTestSharedClassesPredicate.INSTANCE);
if (dcCount > 1)
{
diff --git a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/data/ClearSnapshotTest.java b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/data/ClearSnapshotTest.java
index a363e44..2b7b0a1 100644
--- a/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/data/ClearSnapshotTest.java
+++ b/cassandra-analytics-integration-tests/src/test/java/org/apache/cassandra/analytics/data/ClearSnapshotTest.java
@@ -40,6 +40,7 @@ import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.shared.Uninterruptibles;
import org.apache.cassandra.distributed.shared.Versions;
import org.apache.cassandra.distributed.shared.WithProperties;
+import org.apache.cassandra.sidecar.testing.JvmDTestSharedClassesPredicate;
import org.apache.cassandra.sidecar.testing.QualifiedName;
import org.apache.cassandra.testing.TestVersion;
import org.apache.spark.sql.DataFrameReader;
@@ -138,6 +139,7 @@ class ClearSnapshotTest extends SharedClusterSparkIntegrationTestBase
.withVersion(requestedVersion)
.withDataDirCount(1)
.withDCs(1)
+ .withSharedClasses(JvmDTestSharedClassesPredicate.INSTANCE)
.withConfig(config -> config.with(Feature.NATIVE_PROTOCOL)
.with(Feature.GOSSIP)
.with(Feature.JMX));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org