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;
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;
ConfigurationService netVirtConfigurationService;
Boolean tearDownBridge = false;
+ ImmutablePair<UUID, Map<String, String>> tearDownOpenVSwitchOtherConfig = null;
// Configure the OSGi container
@Configuration
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
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);