Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x: Reenable TabletsIT #364

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.datastax.driver.core.exceptions.SyntaxError;
import com.datastax.driver.core.utils.ScyllaOnly;
import com.datastax.driver.core.utils.ScyllaSkip;
import com.datastax.driver.core.utils.ScyllaVersion;
import java.nio.ByteBuffer;
import java.util.Map;
import org.testng.Assert;
Expand All @@ -17,7 +17,7 @@
"--experimental-features=tablets"
})
@ScyllaOnly
@ScyllaSkip // There is no released version with tablets-routing-v1 currently
@ScyllaVersion(minOSS = "6.0.0", minEnterprise = "2024.2", description = "Needs to support tablets")
public class TabletsIT extends CCMTestsSupport {

private static final int INITIAL_TABLETS = 32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import com.datastax.driver.core.utils.DseVersion;
import com.datastax.driver.core.utils.ScyllaOnly;
import com.datastax.driver.core.utils.ScyllaSkip;
import com.datastax.driver.core.utils.ScyllaVersion;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
Expand Down Expand Up @@ -144,6 +146,11 @@ private boolean scanAnnotatedElement(AnnotatedElement element) {
dseVersionCheck(dseVersion);
foundAnnotation = true;
}
if (element.isAnnotationPresent(ScyllaVersion.class)) {
ScyllaVersion scyllaVersion = element.getAnnotation(ScyllaVersion.class);
scyllaVersionCheck(scyllaVersion);
foundAnnotation = true;
}
return foundAnnotation;
}

Expand Down Expand Up @@ -172,6 +179,57 @@ private static void dseVersionCheck(DseVersion version) {
}
}

private static void scyllaVersionCheck(ScyllaVersion annotation) {
VersionNumber configuredVersion = CCMBridge.getGlobalScyllaVersion();
if (configuredVersion == null) {
throw new SkipException(
"Skipping test because provided Scylla version is null and the test requires Scylla.");
}
boolean isEnterprise = String.valueOf(configuredVersion.getMajor()).matches("\\d{4}");

if (isEnterprise) {
if (!annotation.minEnterprise().isEmpty()) {
VersionNumber minVersion =
Objects.requireNonNull(VersionNumber.parse(annotation.minEnterprise()));
if (minVersion.compareTo(configuredVersion) > 0) {
throw new SkipException(
String.format(
"Version >= %s required, but found %s. Justification: %s",
minVersion, configuredVersion, annotation.description()));
}
}
if (!annotation.maxEnterprise().isEmpty()) {
VersionNumber maxVersion =
Objects.requireNonNull(VersionNumber.parse(annotation.maxEnterprise()));
if (maxVersion.compareTo(configuredVersion) <= 0) {
throw new SkipException(
String.format(
"Version < %s required, but found %s. Justification: %s",
maxVersion, configuredVersion, annotation.description()));
}
}
} else {
if (!annotation.minOSS().isEmpty()) {
VersionNumber minVersion = Objects.requireNonNull(VersionNumber.parse(annotation.minOSS()));
if (minVersion.compareTo(configuredVersion) > 0) {
throw new SkipException(
String.format(
"Version >= %s required, but found %s. Justification: %s",
minVersion, configuredVersion, annotation.description()));
}
}
if (!annotation.maxOSS().isEmpty()) {
VersionNumber maxVersion = Objects.requireNonNull(VersionNumber.parse(annotation.maxOSS()));
if (maxVersion.compareTo(configuredVersion) <= 0) {
throw new SkipException(
String.format(
"Version < %s required, but found %s. Justification: %s",
maxVersion, configuredVersion, annotation.description()));
}
}
}
}

private static void scyllaSkipCheck() {
if (CCMBridge.getGlobalScyllaVersion() != null) {
throw new SkipException("Skipping test because it is disabled for Scylla cluster.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.datastax.driver.core.utils;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* Annotation for a Class or Method that defines a Scylla Version requirement. If the Scylla version
* in use does not meet the version requirement, the test is skipped.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface ScyllaVersion {
/** @return The minimum Enterprise version required to execute this test, i.e. "2020.1.13" */
String minEnterprise() default "";

/**
* @return the maximum exclusive Enterprise version allowed to execute this test, i.e. "2021.1.12"
* means only tests &lt; "2021.1.12" may execute this test.
*/
String maxEnterprise() default "";

/** @return The minimum OSS version required to execute this test, i.e. "4.5.6" */
String minOSS() default "";

/**
* @return the maximum exclusive OSS version allowed to execute this test, i.e. "5.0.0" means only
* tests &lt; "5.0.0" may execute this test.
*/
String maxOSS() default "";

/** @return The description returned if this version requirement is not met. */
String description() default "Does not meet Scylla version requirement.";
}
Loading