Skip to content

Commit 84f1bb6

Browse files
authored
Skip DSE integration tests if we're not on amd64 (#226)
* Initial take on a JUnit skip annotation * Formatting fixes * Working build on arm64 platform * Swap to an inherited annotation instead
1 parent 14480be commit 84f1bb6

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

integration-tests/dse/src/test/java/com/datastax/oss/quarkus/tests/DseTestBase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.datastax.oss.quarkus.tests;
1717

1818
import com.datastax.oss.quarkus.test.CassandraTestResource;
19+
import com.datastax.oss.quarkus.test.SkipIfNotAmd64;
1920
import io.quarkus.test.common.QuarkusTestResource;
2021
import io.quarkus.test.common.ResourceArg;
2122

@@ -29,4 +30,5 @@
2930
@ResourceArg(name = "quarkus.cassandra.test.container.cmd", value = "-g"),
3031
@ResourceArg(name = "quarkus.cassandra.test.container.startup-timeout", value = "PT5M")
3132
})
33+
@SkipIfNotAmd64
3234
public abstract class DseTestBase {}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright DataStax, Inc.
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+
package com.datastax.oss.quarkus.test;
17+
18+
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
19+
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
20+
import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;
21+
22+
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
23+
import org.junit.jupiter.api.extension.ExecutionCondition;
24+
import org.junit.jupiter.api.extension.ExtensionContext;
25+
26+
public class CheckAmd64Condition implements ExecutionCondition {
27+
28+
@Override
29+
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
30+
final var optional = findAnnotation(context.getElement(), SkipIfNotAmd64.class);
31+
return optional
32+
.map(
33+
(ann) -> {
34+
String archStr = System.getProperty("os.arch");
35+
return archStr.equals("amd64")
36+
? enabled("amd64 architecture found")
37+
: disabled(String.format("{} architecture found, skipping test", archStr));
38+
})
39+
.orElse(enabled("No annotation, not checking platform"));
40+
}
41+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright DataStax, Inc.
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+
package com.datastax.oss.quarkus.test;
17+
18+
import java.lang.annotation.Inherited;
19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
21+
import org.junit.jupiter.api.extension.ExtendWith;
22+
23+
@Retention(RetentionPolicy.RUNTIME)
24+
@ExtendWith(CheckAmd64Condition.class)
25+
@Inherited
26+
public @interface SkipIfNotAmd64 {}

0 commit comments

Comments
 (0)