From fcfa3c7ab2ca90cc9f30852228cac850886bee86 Mon Sep 17 00:00:00 2001 From: Alessandro Solimando Date: Sun, 4 Feb 2024 17:43:10 +0100 Subject: [PATCH] improved execution conditions for Cassandra test --- .../calcite/test/CassandraExtension.java | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/cassandra/src/test/java/org/apache/calcite/test/CassandraExtension.java b/cassandra/src/test/java/org/apache/calcite/test/CassandraExtension.java index 29a30ee4d91d..6bcb9de959f2 100644 --- a/cassandra/src/test/java/org/apache/calcite/test/CassandraExtension.java +++ b/cassandra/src/test/java/org/apache/calcite/test/CassandraExtension.java @@ -17,20 +17,19 @@ package org.apache.calcite.test; import org.apache.calcite.config.CalciteSystemProperty; -import org.apache.calcite.util.Bug; import org.apache.calcite.util.Sources; import org.apache.calcite.util.TestUtil; import org.apache.cassandra.concurrent.Stage; import org.apache.cassandra.config.DatabaseDescriptor; -import org.apache.cassandra.db.WindowsFailedSnapshotTracker; import org.apache.cassandra.service.CassandraDaemon; import org.apache.cassandra.service.StorageService; -import org.apache.cassandra.utils.FBUtilities; import com.datastax.oss.driver.api.core.CqlSession; import com.google.common.collect.ImmutableMap; +import org.apache.commons.lang3.SystemUtils; + import org.cassandraunit.utils.EmbeddedCassandraServerHelper; import org.junit.jupiter.api.extension.ConditionEvaluationResult; import org.junit.jupiter.api.extension.ExecutionCondition; @@ -43,8 +42,6 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.lang.reflect.Field; -import java.nio.file.Files; -import java.nio.file.Paths; import java.time.Duration; import java.util.Locale; import java.util.Objects; @@ -121,34 +118,39 @@ private static CassandraResource getOrCreate(ExtensionContext context) { * {@link com.google.common.collect.ImmutableSet#builderWithExpectedSize(int)} * and therefore Guava 23 or higher. * + *

Cassandra dropped support for Windows in 4.1.x + * @see CASSANDRA-16956 + * * @return {@code true} if test is compatible with current environment, * {@code false} otherwise */ @Override public ConditionEvaluationResult evaluateExecutionCondition( final ExtensionContext context) { boolean enabled = CalciteSystemProperty.TEST_CASSANDRA.value(); - Bug.upgrade("remove JDK version check once cassandra-unit supports JDK11+"); + // remove JDK version check once cassandra-unit supports JDK11+ boolean compatibleJdk = TestUtil.getJavaMajorVersion() < 11; boolean compatibleGuava = TestUtil.getGuavaMajorVersion() >= 23; - // See https://issues.apache.org/jira/browse/CASSANDRA-14883 - Bug.upgrade("remove JVM check once Cassandra supports Eclipse OpenJ9 JVM"); + // remove JVM check once Cassandra supports Eclipse OpenJ9 JVM boolean compatibleJVM = !"Eclipse OpenJ9".equals(TestUtil.getJavaVirtualMachineVendor()); - if (enabled && compatibleJdk && compatibleGuava && compatibleJVM) { + boolean compatibleOS = !SystemUtils.IS_OS_WINDOWS; + if (enabled && compatibleJdk && compatibleGuava && compatibleJVM && compatibleOS) { return ConditionEvaluationResult.enabled("Cassandra tests enabled"); - } else { - final StringBuilder sb = new StringBuilder("Cassandra tests disabled:"); + } - if (!compatibleJdk) { - sb.append("\nJDK11+ is not supported"); - } - if (!compatibleGuava) { - sb.append("\nGuava versions < 23 are not supported"); - } - if (!compatibleJVM) { - sb.append("\nEclipse OpenJ9 JVM is not supported"); - } - return ConditionEvaluationResult.disabled(sb.toString()); + final StringBuilder sb = new StringBuilder("Cassandra tests disabled:"); + if (!compatibleJdk) { + sb.append("\n - JDK11+ is not supported"); } + if (!compatibleGuava) { + sb.append("\n - Guava versions < 23 are not supported"); + } + if (!compatibleJVM) { + sb.append("\n - Eclipse OpenJ9 JVM is not supported"); + } + if (!compatibleOS) { + sb.append("\n - Cassandra doesn't support Windows"); + } + return ConditionEvaluationResult.disabled(sb.toString()); } /** Cassandra resource. */ @@ -187,14 +189,6 @@ private CassandraResource() { Thread.currentThread().interrupt(); } Stage.shutdownNow(); - - if (FBUtilities.isWindows) { - // for some reason .toDelete stale folder is not deleted on cassandra shutdown - // doing it manually here - WindowsFailedSnapshotTracker.resetForTests(); - // manually delete stale file(s) - Files.deleteIfExists(Paths.get(WindowsFailedSnapshotTracker.TODELETEFILE)); - } } private static void startCassandra() { @@ -235,5 +229,4 @@ private static CassandraDaemon extractDaemon() { } } } - }