From 013c40096e0de36c43f8d5211c4a7848578e5c89 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 8 Aug 2024 21:58:43 +0200 Subject: [PATCH] Simplify TestProbe property passing Rather than defining a property in our VM and using propagateSystemProperties(), use direct systemProperty() call. Change-Id: I2076fa17d2c34434807e9e517f7fb7ae05b4dd4c Signed-off-by: Robert Varga --- .../features/test/plugin/PaxOptionUtils.java | 5 ----- .../features/test/plugin/TestFeaturesMojo.java | 18 +++++++++++------- .../features/test/plugin/TestProbe.java | 13 +++---------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/PaxOptionUtils.java b/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/PaxOptionUtils.java index b386ba2fc..5767ccb85 100644 --- a/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/PaxOptionUtils.java +++ b/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/PaxOptionUtils.java @@ -12,7 +12,6 @@ import static org.opendaylight.odlparent.features.test.plugin.DependencyUtils.RE import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages; import static org.ops4j.pax.exam.CoreOptions.maven; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties; import static org.ops4j.pax.exam.CoreOptions.systemPackages; import static org.ops4j.pax.exam.CoreOptions.when; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; @@ -165,10 +164,6 @@ final class PaxOptionUtils { .toArray(Option[]::new); } - static Option[] probePropertiesOptions() { - return new Option[]{propagateSystemProperties(TestProbe.ALL_PROPERTY_KEYS)}; - } - private static MavenArtifactUrlReference urlReferenceOf(final Artifact artifact) { return maven().groupId(artifact.getGroupId()).artifactId(artifact.getArtifactId()) .type(artifact.getExtension()).classifier(artifact.getClassifier()) diff --git a/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestFeaturesMojo.java b/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestFeaturesMojo.java index 0e1358d37..f3a691c44 100644 --- a/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestFeaturesMojo.java +++ b/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestFeaturesMojo.java @@ -12,9 +12,9 @@ import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.dep import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.karafConfigOptions; import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.karafDistroOptions; import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.miscOptions; -import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.probePropertiesOptions; import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.profileOptions; import static org.opendaylight.odlparent.features.test.plugin.PaxOptionUtils.vmOptions; +import static org.ops4j.pax.exam.CoreOptions.systemProperty; import java.io.File; import java.io.IOException; @@ -36,6 +36,7 @@ import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.repository.RemoteRepository; import org.ops4j.pax.exam.ExamSystem; +import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.karaf.container.internal.KarafTestContainerFactory; import org.ops4j.pax.exam.spi.PaxExamRuntime; import org.slf4j.Logger; @@ -158,15 +159,18 @@ public final class TestFeaturesMojo extends AbstractMojo { karafConfigOptions(buildDir, localRepository), dependencyFeaturesOptions(pluginDependencyFeatures), dependencyFeaturesOptions(projectDependencyFeatures), - probePropertiesOptions(), + + // probe parameters + new Option[] { + systemProperty(TestProbe.FEATURE_FILE_URI_PROP).value(featureFile.toURI().toString()), + systemProperty(TestProbe.BUNDLE_CHECK_SKIP).value(String.valueOf(bundleStateCheckSkip)), + systemProperty(TestProbe.BUNDLE_CHECK_TIMEOUT_SECONDS).value(String.valueOf(bundleStateCheckTimeout)), + systemProperty(TestProbe.BUNDLE_CHECK_INTERVAL_SECONDS).value(String.valueOf(bundleStateCheckInterval)) + }, + miscOptions() ); - // probe parameters - System.setProperty(TestProbe.FEATURE_FILE_URI_PROP, featureFile.toURI().toString()); - System.setProperty(TestProbe.BUNDLE_CHECK_SKIP, String.valueOf(bundleStateCheckSkip)); - System.setProperty(TestProbe.BUNDLE_CHECK_TIMEOUT_SECONDS, String.valueOf(bundleStateCheckTimeout)); - System.setProperty(TestProbe.BUNDLE_CHECK_INTERVAL_SECONDS, String.valueOf(bundleStateCheckInterval)); final ExamSystem system; try { diff --git a/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestProbe.java b/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestProbe.java index 05fb6757d..a6f7dc494 100644 --- a/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestProbe.java +++ b/features-test-plugin/src/main/java/org/opendaylight/odlparent/features/test/plugin/TestProbe.java @@ -32,15 +32,15 @@ import org.slf4j.LoggerFactory; * All dependencies which are absent on target environment expected to be packaged using same * {@link org.ops4j.pax.exam.ProbeBuilder}. Input parameters are passed through system properties. in order to be * delivered properly all affected properties require explicit declaration using associated Pax options -- see - * {@link PaxOptionUtils#probePropertiesOptions()}. + * {@link PaxOptionUtils} and setup in {@link TestFeaturesMojo#execute()}. * *

* Pax Exam module references: *

*/ public final class TestProbe { @@ -73,13 +73,6 @@ public final class TestProbe { static final String DEFAULT_TIMEOUT = "300"; static final String DEFAULT_INTERVAL = "1"; - static final String[] ALL_PROPERTY_KEYS = { - FEATURE_FILE_URI_PROP, - BUNDLE_CHECK_SKIP, - BUNDLE_CHECK_TIMEOUT_SECONDS, - BUNDLE_CHECK_INTERVAL_SECONDS - }; - private static final Logger LOG = LoggerFactory.getLogger(TestProbe.class); private static final Map ELIGIBLE_STATES = Map.of( "slf4j.log4j12", ContainerState.INSTALLED, -- 2.36.6