Add -Dsft.diag.timeout=... option to SingleFeatureTest BundleDiagInfos 74/50674/2
authorMichael Vorburger <vorburger@redhat.com>
Thu, 19 Jan 2017 14:51:07 +0000 (15:51 +0100)
committerStephen Kitt <skitt@redhat.com>
Mon, 23 Jan 2017 08:48:35 +0000 (08:48 +0000)
This is useful when locally debugging issues, and you don't want to wait
too long for the bundle convergence to eventually succeed (because you
already know there is a problem).  The worst case default of 5 minutes
for the build is still a good idea, though.

This also tunes the pollInterval from 250ms to 1s, which is sufficient,
and leads to less noise in the log.

This also fixes -Dsft.diag.skip=true, which didn't actually work
(becaues of a missing PropagateSystemPropertyOption).

Change-Id: I8c7bae10295ddef57c0869628789949d991456e3
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
bundles-test/src/main/java/org/opendaylight/odlparent/bundlestest/TestBundleDiag.java
features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java

index 1c1c92c7007aafa9283492e237392965d093ca03..4d72552febc8c65a2b2ec5fd2be496fab7008f78 100644 (file)
@@ -8,9 +8,10 @@
 package org.opendaylight.odlparent.bundlestest;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.junit.Assert.fail;
 
+import java.util.concurrent.TimeUnit;
 import org.apache.karaf.bundle.core.BundleService;
 import org.awaitility.Awaitility;
 import org.awaitility.core.ConditionTimeoutException;
@@ -47,16 +48,16 @@ public class TestBundleDiag {
      *
      * @author Michael Vorburger, based on guidance from Christian Schneider
      */
-    public void checkBundleDiagInfos() {
+    public void checkBundleDiagInfos(long timeout, TimeUnit timeoutUnit) {
         try {
             Awaitility.await("checkBundleDiagInfos")
                 .pollDelay(0, MILLISECONDS)
-                .pollInterval(250, MILLISECONDS)
-                .atMost(5, MINUTES)
+                .pollInterval(1, SECONDS)
+                .atMost(timeout, timeoutUnit)
                     .conditionEvaluationListener(
-                        condition -> LOG.info("{} (elapsed time {}ms, remaining time {}ms)",
+                        condition -> LOG.info("{} (elapsed time {}s, remaining time {}s)",
                             ((BundleDiagInfos) condition.getValue()).getSummaryText(),
-                            condition.getElapsedTimeInMS(), condition.getRemainingTimeInMS()))
+                            condition.getElapsedTimeInMS() / 1000, condition.getRemainingTimeInMS() / 1000 ))
                     .until(() -> getBundleDiagInfos(), new BundleServiceSummaryMatcher());
 
             // If we're here then either BundleServiceSummaryMatcher quit because of Active, Failure or Stopping..
index 608c6f2788bc7b395f683e5e8ffec1f9e5a701b8..fb784ada020055d804ad2398c91f6caec62f42a5 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.odlparent.featuretest;
 
+import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.opendaylight.odlparent.featuretest.Constants.ORG_OPENDAYLIGHT_FEATURETEST_FEATURENAME_PROP;
 import static org.opendaylight.odlparent.featuretest.Constants.ORG_OPENDAYLIGHT_FEATURETEST_FEATUREVERSION_PROP;
 import static org.opendaylight.odlparent.featuretest.Constants.ORG_OPENDAYLIGHT_FEATURETEST_URI_PROP;
@@ -50,6 +51,7 @@ import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.options.PropagateSystemPropertyOption;
 import org.ops4j.pax.exam.options.extra.VMOption;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -67,6 +69,7 @@ public class SingleFeatureTest {
     private static final String KEEP_UNPACK_DIRECTORY_PROP = "karaf.keep.unpack";
     private static final String PROFILE_PROP = "karaf.featureTest.profile";
     private static final String BUNDLES_DIAG_SKIP_PROP = "sft.diag.skip";
+    private static final String BUNDLES_DIAG_TIMEOUT_PROP = "sft.diag.timeout";
 
     private static final String LOG4J_LOGGER_ORG_OPENDAYLIGHT_YANGTOOLS_FEATURETEST =
             "log4j.logger.org.opendaylight.odlparent.featuretest";
@@ -182,12 +185,11 @@ public class SingleFeatureTest {
               *
               */
             disableExternalSnapshotRepositories(),
-            CoreOptions.systemProperty(ORG_OPENDAYLIGHT_FEATURETEST_URI_PROP).value(
-                    System.getProperty(ORG_OPENDAYLIGHT_FEATURETEST_URI_PROP)),
-            CoreOptions.systemProperty(ORG_OPENDAYLIGHT_FEATURETEST_FEATURENAME_PROP).value(
-                    System.getProperty(ORG_OPENDAYLIGHT_FEATURETEST_FEATURENAME_PROP)),
-            CoreOptions.systemProperty(ORG_OPENDAYLIGHT_FEATURETEST_FEATUREVERSION_PROP).value(
-                    System.getProperty(ORG_OPENDAYLIGHT_FEATURETEST_FEATUREVERSION_PROP)),
+            new PropagateSystemPropertyOption(ORG_OPENDAYLIGHT_FEATURETEST_URI_PROP),
+            new PropagateSystemPropertyOption(ORG_OPENDAYLIGHT_FEATURETEST_FEATURENAME_PROP),
+            new PropagateSystemPropertyOption(ORG_OPENDAYLIGHT_FEATURETEST_FEATUREVERSION_PROP),
+            new PropagateSystemPropertyOption(BUNDLES_DIAG_SKIP_PROP),
+            new PropagateSystemPropertyOption(BUNDLES_DIAG_TIMEOUT_PROP),
             // Needed for Agrona/aeron.io
             CoreOptions.systemPackages("com.sun.media.sound", "sun.nio.ch"),
         };
@@ -340,7 +342,8 @@ public class SingleFeatureTest {
 
         if (!Boolean.getBoolean(BUNDLES_DIAG_SKIP_PROP)
                 && !BLACKLISTED_BROKEN_FEATURES.contains(getFeatureName())) {
-            new TestBundleDiag(bundleContext, bundleService).checkBundleDiagInfos();
+            Integer timeOutInSeconds = Integer.getInteger(BUNDLES_DIAG_TIMEOUT_PROP, 5 * 60);
+            new TestBundleDiag(bundleContext, bundleService).checkBundleDiagInfos(timeOutInSeconds, SECONDS);
         } else {
             LOG.warn("SKIPPING TestBundleDiag because system property {} is true or feature is blacklisted: {}",
                     BUNDLES_DIAG_SKIP_PROP, getFeatureName());