Fix broken SouthboundIT test 04/18604/2
authorSam Hague <shague@redhat.com>
Sun, 19 Apr 2015 19:30:00 +0000 (15:30 -0400)
committerSam Hague <shague@redhat.com>
Sun, 19 Apr 2015 20:04:47 +0000 (16:04 -0400)
The mdsalUtils field needs to be static becuase each @Test method is a totally new allocation and the value is reaallocated for each test.

Also added some extra debug logs.

Patchset 2: checkstyle

Change-Id: Ic75b5bc25cdf62b1c3daa4ee2fdea487804fb0a9
Signed-off-by: Sam Hague <shague@redhat.com>
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/AbstractConfigTestBase.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundITConstants.java

index fb50e47147337a972ab5c356884eb328b4efdf4b..4a7d1146a437d05b4778004cda2812daf52655b9 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Calendar;
 import javax.management.InstanceNotFoundException;
 
 import org.junit.Rule;
+import org.junit.internal.AssumptionViolatedException;
 import org.junit.rules.TestRule;
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
@@ -131,13 +132,27 @@ public abstract class AbstractConfigTestBase {
     public TestRule watcher = new TestWatcher() {
         @Override
         protected void starting(Description description) {
-            LOG.info("TestWatcher: Starting test: {}",
-                    description.getDisplayName());
+            LOG.info("TestWatcher: Starting test:\n{}", description.getDisplayName());
         }
 
         @Override
         protected void finished(Description description) {
-            LOG.info("TestWatcher: Finished test: {}", description.getDisplayName());
+            LOG.info("TestWatcher: Finished test:\n{}", description.getDisplayName());
+        }
+
+        @Override
+        protected void succeeded(Description description) {
+            LOG.info("TestWatcher: Test succeeded:\n{}", description.getDisplayName());
+        }
+
+        @Override
+        protected void failed(Throwable ex, Description description) {
+            LOG.info("TestWatcher: Test failed:\n{} ", description.getDisplayName(), ex);
+        }
+
+        @Override
+        protected void skipped(AssumptionViolatedException ex, Description description) {
+            LOG.info("TestWatcher: Test skipped:\n{} ", description.getDisplayName(), ex);
         }
     };
 }
index acf7fbe91dbc8113ebe52c30b5656083f0372a39..7323bcfc68ccd79e4056989f026d2c1e6e7e752a 100644 (file)
@@ -81,8 +81,8 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     private static String portStr;
     private static String connectionType;
     private static Boolean setup = false;
-    private MdsalUtils mdsalUtils = null;
-    private String extras = "false";
+    private static MdsalUtils mdsalUtils = null;
+    private static String extras = "false";
     private static final String NETVIRT = "org.opendaylight.ovsdb.openstack.net-virt";
     private static final String NETVIRTPROVIDERS = "org.opendaylight.ovsdb.openstack.net-virt-providers";
 
@@ -141,9 +141,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
     @Override
     public Option[] getLoggingOptions() {
         Option[] options = new Option[] {
-                editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
+                /*editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
                         "log4j.logger.org.opendaylight.ovsdb",
-                        LogLevelOption.LogLevel.DEBUG.name()),
+                        LogLevelOption.LogLevel.DEBUG.name()),*/
                 editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
                         "log4j.logger.org.opendaylight.ovsdb.southbound-impl",
                         LogLevelOption.LogLevel.DEBUG.name())
@@ -337,7 +337,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         Node node = getOvsdbNode(connectionInfo);
         //Assert.assertNull(node);
         Assume.assumeNotNull(node);
-        LOG.info("Disonnected from {}", connectionInfoToString(connectionInfo));
+        LOG.info("Disconnected from {}", connectionInfoToString(connectionInfo));
         return true;
     }
 
@@ -413,7 +413,8 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     private OvsdbBridgeAugmentation getBridge(ConnectionInfo connectionInfo) {
         InstanceIdentifier<Node> bridgeIid =
-                SouthboundMapper.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName("brtest"));
+                SouthboundMapper.createInstanceIdentifier(connectionInfo,
+                        new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME));
         Node bridgeNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid);
         Assert.assertNotNull(bridgeNode);
         OvsdbBridgeAugmentation ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
@@ -423,7 +424,8 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     private boolean deleteBridge(ConnectionInfo connectionInfo) throws InterruptedException {
         boolean result = mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION,
-                SouthboundMapper.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName("brtest")));
+                SouthboundMapper.createInstanceIdentifier(connectionInfo,
+                        new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME)));
         Thread.sleep(OVSDB_UPDATE_TIMEOUT);
         return result;
     }
@@ -433,7 +435,7 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
         Node ovsdbNode = connectOvsdbNode(connectionInfo);
 
-        Assert.assertTrue(addBridge(connectionInfo, "brtest"));
+        Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
         OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
         Assert.assertNotNull(bridge);
         LOG.info("bridge: {}", bridge);
index 0b4ceb255b02e6fe5108650b457362d492637683..27a8b6fad32c74fb3f686e73dc718c5cdd6fe492 100644 (file)
@@ -27,4 +27,5 @@ public final class SouthboundITConstants {
     public static final String DEFAULT_SERVER_IPADDRESS = "127.0.0.1";
     public static final String DEFAULT_SERVER_PORT = "6640";
     public static final String DEFAULT_SERVER_EXTRAS = "false";
+    public static final String BRIDGE_NAME = "brtest";
 }