Fix NeutronIT testGetTunnelEndpoint 16/12316/2
authorFlavio Fernandes <ffernand@redhat.com>
Wed, 29 Oct 2014 13:46:54 +0000 (09:46 -0400)
committerFlavio Fernandes <ffernand@redhat.com>
Wed, 29 Oct 2014 17:48:26 +0000 (13:48 -0400)
The test was broken in that it attempted to update all fields of the OpenVSwitch
row. That is not valid due to immutable columns, such as _version.

Change-Id: I214e96914d85a0ca8321bf7c3e498f9a46f24f0e
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/neutron/NeutronIT.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/ConfigurationServiceImpl.java

index befd5d28cf026ed47bfa57e5539937f62dbcee74..3ac457e9cf55a92d5ee72e1db10046297b09cf93 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
 import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
 import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.notation.Version;
 import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
@@ -35,6 +36,7 @@ import org.opendaylight.ovsdb.schema.openvswitch.Interface;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
 
 import com.google.common.collect.ImmutableMap;
+import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.junit.After;
@@ -83,6 +85,7 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
     ConfigurationService netVirtConfigurationService;
 
     Boolean tearDownBridge = false;
+    ImmutablePair<UUID, Map<String, String>> tearDownOpenVSwitchOtherConfig = null;
 
     // Configure the OSGi container
     @Configuration
@@ -205,15 +208,37 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
                                                             ovsRows.values().iterator().next());
 
         Assert.assertEquals(null, netVirtConfigurationService.getTunnelEndPoint(node));
+        final UUID originalVersion = ovsRow.getVersion();
+
+        OpenVSwitch updateOvsRow = ovsdbConfigurationService.createTypedRow(node, OpenVSwitch.class);
+
+        updateOvsRow.setOtherConfig(
+                ImmutableMap.of(netVirtConfigurationService.getTunnelEndpointKey(), endpointAddress));
 
-        ovsRow.setOtherConfig(ImmutableMap.of(netVirtConfigurationService.getTunnelEndpointKey(), endpointAddress));
         ovsdbConfigurationService.updateRow(node,
                                             ovsdbConfigurationService.getTableName(node, OpenVSwitch.class),
                                             null,
                                             ovsRow.getUuid().toString(),
-                                            ovsRow.getRow());
+                                            updateOvsRow.getRow());
 
+        // Remember original value so it can be restored on tearDown
+        tearDownOpenVSwitchOtherConfig = ImmutablePair.of(ovsRow.getUuid(),
+                                                          ovsRow.getOtherConfigColumn().getData());
+
+        // Make sure tunnel end point was set
         Assert.assertEquals(InetAddress.getByName(endpointAddress), netVirtConfigurationService.getTunnelEndPoint(node));
+
+        // Fetch rows again, and compare tunnel end point values
+        ovsRows = ovsdbConfigurationService.getRows(node,
+                                                    ovsdbConfigurationService.getTableName(node, OpenVSwitch.class));
+        ovsRow = ovsdbConfigurationService.getTypedRow(node,
+                                                       OpenVSwitch.class,
+                                                       ovsRows.values().iterator().next());
+
+        Assert.assertEquals(ovsRow.getOtherConfigColumn(), updateOvsRow.getOtherConfigColumn());
+
+        // expect version of row to be changed, due to the update
+        Assert.assertNotEquals(ovsRow.getVersion(), originalVersion);
     }
 
     @Test
@@ -246,12 +271,31 @@ public class NeutronIT extends OvsdbIntegrationTestBase {
         Thread.sleep(5000);
 
         if (tearDownBridge) {
-            String uuid = bridgeConfigurationManager.getBridgeUuid(node,
-                                                                   netVirtConfigurationService.getIntegrationBridgeName());
-            ovsdbConfigurationService.deleteRow(node, ovsdbConfigurationService.getTableName(node, Bridge.class), uuid);
+            try {
+                String uuid = bridgeConfigurationManager.getBridgeUuid(node,
+                                                                       netVirtConfigurationService.getIntegrationBridgeName());
+                ovsdbConfigurationService.deleteRow(node, ovsdbConfigurationService.getTableName(node, Bridge.class), uuid);
+            } catch (Exception e) {
+                log.error("tearDownBridge Exception : " + e.getMessage());
+            }
             tearDownBridge = false;
         }
 
+        if (tearDownOpenVSwitchOtherConfig != null) {
+            try {
+                OpenVSwitch updateOvsRow = ovsdbConfigurationService.createTypedRow(node, OpenVSwitch.class);
+                updateOvsRow.setOtherConfig(tearDownOpenVSwitchOtherConfig.getRight());
+                ovsdbConfigurationService.updateRow(node,
+                                                    ovsdbConfigurationService.getTableName(node, OpenVSwitch.class),
+                                                    null,
+                                                    tearDownOpenVSwitchOtherConfig.getLeft().toString(),
+                                                    updateOvsRow.getRow());
+            } catch (Exception e) {
+                log.error("tearDownOpenVSwitchOtherConfig Exception : " + e.getMessage());
+            }
+            tearDownOpenVSwitchOtherConfig = null;
+        }
+
         DependencyManager dm = new DependencyManager(bc);
         dm.remove(of10Provider);
         dm.remove(of13Provider);
index fc34377160f132327fab3a7740dd309e3b4818e2..40c9cabc4005d2caae54aeb2b0153a5772516d3b 100644 (file)
@@ -1499,7 +1499,8 @@ public class ConfigurationServiceImpl implements IPluginInBridgeDomainConfigServ
             List<OperationResult> operationResults = results.get();
             for (OperationResult result : operationResults) {
                 if (result.getError() != null) {
-                    throw new OvsdbPluginException("Error updating row : "+ result.getError());
+                    throw new OvsdbPluginException("Error updating row : " + result.getError() +
+                                                   " Details: " + result.getDetails());
                 }
             }
             if (operationResults.isEmpty() || (transactionBuilder.getOperations().size() != operationResults.size())) {