Skip to content

Commit 53fed45

Browse files
Bouncheckavelanarius
authored andcommitted
Add @ScyllaOnly annotation
Needed for Scylla Cloud tests which won't work with cassandra ccm clusters.
1 parent 87fb26a commit 53fed45

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

driver-core/src/test/java/com/datastax/driver/core/ScyllaSniProxyTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
import static org.mockito.Mockito.times;
1111
import static org.mockito.Mockito.verify;
1212

13+
import com.datastax.driver.core.utils.ScyllaOnly;
1314
import java.util.Collection;
1415
import org.testng.annotations.Test;
1516

1617
@CreateCCM(CreateCCM.TestMode.PER_METHOD)
18+
@ScyllaOnly
1719
public class ScyllaSniProxyTest extends CCMTestsSupport {
1820

1921
private void test_ccm_cluster(int testNodes) {

driver-core/src/test/java/com/datastax/driver/core/TestListener.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.datastax.driver.core.utils.CassandraVersion;
2525
import com.datastax.driver.core.utils.DseVersion;
26+
import com.datastax.driver.core.utils.ScyllaOnly;
2627
import com.datastax.driver.core.utils.ScyllaSkip;
2728
import java.lang.reflect.AnnotatedElement;
2829
import java.lang.reflect.Method;
@@ -129,6 +130,10 @@ private boolean scanAnnotatedElement(AnnotatedElement element) {
129130
scyllaSkipCheck();
130131
foundAnnotation = true;
131132
}
133+
if (element.isAnnotationPresent(ScyllaOnly.class)) {
134+
scyllaOnlyCheck();
135+
foundAnnotation = true;
136+
}
132137
if (element.isAnnotationPresent(CassandraVersion.class)) {
133138
CassandraVersion cassandraVersion = element.getAnnotation(CassandraVersion.class);
134139
cassandraVersionCheck(cassandraVersion);
@@ -173,6 +178,12 @@ private static void scyllaSkipCheck() {
173178
}
174179
}
175180

181+
private static void scyllaOnlyCheck() {
182+
if (CCMBridge.getGlobalScyllaVersion() == null) {
183+
throw new SkipException("Skipping test because it is enabled only for Scylla cluster.");
184+
}
185+
}
186+
176187
private static void versionCheck(
177188
VersionNumber current, VersionNumber required, String skipString) {
178189
if (current == null) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2022 ScyllaDB
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.datastax.driver.core.utils;
18+
19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
21+
22+
/**
23+
* Annotation for a Class or Method that skips a test when NOT testing with Scylla.
24+
*
25+
* @see com.datastax.driver.core.TestListener#beforeInvocation(org.testng.IInvokedMethod,
26+
* org.testng.ITestResult)
27+
*/
28+
@Retention(RetentionPolicy.RUNTIME)
29+
public @interface ScyllaOnly {
30+
/** @return The description returned if the Scylla requirement is not met. */
31+
String description() default "Marked skip when not testing with Scylla.";
32+
}

0 commit comments

Comments
 (0)