add testDiagStatus() to OpenFlowPluginWiringTest
authorMichael Vorburger <mike@vorburger.ch>
Fri, 21 Dec 2018 00:47:08 +0000 (01:47 +0100)
committerMichael Vorburger <mike@vorburger.ch>
Wed, 1 Jul 2020 23:38:31 +0000 (01:38 +0200)
to "prove" that those asynchronously initialized ports really came up

This requires changes in infrautils as well as openflowplugin:

* https://git.opendaylight.org/gerrit/#/c/78897/

*  https://git.opendaylight.org/gerrit/78898

Signed-off-by: Michael Vorburger <mike@vorburger.ch>
src/test/java/org/opendaylight/openflowplugin/simple/test/OpenFlowPluginModuleTest.java

index 9fe1e5e1c1a72d054fa1e719a273064da23760e9..9e1a817a58d81319538c961fdf46139279770f40 100644 (file)
@@ -9,11 +9,17 @@ package org.opendaylight.openflowplugin.simple.test;
 
 import static com.google.common.truth.Truth.assertThat;
 
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import javax.inject.Inject;
+import junit.framework.AssertionFailedError;
 import org.junit.Rule;
 import org.junit.Test;
 import org.opendaylight.aaa.web.testutils.WebTestModule;
 import org.opendaylight.controller.simple.InMemoryControllerModule;
+import org.opendaylight.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.infrautils.diagstatus.ServiceStatusSummary;
 import org.opendaylight.infrautils.inject.guice.GuiceClassPathBinder;
 import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
@@ -21,6 +27,7 @@ import org.opendaylight.infrautils.ready.guice.ReadyModule;
 import org.opendaylight.infrautils.simple.DiagStatusModule;
 import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
+import org.opendaylight.openflowplugin.impl.OpenFlowPluginProviderImpl;
 import org.opendaylight.openflowplugin.simple.OpenFlowPluginModule;
 import org.opendaylight.serviceutils.simple.ServiceUtilsModule;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
@@ -40,9 +47,21 @@ public class OpenFlowPluginModuleTest extends AbstractSimpleDistributionTest {
     @Inject OpenflowProviderConfig ofpConfig;
     @Inject ForwardingRulesManagerConfig frmConfig;
 
+    @Inject OpenFlowPluginProviderImpl openFlowPluginProviderImpl;
+    @Inject DiagStatusService diagStatus;
+
     @Test public void testConfig() throws InterruptedException {
         assertThat(ofpConfig.getGlobalNotificationQuota()).named("globalNotificationQuota").isEqualTo(64000L);
         assertThat(frmConfig.getReconciliationRetryCount()).named("reconciliationRetryCount").isEqualTo(5);
     }
 
+    @Test public void testDiagStatus() throws InterruptedException, ExecutionException, TimeoutException {
+        openFlowPluginProviderImpl.getFullyStarted().get(60, TimeUnit.SECONDS);
+        ServiceStatusSummary status = diagStatus.getServiceStatusSummary();
+        if (!status.isOperational()) {
+            throw new AssertionFailedError(
+                    "diagStatus reports non operational, details: " + status);
+        }
+    }
+
 }