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

Fix remote DEV tests after breaking package config changes #1070

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 @@ -15,7 +15,8 @@
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "Windows does not support long file paths")
public class QuickstartUsingUsingUberJarIT {

@GitRepositoryQuarkusApplication(repo = "https://github.com/quarkusio/quarkus-quickstarts.git", contextDir = "getting-started", mavenArgs = "-Dquarkus.package.type=uber-jar -DskipTests=true -Dquarkus.platform.group-id=${QUARKUS_PLATFORM_GROUP-ID} -Dquarkus.platform.version=${QUARKUS_PLATFORM_VERSION}")
// TODO: drop config key quarkus.package.type when Quarkus is bumped to 3.10
@GitRepositoryQuarkusApplication(repo = "https://github.com/quarkusio/quarkus-quickstarts.git", contextDir = "getting-started", mavenArgs = "-Dquarkus.package.jar.type=uber-jar -Dquarkus.package.type=uber-jar -DskipTests=true -Dquarkus.platform.group-id=${QUARKUS_PLATFORM_GROUP-ID} -Dquarkus.platform.version=${QUARKUS_PLATFORM_VERSION}")
static final RestService app = new RestService();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
public class TodoDemoIT {
private static final String REPO = "https://github.com/quarkusio/todo-demo-app.git";
private static final String DEFAULT_ARGS = "-DskipTests=true -Dquarkus.platform.group-id=${QUARKUS_PLATFORM_GROUP-ID} -Dquarkus.platform.version=${QUARKUS_PLATFORM_VERSION} ";
private static final String UBER = "-Dquarkus.package.type=uber-jar ";
// TODO: drop config key quarkus.package.type when Quarkus is bumped to 3.10
private static final String UBER = "-Dquarkus.package.type=uber-jar -Dquarkus.package.jar.type=uber-jar ";

@GitRepositoryQuarkusApplication(repo = REPO, mavenArgs = DEFAULT_ARGS + UBER)
static final RestService app = new RestService();
Expand Down
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
<execution>
<configuration>
<systemProperties>
<quarkus.native.enabled>${quarkus.native.enabled}</quarkus.native.enabled>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<quarkus.package.type>${quarkus.package.type}</quarkus.package.type>
michalvavrik marked this conversation as resolved.
Show resolved Hide resolved
<quarkus.native.container-build>${quarkus.native.container-build}</quarkus.native.container-build>
Expand All @@ -448,6 +449,8 @@
</plugins>
</build>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
<!-- TODO: drop next line when Quarkus is bumped to 3.10 -->
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.container-build>true</quarkus.native.container-build>
<quarkus.native.native-image-xmx>5g</quarkus.native.native-image-xmx>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public abstract class AbstractQuarkusScenarioContainerExecutionCondition impleme
+ " Linux containers");
public static final String ENV_DOES_NOT_SUPPORT_LINUX_CONTAINERS = "Test class '%s' requires Linux containers, "
+ "but the environment does not support them";
private static final Logger LOG = Logger.getLogger(AbstractQuarkusScenarioContainerExecutionCondition.class.getName());
private static final ConditionEvaluationResult CONDITION_NOT_MATCHED = enabled("This condition should "
static final ConditionEvaluationResult CONDITION_NOT_MATCHED = enabled("This condition should "
+ "only be applied on test classes annotated with the '@QuarkusScenario' annotation");
private static final Logger LOG = Logger.getLogger(AbstractQuarkusScenarioContainerExecutionCondition.class.getName());
private static final String LINUX_CONTAINERS_NOT_REQUIRED = "Test class '%s' does not require containers";
private static final String LINUX_CONTAINER_OS_TYPE = "linux";
private static final String PODMAN = "podman";
Expand Down Expand Up @@ -109,7 +109,7 @@ private static boolean isPodman() {
}
}

private static boolean isQuarkusScenario(AnnotatedElement annotatedElement) {
static boolean isQuarkusScenario(AnnotatedElement annotatedElement) {
return annotatedElement.isAnnotationPresent(QuarkusScenario.class);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.quarkus.test.scenarios.execution.condition;

import static io.quarkus.test.scenarios.execution.condition.AbstractQuarkusScenarioContainerExecutionCondition.CONDITION_NOT_MATCHED;
import static io.quarkus.test.services.quarkus.model.QuarkusProperties.isNativePackageType;

import java.lang.reflect.Modifier;
import java.util.Arrays;

import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExtensionContext;

import io.quarkus.test.services.DevModeQuarkusApplication;
import io.quarkus.test.services.RemoteDevModeQuarkusApplication;

public class DisableDevModeTestsInNativeExecutionCondition implements QuarkusScenarioExecutionCondition {

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
return context
.getElement()
.filter(AbstractQuarkusScenarioContainerExecutionCondition::isQuarkusScenario)
.map(clazz -> (Class<?>) clazz)
.map(DisableDevModeTestsInNativeExecutionCondition::evaluate)
.orElse(CONDITION_NOT_MATCHED);
}

private static ConditionEvaluationResult evaluate(Class<?> testClass) {
if (isNativePackageType() && isDevModeTest(testClass)) {
return ConditionEvaluationResult.disabled("DEV mode tests can't be run when native mode is enabled");
} else {
return ConditionEvaluationResult.enabled("Not a DEV mode test in native mode");
}
}

private static boolean isDevModeTest(Class<?> testClass) {
return Arrays.stream(testClass.getDeclaredFields())
.filter(m -> Modifier.isStatic(m.getModifiers()))
.anyMatch(m -> m.isAnnotationPresent(RemoteDevModeQuarkusApplication.class)
|| m.isAnnotationPresent(DevModeQuarkusApplication.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ public final class QuarkusProperties {
public static final PropertyLookup PLATFORM_GROUP_ID = new PropertyLookup("quarkus.platform.group-id", "io.quarkus");
public static final PropertyLookup PLATFORM_VERSION = new PropertyLookup("quarkus.platform.version");
public static final PropertyLookup PLUGIN_VERSION = new PropertyLookup("quarkus-plugin.version");
public static final PropertyLookup NATIVE_ENABLED = new PropertyLookup("quarkus.native.enabled");
public static final String QUARKUS_ANALYTICS_DISABLED_LOCAL_PROP_KEY = "quarkus.analytics.disabled";
public static final PropertyLookup QUARKUS_ANALYTICS_DISABLED_LOCAL_PROP = new PropertyLookup(
QUARKUS_ANALYTICS_DISABLED_LOCAL_PROP_KEY, "true");
public static final String PACKAGE_TYPE_NAME = "quarkus.package.type";
// TODO: drop ternary operator when Quarkus version is bumped to 3.10
public static final String PACKAGE_TYPE_NAME = defaultVersionIfEmpty(PLATFORM_VERSION.get()).startsWith("3.9.")
? "quarkus.package.type"
: "quarkus.package.jar.type";
public static final String MUTABLE_JAR = "mutable-jar";
public static final PropertyLookup PACKAGE_TYPE = new PropertyLookup(PACKAGE_TYPE_NAME);
public static final List<String> PACKAGE_TYPE_NATIVE_VALUES = Arrays.asList("native", "native-sources");
Expand Down Expand Up @@ -45,19 +49,25 @@ public static boolean disableBuildAnalytics() {
}

public static boolean isNativePackageType() {
return PACKAGE_TYPE_NATIVE_VALUES.contains(PACKAGE_TYPE.get());
// TODO: simplify condition when Quarkus version is bumped to 3.10
return isNativeEnabled() || PACKAGE_TYPE_NATIVE_VALUES.contains(PACKAGE_TYPE.get());
}

public static boolean isNativePackageType(ServiceContext context) {
return PACKAGE_TYPE_NATIVE_VALUES.contains(PACKAGE_TYPE.get(context));
// TODO: simplify condition when Quarkus version is bumped to 3.10
return isNativeEnabled() || PACKAGE_TYPE_NATIVE_VALUES.contains(PACKAGE_TYPE.get(context));
}

public static boolean isNativeEnabled() {
return Boolean.parseBoolean(NATIVE_ENABLED.get());
}

public static boolean isLegacyJarPackageType(ServiceContext context) {
return PACKAGE_TYPE_LEGACY_JAR_VALUES.contains(PACKAGE_TYPE.get(context));
return !isNativeEnabled() && PACKAGE_TYPE_LEGACY_JAR_VALUES.contains(PACKAGE_TYPE.get(context));
}

public static boolean isJvmPackageType(ServiceContext context) {
return PACKAGE_TYPE_JVM_VALUES.contains(PACKAGE_TYPE.get(context));
return !isNativeEnabled() && PACKAGE_TYPE_JVM_VALUES.contains(PACKAGE_TYPE.get(context));
}

private static String defaultVersionIfEmpty(String version) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
io.quarkus.test.scenarios.execution.condition.AnnotationBindingQuarkusScenarioContainerExecutionCondition
io.quarkus.test.scenarios.execution.condition.AnnotationBindingQuarkusScenarioContainerExecutionCondition
io.quarkus.test.scenarios.execution.condition.DisableDevModeTestsInNativeExecutionCondition
3 changes: 3 additions & 0 deletions quarkus-test-core/src/main/resources/build-time-list
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ quarkus.resteasy-client-oidc-token-propagation.enabled
quarkus.oidc.enabled
quarkus.openshift.
quarkus.otel.enabled
FIXME: drop next line when Quarkus version is bumped to 3.10
quarkus.package.type
michalvavrik marked this conversation as resolved.
Show resolved Hide resolved
quarkus.package.jar.type
quarkus.native.enabled
quarkus.messaging.health.enabled
quarkus.messaging.kafka.serializer-autodetection.enabled
quarkus.messaging.metrics.enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Before building the container image run:
#
# ./mvnw package -Dquarkus.package.type=legacy-jar
# ./mvnw package -Dquarkus.package.jar.type=legacy-jar
#
# Then, build the image with:
#
Expand Down