-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix IT main for GraalVM >= 22.1 #24767
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
...n-tests/main/src/main/java/io/quarkus/it/corestuff/serialization/SerializationConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| package io.quarkus.it.corestuff.serialization; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import io.quarkus.runtime.annotations.RegisterForReflection; | ||
|
|
||
| @RegisterForReflection(targets = { List.class, ArrayList.class, String.class }, serialization = true) | ||
| @RegisterForReflection(targets = { ArrayList.class, String.class }, serialization = true) | ||
| public class SerializationConfig { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...mework/junit5/src/main/java/io/quarkus/test/junit/DisableIfBuiltWithGraalVMNewerThan.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package io.quarkus.test.junit; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
|
|
||
| /** | ||
| * Used to signal that a test class or method should be disabled if the version of GraalVM used to build the native binary | ||
| * under test was older than the supplied version. | ||
| * | ||
| * This annotation should only be used on a test classes annotated with {@link NativeImageTest} or | ||
| * {@link QuarkusIntegrationTest}. If it is used on other test classes, it will have no effect. | ||
| */ | ||
| @Target({ ElementType.TYPE, ElementType.METHOD }) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @ExtendWith(DisableIfBuiltWithGraalVMNewerThanCondition.class) | ||
| public @interface DisableIfBuiltWithGraalVMNewerThan { | ||
| GraalVMVersion value(); | ||
| } |
67 changes: 67 additions & 0 deletions
67
...nit5/src/main/java/io/quarkus/test/junit/DisableIfBuiltWithGraalVMNewerThanCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package io.quarkus.test.junit; | ||
|
|
||
| import static io.quarkus.test.junit.IntegrationTestUtil.readQuarkusArtifactProperties; | ||
| import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation; | ||
|
|
||
| import java.lang.annotation.Annotation; | ||
| import java.lang.reflect.AnnotatedElement; | ||
| import java.util.Optional; | ||
| import java.util.Properties; | ||
| import java.util.Set; | ||
|
|
||
| import org.junit.jupiter.api.extension.ConditionEvaluationResult; | ||
| import org.junit.jupiter.api.extension.ExecutionCondition; | ||
| import org.junit.jupiter.api.extension.ExtensionContext; | ||
|
|
||
| public class DisableIfBuiltWithGraalVMNewerThanCondition implements ExecutionCondition { | ||
|
|
||
| private static final String QUARKUS_INTEGRATION_TEST_NAME = QuarkusIntegrationTest.class.getName(); | ||
| private static final String NATIVE_IMAGE_TEST_NAME = NativeImageTest.class.getName(); | ||
| private static final Set<String> SUPPORTED_INTEGRATION_TESTS = Set.of(QUARKUS_INTEGRATION_TEST_NAME, | ||
| NATIVE_IMAGE_TEST_NAME); | ||
|
|
||
| @Override | ||
| public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { | ||
| Optional<AnnotatedElement> element = context.getElement(); | ||
| Optional<DisableIfBuiltWithGraalVMNewerThan> optional = findAnnotation(element, | ||
| DisableIfBuiltWithGraalVMNewerThan.class); | ||
| if (!optional.isPresent()) { | ||
| return ConditionEvaluationResult.enabled("@DisableIfBuiltWithGraalVMNewerThan was not found"); | ||
| } | ||
| if (!isIntegrationTest(context.getRequiredTestClass())) { | ||
| return ConditionEvaluationResult.enabled("@DisableIfBuiltWithGraalVMNewerThan was added to an unsupported test"); | ||
| } | ||
|
|
||
| GraalVMVersion annotationValue = optional.get().value(); | ||
| Properties quarkusArtifactProperties = readQuarkusArtifactProperties(context); | ||
| try { | ||
| org.graalvm.home.Version version = org.graalvm.home.Version | ||
| .parse(quarkusArtifactProperties.getProperty("metadata.graalvm.version.version")); | ||
| int comparison = annotationValue.compareTo(version); | ||
| if (comparison < 0) { | ||
| return ConditionEvaluationResult.disabled("Native binary was built with GraalVM{version=" + version.toString() | ||
| + "} but the test is disabled for GraalVM versions newer than " + annotationValue); | ||
| } | ||
| return ConditionEvaluationResult | ||
| .enabled("Native binary was built with a GraalVM version compatible with the required version by the test"); | ||
| } catch (NumberFormatException e) { | ||
| return ConditionEvaluationResult | ||
| .disabled("Unable to determine the GraalVM version with which the native binary was built"); | ||
| } | ||
| } | ||
|
|
||
| private boolean isIntegrationTest(Class<?> testClass) { | ||
| do { | ||
| Annotation[] annotations = testClass.getAnnotations(); | ||
| for (Annotation annotation : annotations) { | ||
| Class<? extends Annotation> annotationType = annotation.annotationType(); | ||
| String annotationTypeName = annotationType.getName(); | ||
| if (SUPPORTED_INTEGRATION_TESTS.contains(annotationTypeName)) { | ||
| return true; | ||
| } | ||
| } | ||
| testClass = testClass.getSuperclass(); | ||
| } while (testClass != Object.class); | ||
| return false; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test-framework/junit5/src/main/java/io/quarkus/test/junit/GraalVMVersion.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package io.quarkus.test.junit; | ||
|
|
||
| public enum GraalVMVersion { | ||
| GRAALVM_21_0(org.graalvm.home.Version.create(21, 0)), | ||
| GRAALVM_22_0(org.graalvm.home.Version.create(22, 0)), | ||
| GRAALVM_22_1(org.graalvm.home.Version.create(22, 1)); | ||
|
|
||
| private final org.graalvm.home.Version version; | ||
|
|
||
| GraalVMVersion(org.graalvm.home.Version version) { | ||
| this.version = version; | ||
| } | ||
|
|
||
| public org.graalvm.home.Version getVersion() { | ||
| return version; | ||
| } | ||
|
|
||
| /** | ||
| * Compares this version with another GraalVM version | ||
| * | ||
| * @return {@code -1} if this version is older than the other version, | ||
| * {@code +1} if it's newer and {@code 0} if they represent the same version | ||
| */ | ||
| public int compareTo(org.graalvm.home.Version version) { | ||
| return this.version.compareTo(version); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "GraalVMVersion{" + | ||
| "version=" + version.toString() + | ||
| '}'; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.