import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import com.google.common.collect.ObjectArrays;
+import com.google.common.collect.Sets;
+
+import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import org.junit.runner.RunWith;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.ovsdb.southbound.SouthboundProvider;
+import org.opendaylight.ovsdb.southbound.SouthboundUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIdsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ProtocolEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.options.MavenUrlReference;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
private static final String NETDEV_DP_TYPE = "netdev";
private static final Logger LOG = LoggerFactory.getLogger(SouthboundIT.class);
private static final int OVSDB_UPDATE_TIMEOUT = 1000;
+ public static final int NUM_THREADS = 4;
private static DataBroker dataBroker = null;
private static String addressStr;
private static String portStr;
private static String connectionType;
private static Boolean setup = false;
private static MdsalUtils mdsalUtils = null;
- private static final String NETVIRT = "org.opendaylight.ovsdb.openstack.net-virt";
- private static final String NETVIRTPROVIDERS = "org.opendaylight.ovsdb.openstack.net-virt-providers";
+
+ // TODO Constants copied frmo AbstractConfigTestBase, need to be removed (see TODO below)
+ private static final String PAX_EXAM_UNPACK_DIRECTORY = "target/exam";
+ private static final String KARAF_DEBUG_PORT = "5005";
+ private static final String KARAF_DEBUG_PROP = "karaf.debug";
+ private static final String KEEP_UNPACK_DIRECTORY_PROP = "karaf.keep.unpack";
@Inject
private BundleContext bundleContext;
@Configuration
public Option[] config() {
- return super.config();
+ // TODO Figure out how to use the parent Karaf setup, then just use super.config()
+ Option[] options = new Option[] {
+ when(Boolean.getBoolean(KARAF_DEBUG_PROP))
+ .useOptions(KarafDistributionOption.debugConfiguration(KARAF_DEBUG_PORT, true)),
+ karafDistributionConfiguration().frameworkUrl(getKarafDistro())
+ .unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY))
+ .useDeployFolder(false),
+ when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
+ // Works only if we don't specify the feature repo and name
+ getLoggingOption()};
+ Option[] propertyOptions = getPropertiesOptions();
+ Option[] otherOptions = getOtherOptions();
+ Option[] combinedOptions = new Option[options.length + propertyOptions.length + otherOptions.length];
+ System.arraycopy(options, 0, combinedOptions, 0, options.length);
+ System.arraycopy(propertyOptions, 0, combinedOptions, options.length, propertyOptions.length);
+ System.arraycopy(otherOptions, 0, combinedOptions, options.length + propertyOptions.length,
+ otherOptions.length);
+ return combinedOptions;
+ }
+
+ private Option[] getOtherOptions() {
+ return new Option[] {
+ vmOption("-javaagent:../jars/org.jacoco.agent.jar=destfile=../../jacoco-it.exec"),
+ keepRuntimeFolder()
+ };
+ }
+
+ @Override
+ public String getKarafDistro() {
+ return maven()
+ .groupId("org.opendaylight.ovsdb")
+ .artifactId("southbound-karaf")
+ .versionAsInProject()
+ .type("zip")
+ .getURL();
}
@Override
}
@Override
- public Option[] getFeaturesOptions() {
- return new Option[]{};
- }
-
- @Override
- public Option[] getLoggingOptions() {
- Option[] options = new Option[] {
+ public Option getLoggingOption() {
+ return composite(
editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- "log4j.logger.org.opendaylight.ovsdb.southbound-impl",
- LogLevelOption.LogLevel.DEBUG.name())
- };
-
- options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);
- return options;
+ "log4j.logger.org.opendaylight.ovsdb",
+ LogLevelOption.LogLevel.TRACE.name()),
+ super.getLoggingOption());
}
- @Override
- public Option[] getPropertiesOptions() {
+ private Option[] getPropertiesOptions() {
Properties props = new Properties(System.getProperties());
String addressStr = props.getProperty(SouthboundITConstants.SERVER_IPADDRESS,
SouthboundITConstants.DEFAULT_SERVER_IPADDRESS);
}
@Before
- public void setUp() throws InterruptedException {
- if (setup == true) {
+ @Override
+ public void setup() throws InterruptedException {
+ if (setup) {
LOG.info("Skipping setUp, already initialized");
return;
}
.setRemotePort(port)
.build());
return new ConnectionInfoBuilder()
- .setRemoteIp(address)
- .setRemotePort(port)
- .build();
+ .setRemoteIp(address)
+ .setRemotePort(port)
+ .build();
}
private String connectionInfoToString(final ConnectionInfo connectionInfo) {
}
private boolean addOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
+ InstanceIdentifier<Node> iid = createInstanceIdentifier(connectionInfo);
+ // Check that the node doesn't already exist (we don't support connecting twice)
+ Assert.assertNull("The OVSDB node has already been added",
+ mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, iid));
boolean result = mdsalUtils.put(LogicalDatastoreType.CONFIGURATION,
- SouthboundMapper.createInstanceIdentifier(connectionInfo),
- SouthboundMapper.createNode(connectionInfo));
+ iid,
+ createNode(connectionInfo));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
return result;
}
+ private InstanceIdentifier<Node> createInstanceIdentifier(
+ ConnectionInfo connectionInfo) {
+ return InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID))
+ .child(Node.class,
+ createNodeKey(connectionInfo.getRemoteIp(),connectionInfo.getRemotePort()));
+ }
+
private Node getOvsdbNode(final ConnectionInfo connectionInfo) {
Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
- SouthboundMapper.createInstanceIdentifier(connectionInfo));
+ createInstanceIdentifier(connectionInfo));
return node;
}
private boolean deleteOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
boolean result = mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION,
- SouthboundMapper.createInstanceIdentifier(connectionInfo));
+ createInstanceIdentifier(connectionInfo));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
return result;
}
LOG.info("dp type is {}", dpTypeStr);
if (dpTypeStr.equals(NETDEV_DP_TYPE)) {
LOG.info("Found a DPDK node; adding a corresponding netdev device");
- InstanceIdentifier<Node> bridgeIid = SouthboundMapper.createInstanceIdentifier(connectionInfo,
+ InstanceIdentifier<Node> bridgeIid = createInstanceIdentifier(connectionInfo,
new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME));
- NodeId bridgeNodeId = SouthboundMapper.createManagedNodeId(bridgeIid);
+ NodeId bridgeNodeId = createManagedNodeId(bridgeIid);
addBridge(connectionInfo, bridgeIid, SouthboundITConstants.BRIDGE_NAME, bridgeNodeId, false, null,
- true, dpType, null, null);
+ true, dpType, null, null, null);
// Verify that the device is netdev
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
//Assume.assumeTrue(disconnectOvsdbNode(connectionInfo));
}
+ @Test
+ public void testOvsdbBridgeControllerInfo() throws InterruptedException {
+ ConnectionInfo connectionInfo = getConnectionInfo(addressStr,portStr);
+ Node ovsdbNode = connectOvsdbNode(connectionInfo);
+ String controllerTarget = SouthboundUtil.getControllerTarget(ovsdbNode);
+ assertNotNull("Failed to get controller target", controllerTarget);
+ List<ControllerEntry> setControllerEntry = createControllerEntry(controllerTarget);
+ Uri setUri = new Uri(controllerTarget);
+ Assert.assertTrue(addBridge(connectionInfo, null, SouthboundITConstants.BRIDGE_NAME,null, true,
+ SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null,
+ setControllerEntry, null));
+ OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
+ Assert.assertNotNull("bridge was not found: " + SouthboundITConstants.BRIDGE_NAME, bridge);
+ Assert.assertNotNull("ControllerEntry was not found: " + setControllerEntry.iterator().next(),
+ bridge.getControllerEntry());
+ List<ControllerEntry> getControllerEntries = bridge.getControllerEntry();
+ for (ControllerEntry entry : getControllerEntries) {
+ if (entry.getTarget() != null) {
+ Assert.assertEquals(setUri.toString(), entry.getTarget().toString());
+ }
+ }
+
+ Assert.assertTrue(deleteBridge(connectionInfo));
+ Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ }
+
+ private List<ControllerEntry> createControllerEntry(String controllerTarget) {
+ List<ControllerEntry> controllerEntriesList = new ArrayList<ControllerEntry>();
+ controllerEntriesList.add(new ControllerEntryBuilder()
+ .setTarget(new Uri(controllerTarget))
+ .build());
+ return controllerEntriesList;
+ }
+
private void setManagedBy(final OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder,
final ConnectionInfo connectionInfo) {
- InstanceIdentifier<Node> connectionNodePath = SouthboundMapper.createInstanceIdentifier(connectionInfo);
+ InstanceIdentifier<Node> connectionNodePath = createInstanceIdentifier(connectionInfo);
ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(connectionNodePath));
}
}
private boolean addTerminationPoint(final NodeId bridgeNodeId, final String portName,
- final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointAugmentationBuilder)
- throws InterruptedException {
+ final OvsdbTerminationPointAugmentationBuilder
+ ovsdbTerminationPointAugmentationBuilder)
+ throws InterruptedException {
InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(bridgeNodeId);
NodeBuilder portNodeBuilder = new NodeBuilder();
* @throws InterruptedException
*/
private boolean addBridge(final ConnectionInfo connectionInfo, InstanceIdentifier<Node> bridgeIid,
- final String bridgeName, NodeId bridgeNodeId, final boolean setProtocolEntries,
- final Class<? extends OvsdbFailModeBase> failMode, final boolean setManagedBy,
- final Class<? extends DatapathTypeBase> dpType,
- final List<BridgeExternalIds> externalIds,
- final List<BridgeOtherConfigs> otherConfigs) throws InterruptedException {
+ final String bridgeName, NodeId bridgeNodeId, final boolean setProtocolEntries,
+ final Class<? extends OvsdbFailModeBase> failMode, final boolean setManagedBy,
+ final Class<? extends DatapathTypeBase> dpType,
+ final List<BridgeExternalIds> externalIds,
+ final List<ControllerEntry> controllerEntries,
+ final List<BridgeOtherConfigs> otherConfigs) throws InterruptedException {
NodeBuilder bridgeNodeBuilder = new NodeBuilder();
if (bridgeIid == null) {
- bridgeIid = SouthboundMapper.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
+ bridgeIid = createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
}
if (bridgeNodeId == null) {
bridgeNodeId = SouthboundMapper.createManagedNodeId(bridgeIid);
if (externalIds != null) {
ovsdbBridgeAugmentationBuilder.setBridgeExternalIds(externalIds);
}
+ if (controllerEntries != null) {
+ ovsdbBridgeAugmentationBuilder.setControllerEntry(controllerEntries);
+ }
if (otherConfigs != null) {
ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(otherConfigs);
}
}
private boolean addBridge(final ConnectionInfo connectionInfo, final String bridgeName)
- throws InterruptedException {
+ throws InterruptedException {
return addBridge(connectionInfo, null, bridgeName, null, true,
- SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null, null);
+ SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null, null, null);
}
private OvsdbBridgeAugmentation getBridge(ConnectionInfo connectionInfo) {
* @return <code>store</code> type data store contents
*/
private OvsdbBridgeAugmentation getBridge(ConnectionInfo connectionInfo, String bridgeName,
- LogicalDatastoreType store) {
+ LogicalDatastoreType store) {
Node bridgeNode = getBridgeNode(connectionInfo, bridgeName, store);
Assert.assertNotNull(bridgeNode);
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
*/
private Node getBridgeNode(ConnectionInfo connectionInfo, String bridgeName, LogicalDatastoreType store) {
InstanceIdentifier<Node> bridgeIid =
- SouthboundMapper.createInstanceIdentifier(connectionInfo,
- new OvsdbBridgeName(bridgeName));
+ createInstanceIdentifier(connectionInfo,
+ new OvsdbBridgeName(bridgeName));
return mdsalUtils.read(store, bridgeIid);
}
}
private boolean deleteBridge(final ConnectionInfo connectionInfo, final String bridgeName)
- throws InterruptedException {
+ throws InterruptedException {
boolean result = mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION,
- SouthboundMapper.createInstanceIdentifier(connectionInfo,
+ createInstanceIdentifier(connectionInfo,
new OvsdbBridgeName(bridgeName)));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
return result;
}
private InstanceIdentifier<Node> getTpIid(ConnectionInfo connectionInfo, OvsdbBridgeAugmentation bridge) {
- return SouthboundMapper.createInstanceIdentifier(connectionInfo,
- bridge.getBridgeName());
+ return createInstanceIdentifier(connectionInfo,
+ bridge.getBridgeName());
}
/**
* @param index
* @return
*/
- private OvsdbTerminationPointAugmentation getOvsdbTerminationPointAugmentation(ConnectionInfo connectionInfo,
- String bridgeName, LogicalDatastoreType store, int index ) {
+ private OvsdbTerminationPointAugmentation getOvsdbTerminationPointAugmentation(
+ ConnectionInfo connectionInfo, String bridgeName, LogicalDatastoreType store, int index ) {
+ List<TerminationPoint> tpList = getBridgeNode(connectionInfo, bridgeName, store).getTerminationPoint();
+ if (tpList == null) {
+ return null;
+ }
return ((OvsdbTerminationPointAugmentation)
- getBridgeNode(connectionInfo, bridgeName, store)
- .getTerminationPoint().get(index)
- .getAugmentation(OvsdbTerminationPointAugmentation.class));
+ tpList.get(index)
+ .getAugmentation(OvsdbTerminationPointAugmentation.class));
}
@Test
- public void testTerminationPointOfPort() throws InterruptedException {
+ public void testCRDTerminationPointOfPort() throws InterruptedException {
+ final Long OFPORT_EXPECTED = new Long(45002);
+
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
connectOvsdbNode(connectionInfo);
+ // CREATE
Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
Assert.assertNotNull(bridge);
LOG.info("bridge: {}", bridge);
- NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
+ NodeId nodeId = SouthboundMapper.createManagedNodeId(createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testOfPort";
ovsdbTerminationBuilder.setName(portName);
- Long ofPortExpected = new Long(45002);
- ovsdbTerminationBuilder.setOfport(ofPortExpected);
+
+ ovsdbTerminationBuilder.setOfport(OFPORT_EXPECTED);
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
Assert.assertNotNull(terminationPointNode);
+ // READ
List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
for (TerminationPoint terminationPoint : terminationPoints) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
Long ofPort = ovsdbTerminationPointAugmentation.getOfport();
// if ephemeral port 45002 is in use, ofPort is set to 1
- Assert.assertTrue(ofPort.equals(ofPortExpected) || ofPort.equals(new Long(1)));
+ Assert.assertTrue(ofPort.equals(OFPORT_EXPECTED) || ofPort.equals(new Long(1)));
LOG.info("ofPort: {}", ofPort);
}
}
+
+ // UPDATE- Not Applicable. From the OpenVSwitch Documentation:
+ // "A client should ideally set this column’s value in the same database transaction that it uses to create
+ // the interface."
+
+ // DELETE
Assert.assertTrue(deleteBridge(connectionInfo));
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
@Test
- public void testTerminationPointOfPortRequest() throws InterruptedException {
+ public void testCRDTerminationPointOfPortRequest() throws InterruptedException {
+ final Long OFPORT_EXPECTED = new Long(45008);
+ final Long OFPORT_INPUT = new Long(45008);
+
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
connectOvsdbNode(connectionInfo);
+
+ // CREATE
Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
Assert.assertNotNull(bridge);
- NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
+ NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testOfPortRequest";
ovsdbTerminationBuilder.setName(portName);
- Long ofPortExpected = new Long(45008);
- Integer ofPortRequestExpected = ofPortExpected.intValue();
- Long ofPortInput = new Long(45008);
- ovsdbTerminationBuilder.setOfport(ofPortInput);
+ Integer ofPortRequestExpected = OFPORT_EXPECTED.intValue();
+ ovsdbTerminationBuilder.setOfport(OFPORT_INPUT);
ovsdbTerminationBuilder.setOfportRequest(ofPortRequestExpected);
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
Assert.assertNotNull(terminationPointNode);
+ // READ
List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
for (TerminationPoint terminationPoint : terminationPoints) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
Long ofPort = ovsdbTerminationPointAugmentation.getOfport();
- // if ephemeral port 45002 is in use, ofPort is set to 1
- Assert.assertTrue(ofPort.equals(ofPortExpected) || ofPort.equals(new Long(1)));
+ // if ephemeral port 45008 is in use, ofPort is set to 1
+ Assert.assertTrue(ofPort.equals(OFPORT_EXPECTED) || ofPort.equals(new Long(1)));
LOG.info("ofPort: {}", ofPort);
Integer ofPortRequest = ovsdbTerminationPointAugmentation.getOfportRequest();
LOG.info("ofPortRequest: {}", ofPortRequest);
}
}
+
+ // UPDATE- Not Applicable. From the OpenVSwitch documentation:
+ // "A client should ideally set this column’s value in the same database transaction that it uses to create
+ // the interface. "
+
+ // DELETE
Assert.assertTrue(deleteBridge(connectionInfo));
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
final String testOneExternalIdName = "TestOneExternalId";
int externalIdCounter = 0;
List<PortExternalIds> oneExternalId = (List<PortExternalIds>) Lists.newArrayList(
- (new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testOneExternalIdName,
- PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testOneExternalIdName,
- PORT_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()));
+ (new PortExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testOneExternalIdName,
+ PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testOneExternalIdName,
+ PORT_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()));
Map<String,List<PortExternalIds>> testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, oneExternalId);
testCase.put(INPUT_VALUES_KEY, oneExternalId);
final String testFiveExternalIdName = "TestFiveExternalId";
externalIdCounter = 0;
List<PortExternalIds> fiveExternalId = (List<PortExternalIds>) Lists.newArrayList(
- (new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- PORT_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()));
+ (new PortExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new PortExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new PortExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new PortExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new PortExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ PORT_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()));
testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, fiveExternalId);
testCase.put(INPUT_VALUES_KEY, fiveExternalId);
- testMap.put(testOneExternalIdName, testCase);
+ testMap.put(testFiveExternalIdName, testCase);
// Test Case 3: TestOneGoodExternalIdOneMalformedExternalIdValue
// Test Type: Negative
"TestOneGoodExternalIdOneMalformedExternalIdValue";
externalIdCounter = 0;
PortExternalIds oneGood = new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdValueName,
- GOOD_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format("FORMAT_STR",
+ .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdValueName,
+ GOOD_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR,
testOneGoodExternalIdOneMalformedExternalIdValueName,
- GOOD_VALUE, externalIdCounter))
+ GOOD_VALUE, externalIdCounter))
.build();
PortExternalIds oneBad = new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR,
- testOneGoodExternalIdOneMalformedExternalIdValueName, NO_VALUE_FOR_KEY, ++externalIdCounter))
+ .setExternalIdKey(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdValueName, NO_VALUE_FOR_KEY, ++externalIdCounter))
.build();
List<PortExternalIds> oneGoodOneBadInput = (List<PortExternalIds>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodExternalIdOneMalformedExternalIdValueName, testCase);
// Test Case 4: TestOneGoodExternalIdOneMalformedExternalIdKey
// Test Type: Negative
"TestOneGoodExternalIdOneMalformedExternalIdKey";
externalIdCounter = 0;
oneGood = new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdKeyName,
- GOOD_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format("FORMAT_STR",
+ .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdKeyName,
+ GOOD_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR,
testOneGoodExternalIdOneMalformedExternalIdKeyName,
- GOOD_VALUE, externalIdCounter))
+ GOOD_VALUE, externalIdCounter))
.build();
oneBad = new PortExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR,
- testOneGoodExternalIdOneMalformedExternalIdKeyName, NO_KEY_FOR_VALUE, ++externalIdCounter))
+ .setExternalIdKey(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdKeyName, NO_KEY_FOR_VALUE, ++externalIdCounter))
.build();
oneGoodOneBadInput = (List<PortExternalIds>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodExternalIdOneMalformedExternalIdKeyName, testCase);
return testMap;
}
* This is helper test method to compare a test "set" of BridgeExternalIds against an expected "set"
*/
private void assertExpectedPortExternalIdsExist( List<PortExternalIds> expected,
- List<PortExternalIds> test ) {
+ List<PortExternalIds> test ) {
if (expected != null) {
for (PortExternalIds expectedExternalId : expected) {
Assert.assertTrue(test.contains(expectedExternalId));
}
- } else {
- Assert.assertNull(test);
- }
- }
-
- /*
- * @see <code>SouthboundIT.testCRUDPortExternalIds()</code>
- * This is a helper test method. The method only checks if
- * <code>updateFromInputExternalIds != updateToInputExternalIds</code>, (i.e., the updateTo "set" isn't the same
- * as the updateFrom "set". Then, the method ensures each element of erase is not an element of test, as the input
- * test cases are divergent.
- */
- private void assertPortExternalIdsErased( List<PortExternalIds> updateFromInputExternalIds,
- List<PortExternalIds> updateToInputExternalIds,
- List<PortExternalIds> updateFromExpectedExternalIds,
- List<PortExternalIds> updateToTestExternalIds ) {
-
- if (!updateFromInputExternalIds.containsAll(updateToInputExternalIds)) {
- for (PortExternalIds erasedExternalId : updateFromExpectedExternalIds) {
- Assert.assertTrue(!updateToTestExternalIds.contains(erasedExternalId));
- }
}
}
/*
- * Tests the CRUD operations for <code>Port</code> <code>external_ids</code>.
+ * Tests the CRUD operations for <code>Port</code>
+ * <code>external_ids</code>.
*
- * @see <code>SouthboundIT.generatePortExternalIdsTestCases()</code> for specific test case information
+ * @see <code>SouthboundIT.generatePortExternalIdsTestCases()</code> for
+ * specific test case information
*/
@Test
- public void testCRUDTerminationPointPortExternalIds() throws InterruptedException {
+ public void testCRUDTerminationPointPortExternalIds()
+ throws InterruptedException, ExecutionException {
+
final String TEST_PREFIX = "CRUDTPPortExternalIds";
- final int TERMINATION_POINT_TEST_INDEX = 0;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
connectOvsdbNode(connectionInfo);
- // updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
- // the update has been performed.
- Map<String, Map<String, List<PortExternalIds>>> updateFromTestCases = generatePortExternalIdsTestCases();
- Map<String, Map<String, List<PortExternalIds>>> updateToTestCases = generatePortExternalIdsTestCases();
- Map<String, List<PortExternalIds>> updateFromTestCase = null;
- List<PortExternalIds> updateFromInputExternalIds = null;
- List<PortExternalIds> updateFromExpectedExternalIds = null;
- List<PortExternalIds> updateFromConfigurationExternalIds = null;
- List<PortExternalIds> updateFromOperationalExternalIds = null;
- Map<String, List<PortExternalIds>> updateToTestCase = null;
- List<PortExternalIds> updateToInputExternalIds = null;
- List<PortExternalIds> updateToExpectedExternalIds = null;
- List<PortExternalIds> updateToConfigurationExternalIds = null;
- List<PortExternalIds> updateToOperationalExternalIds = null;
- String testBridgeName = null;
- String testPortName = null;
- OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation = null;
- OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder = null;
- OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder = null;
- TerminationPointBuilder tpUpdateBuilder = null;
- NodeBuilder portUpdateNodeBuilder = null;
- NodeId testBridgeNodeId = null;
- NodeId portUpdateNodeId = null;
- InstanceIdentifier<Node> portIid = null;
- boolean result = false;
-
+ // updateFromTestCases represent the original test case value.
+ // updateToTestCases represent the new value after the update has been
+ // performed.
+ Map<String, Map<String, List<PortExternalIds>>> updateFromTestCases =
+ generatePortExternalIdsTestCases();
+ Map<String, Map<String, List<PortExternalIds>>> updateToTestCases =
+ generatePortExternalIdsTestCases();
+ Map<String, List<PortExternalIds>> updateFromTestCase;
+ List<PortExternalIds> updateFromInputExternalIds;
+ List<PortExternalIds> updateFromExpectedExternalIds;
+ Map<String, List<PortExternalIds>> updateToTestCase;
+ List<PortExternalIds> updateToInputExternalIds;
+ List<PortExternalIds> updateToExpectedExternalIds;
+ String testBridgeName;
+ String testPortName;
+
+ int counter = 1;
+ // multihreads the test using NUM_THREADS
+ ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
for (String updateFromTestCaseKey : updateFromTestCases.keySet()) {
- updateFromTestCase = updateFromTestCases.get(updateFromTestCaseKey);
- updateFromInputExternalIds = updateFromTestCase.get(INPUT_VALUES_KEY);
- updateFromExpectedExternalIds = updateFromTestCase.get(EXPECTED_VALUES_KEY);
+ updateFromTestCase = updateFromTestCases.get(
+ updateFromTestCaseKey);
+ updateFromInputExternalIds = updateFromTestCase.get(
+ INPUT_VALUES_KEY);
+ updateFromExpectedExternalIds = updateFromTestCase.get(
+ EXPECTED_VALUES_KEY);
for (String testCaseKey : updateToTestCases.keySet()) {
- testPortName = testBridgeName = String.format("%s_%s", TEST_PREFIX, testCaseKey);
+ testPortName = testBridgeName = String.format("%s_%s_%d",
+ TEST_PREFIX, testCaseKey, counter);
+ counter += 1;
updateToTestCase = updateToTestCases.get(testCaseKey);
- updateToInputExternalIds = updateToTestCase.get(INPUT_VALUES_KEY);
- updateToExpectedExternalIds = updateToTestCase.get(EXPECTED_VALUES_KEY);
+ updateToInputExternalIds = updateToTestCase.get(
+ INPUT_VALUES_KEY);
+ updateToExpectedExternalIds = updateToTestCase.get(
+ EXPECTED_VALUES_KEY);
+ TestCRUDTerminationPointPortExternalIdsRunnable testRunnable =
+ new TestCRUDTerminationPointPortExternalIdsRunnable(
+ connectionInfo, testBridgeName, testPortName,
+ updateFromInputExternalIds,
+ updateFromExpectedExternalIds,
+ updateToInputExternalIds,
+ updateToExpectedExternalIds);
+ executor.submit(testRunnable);
+ }
+ }
+ executor.shutdown();
+ executor.awaitTermination(5, TimeUnit.MINUTES);
+ Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ }
- // CREATE: Create the test bridge
- Assert.assertTrue(addBridge(connectionInfo, null,
- testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
- true, null, null, null));
- testBridgeNodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
- connectionInfo, new OvsdbBridgeName(testBridgeName)));
- tpCreateAugmentationBuilder = createGenericOvsdbTerminationPointAugmentationBuilder();
- tpCreateAugmentationBuilder.setName(testPortName);
- tpCreateAugmentationBuilder.setPortExternalIds(updateFromInputExternalIds);
- Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
-
- // READ: Read the test port and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateFromConfigurationTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
- updateFromConfigurationExternalIds = updateFromConfigurationTerminationPointAugmentation
- .getPortExternalIds();
- assertExpectedPortExternalIdsExist(updateFromExpectedExternalIds, updateFromConfigurationExternalIds);
- updateFromOperationalTerminationPointAugmenation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
- updateFromOperationalExternalIds = updateFromOperationalTerminationPointAugmenation
- .getPortExternalIds();
- assertExpectedPortExternalIdsExist(updateFromExpectedExternalIds, updateFromOperationalExternalIds);
-
- // UPDATE: update the external_ids
- testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
- tpUpdateAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
- tpUpdateAugmentationBuilder.setPortExternalIds(updateToInputExternalIds);
- portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
- portUpdateNodeBuilder = new NodeBuilder();
- portUpdateNodeId = SouthboundMapper.createManagedNodeId(portIid);
- portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
- tpUpdateBuilder = new TerminationPointBuilder();
- tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
- portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
- result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
- portIid, portUpdateNodeBuilder.build());
- Thread.sleep(OVSDB_UPDATE_TIMEOUT);
- Assert.assertTrue(result);
-
- // READ: the test port and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateToConfigurationTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
- updateToConfigurationExternalIds = updateToConfigurationTerminationPointAugmentation
- .getPortExternalIds();
- assertExpectedPortExternalIdsExist(updateToExpectedExternalIds, updateToConfigurationExternalIds);
- updateToOperationalTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
- updateToOperationalExternalIds = updateToOperationalTerminationPointAugmentation.getPortExternalIds();
- assertExpectedPortExternalIdsExist(updateToExpectedExternalIds, updateToOperationalExternalIds);
+ class TestCRUDTerminationPointPortExternalIdsRunnable implements Runnable {
+ ConnectionInfo connectionInfo;
+ String testBridgeName;
+ String testPortName;
+ List<PortExternalIds> updateFromInputExternalIds;
+ List<PortExternalIds> updateFromExpectedExternalIds;
+ List<PortExternalIds> updateToInputExternalIds;
+ List<PortExternalIds> updateToExpectedExternalIds;
+
+ public TestCRUDTerminationPointPortExternalIdsRunnable(
+ ConnectionInfo connectionInfo,
+ String testBridgeName, String testPortName,
+ List<PortExternalIds> updateFromInputExternalIds,
+ List<PortExternalIds> updateFromExpectedExternalIds,
+ List<PortExternalIds> updateToInputExternalIds,
+ List<PortExternalIds> updateToExpectedExternalIds) {
+
+ this.connectionInfo = connectionInfo;
+ this.testBridgeName = testBridgeName;
+ this.testPortName = testPortName;
+ this.updateFromInputExternalIds = updateFromInputExternalIds;
+ this.updateFromExpectedExternalIds = updateFromExpectedExternalIds;
+ this.updateToInputExternalIds = updateToInputExternalIds;
+ this.updateToExpectedExternalIds = updateToExpectedExternalIds;
+ }
- // Make sure the old port external ids aren't present in the CONFIGURATION data store
- assertPortExternalIdsErased(updateFromInputExternalIds, updateToInputExternalIds,
- updateFromExpectedExternalIds, updateToConfigurationExternalIds);
- assertPortExternalIdsErased(updateFromInputExternalIds, updateToInputExternalIds,
- updateFromExpectedExternalIds, updateToConfigurationExternalIds);
+ @Override
+ public void run() {
+ try {
+ test();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
- // DELETE
- Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ private void test() throws InterruptedException {
+
+ final int TERMINATION_POINT_TEST_INDEX = 0;
+ // CREATE: Create the test bridge
+ Assert.assertTrue(addBridge(connectionInfo, null,
+ testBridgeName, null, true,
+ SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+ true, null, null, null, null));
+ NodeId testBridgeNodeId = createManagedNodeId(createInstanceIdentifier(
+ connectionInfo, new OvsdbBridgeName(testBridgeName)));
+ OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder =
+ createGenericOvsdbTerminationPointAugmentationBuilder();
+ tpCreateAugmentationBuilder.setName(testPortName);
+ tpCreateAugmentationBuilder.setPortExternalIds(updateFromInputExternalIds);
+ Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
+
+ // READ: Read the test port and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<PortExternalIds> updateFromConfigurationExternalIds =
+ updateFromConfigurationTerminationPointAugmentation
+ .getPortExternalIds();
+ assertExpectedPortExternalIdsExist(updateFromExpectedExternalIds, updateFromConfigurationExternalIds);
+ OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<PortExternalIds> updateFromOperationalExternalIds = updateFromOperationalTerminationPointAugmenation
+ .getPortExternalIds();
+ assertExpectedPortExternalIdsExist(updateFromExpectedExternalIds, updateFromOperationalExternalIds);
+
+ // UPDATE: update the external_ids
+ testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setPortExternalIds(updateToInputExternalIds);
+ InstanceIdentifier portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ Assert.assertTrue(result);
+
+ // READ: the test port and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<PortExternalIds> updateToConfigurationExternalIds = updateToConfigurationTerminationPointAugmentation
+ .getPortExternalIds();
+ assertExpectedPortExternalIdsExist(updateToExpectedExternalIds, updateToConfigurationExternalIds);
+ assertExpectedPortExternalIdsExist(updateFromExpectedExternalIds, updateToConfigurationExternalIds);
+ OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<PortExternalIds> updateToOperationalExternalIds =
+ updateToOperationalTerminationPointAugmentation.getPortExternalIds();
+ if (updateFromExpectedExternalIds != null) {
+ assertExpectedPortExternalIdsExist(updateToExpectedExternalIds, updateToOperationalExternalIds);
+ assertExpectedPortExternalIdsExist(updateFromExpectedExternalIds, updateToOperationalExternalIds);
}
+
+ // DELETE
+ Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
}
- Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
+
+
/*
* Generates the test cases involved in testing InterfaceExternalIds. See inline comments for descriptions of
* the particular cases considered.
final String testOneExternalIdName = "TestOneExternalId";
int externalIdCounter = 0;
List<InterfaceExternalIds> oneExternalId = (List<InterfaceExternalIds>) Lists.newArrayList(
- (new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testOneExternalIdName,
- INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testOneExternalIdName,
- INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()));
+ (new InterfaceExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testOneExternalIdName,
+ INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testOneExternalIdName,
+ INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()));
Map<String,List<InterfaceExternalIds>> testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, oneExternalId);
testCase.put(INPUT_VALUES_KEY, oneExternalId);
final String testFiveExternalIdName = "TestFiveExternalId";
externalIdCounter = 0;
List<InterfaceExternalIds> fiveExternalId = (List<InterfaceExternalIds>) Lists.newArrayList(
- (new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()));
+ (new InterfaceExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new InterfaceExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new InterfaceExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new InterfaceExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new InterfaceExternalIdsBuilder()
+ .setExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ INTERFACE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()));
testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, fiveExternalId);
testCase.put(INPUT_VALUES_KEY, fiveExternalId);
- testMap.put(testOneExternalIdName, testCase);
+ testMap.put(testFiveExternalIdName, testCase);
// Test Case 3: TestOneGoodExternalIdOneMalformedExternalIdValue
// Test Type: Negative
"TestOneGoodExternalIdOneMalformedExternalIdValue";
externalIdCounter = 0;
InterfaceExternalIds oneGood = new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdValueName,
- GOOD_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format("FORMAT_STR",
+ .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdValueName,
+ GOOD_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR,
testOneGoodExternalIdOneMalformedExternalIdValueName,
- GOOD_VALUE, externalIdCounter))
+ GOOD_VALUE, externalIdCounter))
.build();
InterfaceExternalIds oneBad = new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR,
- testOneGoodExternalIdOneMalformedExternalIdValueName, NO_VALUE_FOR_KEY, ++externalIdCounter))
+ .setExternalIdKey(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdValueName, NO_VALUE_FOR_KEY, ++externalIdCounter))
.build();
List<InterfaceExternalIds> oneGoodOneBadInput = (List<InterfaceExternalIds>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodExternalIdOneMalformedExternalIdValueName, testCase);
// Test Case 4: TestOneGoodExternalIdOneMalformedExternalIdKey
// Test Type: Negative
"TestOneGoodExternalIdOneMalformedExternalIdKey";
externalIdCounter = 0;
oneGood = new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdKeyName,
- GOOD_KEY, ++externalIdCounter))
- .setExternalIdValue(String.format("FORMAT_STR",
+ .setExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdKeyName,
+ GOOD_KEY, ++externalIdCounter))
+ .setExternalIdValue(String.format(FORMAT_STR,
testOneGoodExternalIdOneMalformedExternalIdKeyName,
- GOOD_VALUE, externalIdCounter))
+ GOOD_VALUE, externalIdCounter))
.build();
oneBad = new InterfaceExternalIdsBuilder()
- .setExternalIdKey(String.format(FORMAT_STR,
- testOneGoodExternalIdOneMalformedExternalIdKeyName, NO_KEY_FOR_VALUE, ++externalIdCounter))
+ .setExternalIdKey(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdKeyName, NO_KEY_FOR_VALUE, ++externalIdCounter))
.build();
oneGoodOneBadInput = (List<InterfaceExternalIds>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodExternalIdOneMalformedExternalIdKeyName, testCase);
return testMap;
}
* This is helper test method to compare a test "set" of InterfaceExternalIds against an expected "set"
*/
private void assertExpectedInterfaceExternalIdsExist( List<InterfaceExternalIds> expected,
- List<InterfaceExternalIds> test ) {
+ List<InterfaceExternalIds> test ) {
if (expected != null) {
for (InterfaceExternalIds expectedExternalId : expected) {
Assert.assertTrue(test.contains(expectedExternalId));
}
- } else {
- Assert.assertNull(test);
- }
- }
-
- /*
- * @see <code>SouthboundIT.testCRUDInterfaceExternalIds()</code>
- * This is a helper test method. The method only checks if
- * <code>updateFromInputExternalIds != updateToInputExternalIds</code>, (i.e., the updateTo "set" isn't the same
- * as the updateFrom "set". Then, the method ensures each element of erase is not an element of test, as the input
- * test cases are divergent.
- */
- private void assertInterfaceExternalIdsErased( List<InterfaceExternalIds> updateFromInputExternalIds,
- List<InterfaceExternalIds> updateToInputExternalIds,
- List<InterfaceExternalIds> updateFromExpectedExternalIds,
- List<InterfaceExternalIds> updateToTestExternalIds ) {
-
- if (!updateFromInputExternalIds.containsAll(updateToInputExternalIds)) {
- for (InterfaceExternalIds erasedExternalId : updateFromExpectedExternalIds) {
- Assert.assertTrue(!updateToTestExternalIds.contains(erasedExternalId));
- }
}
}
* @see <code>SouthboundIT.generateInterfaceExternalIdsTestCases()</code> for specific test case information
*/
@Test
- public void testCRUDTerminationPointInterfaceExternalIds() throws InterruptedException {
+ public void testCRUDTerminationPointInterfaceExternalIds() throws InterruptedException, ExecutionException {
final String TEST_PREFIX = "CRUDTPInterfaceExternalIds";
final int TERMINATION_POINT_TEST_INDEX = 0;
generateInterfaceExternalIdsTestCases();
Map<String, Map<String, List<InterfaceExternalIds>>> updateToTestCases =
generateInterfaceExternalIdsTestCases();
- Map<String, List<InterfaceExternalIds>> updateFromTestCase = null;
- List<InterfaceExternalIds> updateFromInputExternalIds = null;
- List<InterfaceExternalIds> updateFromExpectedExternalIds = null;
- List<InterfaceExternalIds> updateFromConfigurationExternalIds = null;
- List<InterfaceExternalIds> updateFromOperationalExternalIds = null;
- Map<String, List<InterfaceExternalIds>> updateToTestCase = null;
- List<InterfaceExternalIds> updateToInputExternalIds = null;
- List<InterfaceExternalIds> updateToExpectedExternalIds = null;
- List<InterfaceExternalIds> updateToConfigurationExternalIds = null;
- List<InterfaceExternalIds> updateToOperationalExternalIds = null;
- String testBridgeName = null;
- String testPortName = null;
- OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation = null;
- OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder = null;
- OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder = null;
- TerminationPointBuilder tpUpdateBuilder = null;
- NodeBuilder portUpdateNodeBuilder = null;
- NodeId testBridgeNodeId = null;
- NodeId portUpdateNodeId = null;
- InstanceIdentifier<Node> portIid = null;
- boolean result = false;
-
+ Map<String, List<InterfaceExternalIds>> updateFromTestCase;
+ List<InterfaceExternalIds> updateFromInputExternalIds;
+ List<InterfaceExternalIds> updateFromExpectedExternalIds;
+ Map<String, List<InterfaceExternalIds>> updateToTestCase;
+ List<InterfaceExternalIds> updateToInputExternalIds;
+ List<InterfaceExternalIds> updateToExpectedExternalIds;
+ String testBridgeName;
+ String testPortName;
+
+ int counter = 1;
+ // multihreads the test using NUM_THREADS
+ ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
for (String updateFromTestCaseKey : updateFromTestCases.keySet()) {
updateFromTestCase = updateFromTestCases.get(updateFromTestCaseKey);
updateFromInputExternalIds = updateFromTestCase.get(INPUT_VALUES_KEY);
updateFromExpectedExternalIds = updateFromTestCase.get(EXPECTED_VALUES_KEY);
for (String testCaseKey : updateToTestCases.keySet()) {
- testPortName = testBridgeName = String.format("%s_%s", TEST_PREFIX, testCaseKey);
+ testPortName = testBridgeName = String.format("%s_%s_%d", TEST_PREFIX, testCaseKey, counter);
+ counter += 1;
updateToTestCase = updateToTestCases.get(testCaseKey);
updateToInputExternalIds = updateToTestCase.get(INPUT_VALUES_KEY);
updateToExpectedExternalIds = updateToTestCase.get(EXPECTED_VALUES_KEY);
- // CREATE: Create the test interface
- Assert.assertTrue(addBridge(connectionInfo, null,
- testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
- true, null, null, null));
- testBridgeNodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
- connectionInfo, new OvsdbBridgeName(testBridgeName)));
- tpCreateAugmentationBuilder = createGenericOvsdbTerminationPointAugmentationBuilder();
- tpCreateAugmentationBuilder.setName(testPortName);
- tpCreateAugmentationBuilder.setInterfaceExternalIds(updateFromInputExternalIds);
- Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
-
- // READ: Read the test interface and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateFromConfigurationTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
- updateFromConfigurationExternalIds = updateFromConfigurationTerminationPointAugmentation
- .getInterfaceExternalIds();
- assertExpectedInterfaceExternalIdsExist(updateFromExpectedExternalIds,
- updateFromConfigurationExternalIds);
- updateFromOperationalTerminationPointAugmenation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
- updateFromOperationalExternalIds = updateFromOperationalTerminationPointAugmenation
- .getInterfaceExternalIds();
- assertExpectedInterfaceExternalIdsExist(updateFromExpectedExternalIds,
- updateFromOperationalExternalIds);
-
- // UPDATE: update the external_ids
- testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
- tpUpdateAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
- tpUpdateAugmentationBuilder.setInterfaceExternalIds(updateToInputExternalIds);
- portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
- portUpdateNodeBuilder = new NodeBuilder();
- portUpdateNodeId = SouthboundMapper.createManagedNodeId(portIid);
- portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
- tpUpdateBuilder = new TerminationPointBuilder();
- tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
- portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
- result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
- portIid, portUpdateNodeBuilder.build());
- Thread.sleep(OVSDB_UPDATE_TIMEOUT);
- Assert.assertTrue(result);
-
- // READ: the test interface and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateToConfigurationTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
- updateToConfigurationExternalIds = updateToConfigurationTerminationPointAugmentation
- .getInterfaceExternalIds();
- assertExpectedInterfaceExternalIdsExist(updateToExpectedExternalIds, updateToConfigurationExternalIds);
- updateToOperationalTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
- updateToOperationalExternalIds = updateToOperationalTerminationPointAugmentation
- .getInterfaceExternalIds();
- assertExpectedInterfaceExternalIdsExist(updateToExpectedExternalIds, updateToOperationalExternalIds);
-
- // Make sure the old interface external ids aren't present in the CONFIGURATION data store
- assertInterfaceExternalIdsErased(updateFromInputExternalIds, updateToInputExternalIds,
- updateFromExpectedExternalIds, updateToConfigurationExternalIds);
- assertInterfaceExternalIdsErased(updateFromInputExternalIds, updateToInputExternalIds,
- updateFromExpectedExternalIds, updateToConfigurationExternalIds);
-
- // DELETE
- Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ TestCRUDTerminationPointInterfaceExternalIdsRunnable testRunnable =
+ new TestCRUDTerminationPointInterfaceExternalIdsRunnable(
+ connectionInfo, testBridgeName, testPortName,
+ updateFromInputExternalIds,
+ updateFromExpectedExternalIds,
+ updateToInputExternalIds,
+ updateToExpectedExternalIds);
+ executor.submit(testRunnable);
}
}
+ executor.shutdown();
+ executor.awaitTermination(5, TimeUnit.MINUTES);
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
+ class TestCRUDTerminationPointInterfaceExternalIdsRunnable implements Runnable {
+
+ ConnectionInfo connectionInfo;
+ String testBridgeName;
+ String testPortName;
+ List<InterfaceExternalIds> updateFromInputExternalIds;
+ List<InterfaceExternalIds> updateFromExpectedExternalIds;
+ List<InterfaceExternalIds> updateToInputExternalIds;
+ List<InterfaceExternalIds> updateToExpectedExternalIds;
+
+ TestCRUDTerminationPointInterfaceExternalIdsRunnable(
+ ConnectionInfo connectionInfo, String testBridgeName,
+ String testPortName,
+ List<InterfaceExternalIds> updateFromInputExternalIds,
+ List<InterfaceExternalIds> updateFromExpectedExternalIds,
+ List<InterfaceExternalIds> updateToInputExternalIds,
+ List<InterfaceExternalIds> updateToExpectedExternalIds) {
+
+ this.connectionInfo = connectionInfo;
+ this.testBridgeName = testBridgeName;
+ this.testPortName = testPortName;
+ this.updateFromInputExternalIds = updateFromInputExternalIds;
+ this.updateFromExpectedExternalIds = updateFromExpectedExternalIds;
+ this.updateToInputExternalIds = updateToInputExternalIds;
+ this.updateToExpectedExternalIds = updateToExpectedExternalIds;
+ }
+
+ @Override
+ public void run() {
+ try {
+ test();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void test() throws InterruptedException {
+
+ final int TERMINATION_POINT_TEST_INDEX = 0;
+ // CREATE: Create the test interface
+ Assert.assertTrue(addBridge(connectionInfo, null,
+ testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+ true, null, null, null, null));
+ NodeId testBridgeNodeId = createManagedNodeId(createInstanceIdentifier(
+ connectionInfo, new OvsdbBridgeName(testBridgeName)));
+ OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder =
+ createGenericOvsdbTerminationPointAugmentationBuilder();
+ tpCreateAugmentationBuilder.setName(testPortName);
+ tpCreateAugmentationBuilder.setInterfaceExternalIds(updateFromInputExternalIds);
+ Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
+
+ // READ: Read the test interface and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceExternalIds> updateFromConfigurationExternalIds =
+ updateFromConfigurationTerminationPointAugmentation
+ .getInterfaceExternalIds();
+ assertExpectedInterfaceExternalIdsExist(updateFromExpectedExternalIds,
+ updateFromConfigurationExternalIds);
+ OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceExternalIds> updateFromOperationalExternalIds =
+ updateFromOperationalTerminationPointAugmenation
+ .getInterfaceExternalIds();
+ assertExpectedInterfaceExternalIdsExist(updateFromExpectedExternalIds,
+ updateFromOperationalExternalIds);
+
+ // UPDATE: update the external_ids
+ testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setInterfaceExternalIds(updateToInputExternalIds);
+ InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ Assert.assertTrue(result);
+
+ // READ: the test interface and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceExternalIds> updateToConfigurationExternalIds =
+ updateToConfigurationTerminationPointAugmentation
+ .getInterfaceExternalIds();
+ assertExpectedInterfaceExternalIdsExist(updateToExpectedExternalIds, updateToConfigurationExternalIds);
+ assertExpectedInterfaceExternalIdsExist(updateFromExpectedExternalIds,
+ updateToConfigurationExternalIds);
+ OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceExternalIds> updateToOperationalExternalIds = updateToOperationalTerminationPointAugmentation
+ .getInterfaceExternalIds();
+ if (updateFromExpectedExternalIds != null) {
+ assertExpectedInterfaceExternalIdsExist(updateToExpectedExternalIds,
+ updateToOperationalExternalIds);
+ assertExpectedInterfaceExternalIdsExist(updateFromExpectedExternalIds,
+ updateToOperationalExternalIds);
+ } else {
+ Assert.assertNull(updateToOperationalExternalIds);
+ }
+
+ // DELETE
+ Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ }
+ }
+
/*
* Generates the test cases involved in testing TP Options. See inline comments for descriptions of
* the particular cases considered.
final String testOneOptionsName = "TestOneOptions";
int optionsCounter = 0;
List<Options> oneOptions = (List<Options>) Lists.newArrayList(
- (new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testOneOptionsName,
- TP_OPTIONS_KEY, ++optionsCounter))
- .setValue(String.format(FORMAT_STR, testOneOptionsName,
- TP_OPTIONS_VALUE, optionsCounter))
- .build()));
+ (new OptionsBuilder()
+ .setOption(String.format(FORMAT_STR, testOneOptionsName,
+ TP_OPTIONS_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR, testOneOptionsName,
+ TP_OPTIONS_VALUE, optionsCounter))
+ .build()));
Map<String,List<Options>> testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, oneOptions);
testCase.put(INPUT_VALUES_KEY, oneOptions);
// Test Type: Positive
// Description: Create a termination point with multiple (five) Options
// Expected: A termination point is created with the five options specified below
- final String testFiveOptions = "TestFiveOptions";
+ final String testFiveOptionsName = "TestFiveOptions";
optionsCounter = 0;
List<Options> fiveOptions = (List<Options>) Lists.newArrayList(
- (new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_KEY, ++optionsCounter))
- .setValue(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_VALUE, optionsCounter))
- .build()),
- (new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_KEY, ++optionsCounter))
- .setValue(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_VALUE, optionsCounter))
- .build()),
- (new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_KEY, ++optionsCounter))
- .setValue(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_VALUE, optionsCounter))
- .build()),
- (new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_KEY, ++optionsCounter))
- .setValue(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_VALUE, optionsCounter))
- .build()),
- (new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_KEY, ++optionsCounter))
- .setValue(String.format(FORMAT_STR, testFiveOptions,
- TP_OPTIONS_VALUE, optionsCounter))
- .build()));
+ (new OptionsBuilder()
+ .setOption(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_VALUE, optionsCounter))
+ .build()),
+ (new OptionsBuilder()
+ .setOption(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_VALUE, optionsCounter))
+ .build()),
+ (new OptionsBuilder()
+ .setOption(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_VALUE, optionsCounter))
+ .build()),
+ (new OptionsBuilder()
+ .setOption(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_VALUE, optionsCounter))
+ .build()),
+ (new OptionsBuilder()
+ .setOption(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR, testFiveOptionsName,
+ TP_OPTIONS_VALUE, optionsCounter))
+ .build()));
testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, fiveOptions);
testCase.put(INPUT_VALUES_KEY, fiveOptions);
- testMap.put(testOneOptionsName, testCase);
+ testMap.put(testFiveOptionsName, testCase);
// Test Case 3: TestOneGoodOptionsOneMalformedOptionsValue
// Test Type: Negative
"TestOneGoodOptionsOneMalformedOptionsValue";
optionsCounter = 0;
Options oneGood = new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testOneGoodOptionsOneMalformedOptionsValueName,
- GOOD_KEY, ++optionsCounter))
- .setValue(String.format("FORMAT_STR",
+ .setOption(String.format(FORMAT_STR, testOneGoodOptionsOneMalformedOptionsValueName,
+ GOOD_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR,
testOneGoodOptionsOneMalformedOptionsValueName,
- GOOD_VALUE, optionsCounter))
+ GOOD_VALUE, optionsCounter))
.build();
Options oneBad = new OptionsBuilder()
- .setOption(String.format(FORMAT_STR,
- testOneGoodOptionsOneMalformedOptionsValueName, NO_VALUE_FOR_KEY, ++optionsCounter))
+ .setOption(String.format(FORMAT_STR,
+ testOneGoodOptionsOneMalformedOptionsValueName, NO_VALUE_FOR_KEY, ++optionsCounter))
.build();
List<Options> oneGoodOneBadInput = (List<Options>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodOptionsOneMalformedOptionsValueName, testCase);
// Test Case 4: TestOneGoodOptionsOneMalformedOptionsKey
// Test Type: Negative
"TestOneGoodOptionsOneMalformedOptionsKey";
optionsCounter = 0;
oneGood = new OptionsBuilder()
- .setOption(String.format(FORMAT_STR, testOneGoodOptionsOneMalformedOptionsKeyName,
- GOOD_KEY, ++optionsCounter))
- .setValue(String.format("FORMAT_STR",
+ .setOption(String.format(FORMAT_STR, testOneGoodOptionsOneMalformedOptionsKeyName,
+ GOOD_KEY, ++optionsCounter))
+ .setValue(String.format(FORMAT_STR,
testOneGoodOptionsOneMalformedOptionsKeyName,
- GOOD_VALUE, optionsCounter))
+ GOOD_VALUE, optionsCounter))
.build();
oneBad = new OptionsBuilder()
- .setOption(String.format(FORMAT_STR,
- testOneGoodOptionsOneMalformedOptionsKeyName, NO_KEY_FOR_VALUE, ++optionsCounter))
+ .setOption(String.format(FORMAT_STR,
+ testOneGoodOptionsOneMalformedOptionsKeyName, NO_KEY_FOR_VALUE, ++optionsCounter))
.build();
oneGoodOneBadInput = (List<Options>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodOptionsOneMalformedOptionsKeyName, testCase);
return testMap;
}
* This is helper test method to compare a test "set" of Options against an expected "set"
*/
private void assertExpectedOptionsExist( List<Options> expected,
- List<Options> test ) {
+ List<Options> test ) {
if (expected != null) {
for (Options expectedOption : expected) {
Assert.assertTrue(test.contains(expectedOption));
}
- } else {
- Assert.assertNull(test);
- }
- }
-
- /*
- * @see <code>SouthboundIT.testCRUDTPOptions()</code>
- * This is a helper test method. The method only checks if
- * <code>updateFromInputOptions != updateToInputOptions</code>, (i.e., the updateTo "set" isn't the same
- * as the updateFrom "set". Then, the method ensures each element of erase is not an element of test, as the input
- * test cases are divergent.
- */
- private void assertOptionsErased( List<Options> updateFromInputOptions,
- List<Options> updateToInputOptions,
- List<Options> updateFromExpectedOptions,
- List<Options> updateToTestOptions ) {
-
- if (!updateFromInputOptions.containsAll(updateToInputOptions)) {
- for (Options erasedOption : updateFromExpectedOptions) {
- Assert.assertTrue(!updateToTestOptions.contains(erasedOption));
- }
}
}
@Test
public void testCRUDTerminationPointOptions() throws InterruptedException {
final String TEST_PREFIX = "CRUDTPOptions";
- final int TERMINATION_POINT_TEST_INDEX = 0;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
connectOvsdbNode(connectionInfo);
generateTerminationPointOptionsTestCases();
Map<String, Map<String, List<Options>>> updateToTestCases =
generateTerminationPointOptionsTestCases();
- Map<String, List<Options>> updateFromTestCase = null;
- List<Options> updateFromInputOptions = null;
- List<Options> updateFromExpectedOptions = null;
- List<Options> updateFromConfigurationOptions = null;
- List<Options> updateFromOperationalOptions = null;
- Map<String, List<Options>> updateToTestCase = null;
- List<Options> updateToInputOptions = null;
- List<Options> updateToExpectedOptions = null;
- List<Options> updateToConfigurationOptions = null;
- List<Options> updateToOperationalOptions = null;
- String testBridgeName = null;
- String testPortName = null;
- OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation = null;
- OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation = null;
- OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder = null;
- OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder = null;
- TerminationPointBuilder tpUpdateBuilder = null;
- NodeBuilder portUpdateNodeBuilder = null;
- NodeId testBridgeNodeId = null;
- NodeId portUpdateNodeId = null;
- InstanceIdentifier<Node> portIid = null;
- boolean result = false;
-
+ Map<String, List<Options>> updateFromTestCase;
+ List<Options> updateFromInputOptions;
+ List<Options> updateFromExpectedOptions;
+ Map<String, List<Options>> updateToTestCase;
+ List<Options> updateToInputOptions;
+ List<Options> updateToExpectedOptions;
+ String testBridgeName;
+ String testPortName;
+
+ int counter = 1;
+ ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
for (String updateFromTestCaseKey : updateFromTestCases.keySet()) {
updateFromTestCase = updateFromTestCases.get(updateFromTestCaseKey);
updateFromInputOptions = updateFromTestCase.get(INPUT_VALUES_KEY);
updateFromExpectedOptions = updateFromTestCase.get(EXPECTED_VALUES_KEY);
for (String testCaseKey : updateToTestCases.keySet()) {
- testPortName = testBridgeName = String.format("%s_%s", TEST_PREFIX, testCaseKey);
+ testPortName = testBridgeName = String.format("%s_%s_%d", TEST_PREFIX, testCaseKey, counter);
+ counter += 1;
updateToTestCase = updateToTestCases.get(testCaseKey);
updateToInputOptions = updateToTestCase.get(INPUT_VALUES_KEY);
updateToExpectedOptions = updateToTestCase.get(EXPECTED_VALUES_KEY);
- // CREATE: Create the test interface
- Assert.assertTrue(addBridge(connectionInfo, null,
- testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
- true, null, null, null));
- testBridgeNodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
- connectionInfo, new OvsdbBridgeName(testBridgeName)));
- tpCreateAugmentationBuilder = createGenericOvsdbTerminationPointAugmentationBuilder();
- tpCreateAugmentationBuilder.setName(testPortName);
- tpCreateAugmentationBuilder.setOptions(updateFromInputOptions);
- Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
-
- // READ: Read the test interface and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateFromConfigurationTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
- updateFromConfigurationOptions = updateFromConfigurationTerminationPointAugmentation
- .getOptions();
- assertExpectedOptionsExist(updateFromExpectedOptions,
- updateFromConfigurationOptions);
- updateFromOperationalTerminationPointAugmenation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
- updateFromOperationalOptions = updateFromOperationalTerminationPointAugmenation
- .getOptions();
- assertExpectedOptionsExist(updateFromExpectedOptions,
- updateFromOperationalOptions);
-
- // UPDATE: update the external_ids
- testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
- tpUpdateAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
- tpUpdateAugmentationBuilder.setOptions(updateToInputOptions);
- portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
- portUpdateNodeBuilder = new NodeBuilder();
- portUpdateNodeId = SouthboundMapper.createManagedNodeId(portIid);
- portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
- tpUpdateBuilder = new TerminationPointBuilder();
- tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
- portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
- result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
- portIid, portUpdateNodeBuilder.build());
- Thread.sleep(OVSDB_UPDATE_TIMEOUT);
- Assert.assertTrue(result);
-
- // READ: the test interface and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateToConfigurationTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
- updateToConfigurationOptions = updateToConfigurationTerminationPointAugmentation
- .getOptions();
- assertExpectedOptionsExist(updateToExpectedOptions, updateToConfigurationOptions);
- updateToOperationalTerminationPointAugmentation =
- getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
- updateToOperationalOptions = updateToOperationalTerminationPointAugmentation
- .getOptions();
- assertExpectedOptionsExist(updateToExpectedOptions, updateToOperationalOptions);
-
- // Make sure the old interface external ids aren't present in the CONFIGURATION data store
- assertOptionsErased(updateFromInputOptions, updateToInputOptions,
- updateFromExpectedOptions, updateToConfigurationOptions);
- assertOptionsErased(updateFromInputOptions, updateToInputOptions,
- updateFromExpectedOptions, updateToConfigurationOptions);
-
- // DELETE
- Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ TestCRUDTerminationPointOptionsRunnable testRunnable =
+ new TestCRUDTerminationPointOptionsRunnable(
+ connectionInfo, testBridgeName, testPortName,
+ updateFromInputOptions,
+ updateFromExpectedOptions,
+ updateToInputOptions,
+ updateToExpectedOptions);
+ executor.submit(testRunnable);
}
}
+ executor.shutdown();
+ executor.awaitTermination(5, TimeUnit.MINUTES);
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
- @Test
- public void testTerminationPointInterfaceOtherConfigs() throws InterruptedException {
- ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
- connectOvsdbNode(connectionInfo);
- Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
- OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
- NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
- connectionInfo, bridge.getBridgeName()));
- OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
- createGenericOvsdbTerminationPointAugmentationBuilder();
- String portName = "testInterfaceOtherConfigs";
- ovsdbTerminationBuilder.setName(portName);
- //setup
- InterfaceOtherConfigsBuilder interfaceBuilder1 = new InterfaceOtherConfigsBuilder();
- interfaceBuilder1.setOtherConfigKey("interfaceOtherConfigsKey1");
- interfaceBuilder1.setOtherConfigValue("interfaceOtherConfigsValue1");
- InterfaceOtherConfigsBuilder interfaceBuilder2 = new InterfaceOtherConfigsBuilder();
- interfaceBuilder2.setOtherConfigKey("interfaceOtherConfigsKey2");
- interfaceBuilder2.setOtherConfigValue("interfaceOtherConfigsValue2");
- List<InterfaceOtherConfigs> interfaceOtherConfigs = Lists.newArrayList(interfaceBuilder1.build(),
- interfaceBuilder2.build());
- ovsdbTerminationBuilder.setInterfaceOtherConfigs(interfaceOtherConfigs);
+ class TestCRUDTerminationPointOptionsRunnable implements Runnable {
+
+ ConnectionInfo connectionInfo;
+ String testBridgeName;
+ String testPortName;
+ List<Options> updateFromInputOptions;
+ List<Options> updateFromExpectedOptions;
+ List<Options> updateToInputOptions;
+ List<Options> updateToExpectedOptions;
+
+ TestCRUDTerminationPointOptionsRunnable(
+ ConnectionInfo connectionInfo, String testBridgeName,
+ String testPortName,
+ List<Options> updateFromInputOptions,
+ List<Options> updateFromExpectedOptions,
+ List<Options> updateToInputOptions,
+ List<Options> updateToExpectedOptions) {
+
+ this.connectionInfo = connectionInfo;
+ this.testBridgeName = testBridgeName;
+ this.testPortName = testPortName;
+ this.updateFromInputOptions = updateFromInputOptions;
+ this.updateFromExpectedOptions = updateFromExpectedOptions;
+ this.updateToInputOptions = updateToInputOptions;
+ this.updateToExpectedOptions = updateToExpectedOptions;
+ }
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
- Thread.sleep(1000);
- InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
- Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ @Override
+ public void run() {
+ try {
+ test();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
- OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
- terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
- if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
- List<InterfaceOtherConfigs> actualInterfaceOtherConfigs = ovsdbTerminationPointAugmentation.
- getInterfaceOtherConfigs();
- Assert.assertNotNull(actualInterfaceOtherConfigs);
- Assert.assertNotNull(interfaceOtherConfigs);
- Assert.assertTrue(interfaceOtherConfigs.size() == actualInterfaceOtherConfigs.size());
- for (InterfaceOtherConfigs interfaceOtherConfig : interfaceOtherConfigs) {
- Assert.assertTrue(actualInterfaceOtherConfigs.contains(interfaceOtherConfig));
- }
+ public void test() throws InterruptedException {
+ final int TERMINATION_POINT_TEST_INDEX = 0;
+ // CREATE: Create the test interface
+ Assert.assertTrue(addBridge(connectionInfo, null,
+ testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+ true, null, null, null, null));
+ NodeId testBridgeNodeId = createManagedNodeId(createInstanceIdentifier(
+ connectionInfo, new OvsdbBridgeName(testBridgeName)));
+ OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder =
+ createGenericOvsdbTerminationPointAugmentationBuilder();
+ tpCreateAugmentationBuilder.setName(testPortName);
+ tpCreateAugmentationBuilder.setOptions(updateFromInputOptions);
+ Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
+
+ // READ: Read the test interface and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<Options> updateFromConfigurationOptions = updateFromConfigurationTerminationPointAugmentation
+ .getOptions();
+ assertExpectedOptionsExist(updateFromExpectedOptions,
+ updateFromConfigurationOptions);
+ OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<Options> updateFromOperationalOptions = updateFromOperationalTerminationPointAugmenation
+ .getOptions();
+ assertExpectedOptionsExist(updateFromExpectedOptions,
+ updateFromOperationalOptions);
+
+ // UPDATE: update the external_ids
+ testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setOptions(updateToInputOptions);
+ InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ Assert.assertTrue(result);
+
+ // READ: the test interface and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<Options> updateToConfigurationOptions = updateToConfigurationTerminationPointAugmentation
+ .getOptions();
+ assertExpectedOptionsExist(updateToExpectedOptions, updateToConfigurationOptions);
+ assertExpectedOptionsExist(updateFromExpectedOptions, updateToConfigurationOptions);
+ OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<Options> updateToOperationalOptions = updateToOperationalTerminationPointAugmentation
+ .getOptions();
+ if (updateFromExpectedOptions != null) {
+ assertExpectedOptionsExist(updateToExpectedOptions, updateToOperationalOptions);
+ assertExpectedOptionsExist(updateFromExpectedOptions, updateToOperationalOptions);
}
+
+ // DELETE
+ Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
}
- Assert.assertTrue(deleteBridge(connectionInfo));
- Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
- @Test
- public void testTerminationPointPortOtherConfigs() throws InterruptedException {
- ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
- connectOvsdbNode(connectionInfo);
- Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
- OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
- NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
- connectionInfo, bridge.getBridgeName()));
- OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
- createGenericOvsdbTerminationPointAugmentationBuilder();
- String portName = "testPortOtherConfigs";
- ovsdbTerminationBuilder.setName(portName);
- //setup
- PortOtherConfigsBuilder portBuilder1 = new PortOtherConfigsBuilder();
- portBuilder1.setOtherConfigKey("portOtherConfigsKey1");
- portBuilder1.setOtherConfigValue("portOtherConfigsValue1");
- PortOtherConfigsBuilder portBuilder2 = new PortOtherConfigsBuilder();
- portBuilder2.setOtherConfigKey("portOtherConfigsKey2");
- portBuilder2.setOtherConfigValue("portOtherConfigsValue2");
- List<PortOtherConfigs> portOtherConfigs = Lists.newArrayList(portBuilder1.build(),
- portBuilder2.build());
- ovsdbTerminationBuilder.setPortOtherConfigs(portOtherConfigs);
+ /*
+ * Generates the test cases involved in testing Interface other_configs. See inline comments for descriptions of
+ * the particular cases considered.
+ *
+ * The return value is a Map in the form (K,V)=(testCaseName,testCase).
+ * - testCaseName is a String
+ * - testCase is a Map in the form (K,V) s.t. K=(EXPECTED_VALUES_KEY|INPUT_VALUES_KEY) and V is a List of
+ * either corresponding INPUT interface other_configs, or EXPECTED interface other_configs
+ * INPUT is the List we use when calling
+ * <code>TerminationPointAugmentationBuilder.setInterfaceOtherConfigs()</code>
+ * EXPECTED is the List we expect to receive after calling
+ * <code>TerminationPointAugmentationBuilder.getInterfaceOtherConfigs()</code>
+ */
+ private Map<String, Map<String, List<InterfaceOtherConfigs>>> generateInterfaceOtherConfigsTestCases() {
+ Map<String, Map<String, List<InterfaceOtherConfigs>>> testMap =
+ new HashMap<String, Map<String, List<InterfaceOtherConfigs>>>();
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
- InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
- Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ final String INT_OTHER_CONFIGS_KEY = "IntOtherConfigsKey";
+ final String INT_OTHER_CONFIGS_VALUE = "IntOtherConfigsValue";
+ final String FORMAT_STR = "%s_%s_%d";
+ final String GOOD_KEY = "GoodKey";
+ final String GOOD_VALUE = "GoodValue";
+ final String NO_VALUE_FOR_KEY = "NoValueForKey";
+ final String NO_KEY_FOR_VALUE = "NoKeyForValue";
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
- OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
- terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
- if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
- List<PortOtherConfigs> actualPortOtherConfigs = ovsdbTerminationPointAugmentation.
- getPortOtherConfigs();
- Assert.assertTrue((portOtherConfigs.size() == actualPortOtherConfigs.size()));
- for (PortOtherConfigs portOtherConfig : portOtherConfigs) {
- Assert.assertTrue(actualPortOtherConfigs.contains(portOtherConfig));
- }
+ // Test Case 1: TestOneOtherConfigs
+ // Test Type: Positive
+ // Description: Create an interface with one other_Configs
+ // Expected: An interface is created with the single other_configs specified below
+ final String testOneOtherConfigsName = "TestOneInterfaceOtherConfigs";
+ int otherConfigsCounter = 0;
+ List<InterfaceOtherConfigs> oneOtherConfigs = (List<InterfaceOtherConfigs>) Lists.newArrayList(
+ (new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testOneOtherConfigsName,
+ INT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testOneOtherConfigsName,
+ INT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()));
+ Map<String,List<InterfaceOtherConfigs>> testCase = Maps.newHashMap();
+ testCase.put(EXPECTED_VALUES_KEY, oneOtherConfigs);
+ testCase.put(INPUT_VALUES_KEY, oneOtherConfigs);
+ testMap.put(testOneOtherConfigsName, testCase);
+
+ // Test Case 2: TestFiveInterfaceOtherConfigs
+ // Test Type: Positive
+ // Description: Create a termination point with multiple (five) InterfaceOtherConfigs
+ // Expected: A termination point is created with the five InterfaceOtherConfigs specified below
+ final String testFiveInterfaceOtherConfigsName = "TestFiveInterfaceOtherConfigs";
+ otherConfigsCounter = 0;
+ List<InterfaceOtherConfigs> fiveInterfaceOtherConfigs = (List<InterfaceOtherConfigs>) Lists.newArrayList(
+ (new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFiveInterfaceOtherConfigsName,
+ INT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()));
+ testCase = Maps.newHashMap();
+ testCase.put(EXPECTED_VALUES_KEY, fiveInterfaceOtherConfigs);
+ testCase.put(INPUT_VALUES_KEY, fiveInterfaceOtherConfigs);
+ testMap.put(testFiveInterfaceOtherConfigsName, testCase);
+
+ // Test Case 3: TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValue
+ // Test Type: Negative
+ // Description:
+ // One perfectly fine InterfaceOtherConfigs
+ // (TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValue_InterfaceOtherConfigsKey_1,
+ // TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigs_InterfaceOtherConfigsValue_1)
+ // and one malformed InterfaceOtherConfigs which only has key specified
+ // (TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValue_NoValueForKey_2,
+ // UNSPECIFIED)
+ // Expected: A termination point is created without any InterfaceOtherConfigs
+ final String testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValueName =
+ "TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValue";
+ otherConfigsCounter = 0;
+ InterfaceOtherConfigs oneGood = new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValueName,
+ GOOD_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR,
+ testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValueName,
+ GOOD_VALUE, otherConfigsCounter))
+ .build();
+ InterfaceOtherConfigs oneBad = new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValueName, NO_VALUE_FOR_KEY,
+ ++otherConfigsCounter))
+ .build();
+ List<InterfaceOtherConfigs> oneGoodOneBadInput = (List<InterfaceOtherConfigs>) Lists.newArrayList(
+ oneGood, oneBad);
+ List<InterfaceOtherConfigs> oneGoodOneBadExpected = null;
+ testCase = Maps.newHashMap();
+ testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
+ testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValueName, testCase);
+
+ // Test Case 4: TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKey
+ // Test Type: Negative
+ // Description:
+ // One perfectly fine InterfaceOtherConfigs
+ // (TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsValue_InterfaceOtherConfigsKey_1,
+ // TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigs_InterfaceOtherConfigsValue_1)
+ // and one malformed InterfaceOtherConfigs which only has key specified
+ // (UNSPECIFIED,
+ // TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKey_NoKeyForValue_2)
+ // Expected: A termination point is created without any InterfaceOtherConfigs
+ final String testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKeyName =
+ "TestOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKey";
+ otherConfigsCounter = 0;
+ oneGood = new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKeyName,
+ GOOD_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR,
+ testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKeyName,
+ GOOD_VALUE, otherConfigsCounter))
+ .build();
+ oneBad = new InterfaceOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKeyName, NO_KEY_FOR_VALUE,
+ ++otherConfigsCounter))
+ .build();
+ oneGoodOneBadInput = (List<InterfaceOtherConfigs>) Lists.newArrayList(
+ oneGood, oneBad);
+ oneGoodOneBadExpected = null;
+ testCase = Maps.newHashMap();
+ testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
+ testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodInterfaceOtherConfigsOneMalformedInterfaceOtherConfigsKeyName, testCase);
+
+ return testMap;
+ }
+
+ /*
+ * @see <code>SouthboundIT.testCRUDInterfaceOtherConfigs()</code>
+ * This is helper test method to compare a test "set" of Options against an expected "set"
+ */
+ private void assertExpectedInterfaceOtherConfigsExist( List<InterfaceOtherConfigs> expected,
+ List<InterfaceOtherConfigs> test ) {
+
+ if (expected != null && test != null) {
+ for (InterfaceOtherConfigs expectedOtherConfigs : expected) {
+ Assert.assertTrue(test.contains(expectedOtherConfigs));
}
}
- Assert.assertTrue(deleteBridge(connectionInfo));
- Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
+ /*
+ * Tests the CRUD operations for <code>Interface</code> <code>other_configs</code>.
+ *
+ * @see <code>SouthboundIT.generateInterfaceExternalIdsTestCases()</code> for specific test case information
+ */
@Test
- public void testTerminationPointVlan() throws InterruptedException {
+ public void testCRUDTerminationPointInterfaceOtherConfigs() throws InterruptedException {
+ final String TEST_PREFIX = "CRUDTPInterfaceOtherConfigs";
+
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
connectOvsdbNode(connectionInfo);
- Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
- OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
- NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
- connectionInfo, bridge.getBridgeName()));
- OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
- createGenericOvsdbTerminationPointAugmentationBuilder();
- String portName = "testTerminationPointVlanId";
- ovsdbTerminationBuilder.setName(portName);
- //setup
- Integer vlanId = new Integer(4000);
- ovsdbTerminationBuilder.setVlanTag(new VlanId(vlanId));
-
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
- InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
- Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
- OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
- terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
- if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
- //test
- VlanId actualVlanId = ovsdbTerminationPointAugmentation.getVlanTag();
- Assert.assertNotNull(actualVlanId);
- Integer actualVlanIdInt = actualVlanId.getValue();
- Assert.assertTrue(actualVlanIdInt.equals(vlanId));
+ // updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
+ // the update has been performed.
+ Map<String, Map<String, List<InterfaceOtherConfigs>>> updateFromTestCases =
+ generateInterfaceOtherConfigsTestCases();
+ Map<String, Map<String, List<InterfaceOtherConfigs>>> updateToTestCases =
+ generateInterfaceOtherConfigsTestCases();
+ Map<String, List<InterfaceOtherConfigs>> updateFromTestCase;
+ List<InterfaceOtherConfigs> updateFromInputOtherConfigs;
+ List<InterfaceOtherConfigs> updateFromExpectedOtherConfigs;
+ Map<String, List<InterfaceOtherConfigs>> updateToTestCase;
+ List<InterfaceOtherConfigs> updateToInputOtherConfigs;
+ List<InterfaceOtherConfigs> updateToExpectedOtherConfigs;
+ String testBridgeName;
+ String testPortName;
+
+ int counter = 1;
+ ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
+ for (String updateFromTestCaseKey : updateFromTestCases.keySet()) {
+ updateFromTestCase = updateFromTestCases.get(updateFromTestCaseKey);
+ updateFromInputOtherConfigs = updateFromTestCase.get(INPUT_VALUES_KEY);
+ updateFromExpectedOtherConfigs = updateFromTestCase.get(EXPECTED_VALUES_KEY);
+ for (String testCaseKey : updateToTestCases.keySet()) {
+ testPortName = testBridgeName = String.format("%s_%s_%d", TEST_PREFIX, testCaseKey, counter);
+ counter += 1;
+ updateToTestCase = updateToTestCases.get(testCaseKey);
+ updateToInputOtherConfigs = updateToTestCase.get(INPUT_VALUES_KEY);
+ updateToExpectedOtherConfigs = updateToTestCase.get(EXPECTED_VALUES_KEY);
+
+ TestCRUDTerminationPointInterfaceOtherConfigsRunnable testRunnable =
+ new TestCRUDTerminationPointInterfaceOtherConfigsRunnable(
+ connectionInfo, testBridgeName, testPortName,
+ updateFromInputOtherConfigs,
+ updateFromExpectedOtherConfigs,
+ updateToInputOtherConfigs,
+ updateToExpectedOtherConfigs);
+ executor.submit(testRunnable);
}
}
- Assert.assertTrue(deleteBridge(connectionInfo));
+ executor.shutdown();
+ executor.awaitTermination(5, TimeUnit.MINUTES);
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
- @Test
- public void testTerminationPointVlanModes() throws InterruptedException {
- ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
- connectOvsdbNode(connectionInfo);
+ class TestCRUDTerminationPointInterfaceOtherConfigsRunnable implements Runnable {
+
+ ConnectionInfo connectionInfo;
+ String testBridgeName;
+ String testPortName;
+ List<InterfaceOtherConfigs> updateFromInputOtherConfigs;
+ List<InterfaceOtherConfigs> updateFromExpectedOtherConfigs;
+ List<InterfaceOtherConfigs> updateToInputOtherConfigs;
+ List<InterfaceOtherConfigs> updateToExpectedOtherConfigs;
+
+ TestCRUDTerminationPointInterfaceOtherConfigsRunnable(
+ ConnectionInfo connectionInfo, String testBridgeName,
+ String testPortName,
+ List<InterfaceOtherConfigs> updateFromInputOtherConfigs,
+ List<InterfaceOtherConfigs> updateFromExpectedOtherConfigs,
+ List<InterfaceOtherConfigs> updateToInputOtherConfigs,
+ List<InterfaceOtherConfigs> updateToExpectedOtherConfigs) {
+
+ this.connectionInfo = connectionInfo;
+ this.testBridgeName = testBridgeName;
+ this.testPortName = testPortName;
+ this.updateFromInputOtherConfigs = updateFromInputOtherConfigs;
+ this.updateFromExpectedOtherConfigs = updateFromExpectedOtherConfigs;
+ this.updateToInputOtherConfigs = updateToInputOtherConfigs;
+ this.updateToExpectedOtherConfigs = updateToExpectedOtherConfigs;
+ }
+
+ @Override
+ public void run() {
+ try {
+ test();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void test() throws InterruptedException {
+ final int TERMINATION_POINT_TEST_INDEX = 0;
+
+ // CREATE: Create the test interface
+ Assert.assertTrue(addBridge(connectionInfo, null,
+ testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+ true, null, null, null, null));
+ NodeId testBridgeNodeId = createManagedNodeId(createInstanceIdentifier(
+ connectionInfo, new OvsdbBridgeName(testBridgeName)));
+ OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder =
+ createGenericOvsdbTerminationPointAugmentationBuilder();
+ tpCreateAugmentationBuilder.setName(testPortName);
+ tpCreateAugmentationBuilder.setInterfaceOtherConfigs(updateFromInputOtherConfigs);
+ Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
+
+ // READ: Read the test interface and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceOtherConfigs> updateFromConfigurationOtherConfigs;
+ if (updateFromConfigurationTerminationPointAugmentation != null) {
+ updateFromConfigurationOtherConfigs = updateFromConfigurationTerminationPointAugmentation
+ .getInterfaceOtherConfigs();
+ } else {
+ updateFromConfigurationOtherConfigs = null;
+ }
+ assertExpectedInterfaceOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateFromConfigurationOtherConfigs);
+ OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceOtherConfigs> updateFromOperationalOtherConfigs =
+ updateFromOperationalTerminationPointAugmenation.getInterfaceOtherConfigs();
+ if (updateFromOperationalOtherConfigs != null) {
+ updateFromOperationalOtherConfigs = updateFromOperationalTerminationPointAugmenation
+ .getInterfaceOtherConfigs();
+ } else {
+ updateFromOperationalOtherConfigs = null;
+ }
+ assertExpectedInterfaceOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateFromOperationalOtherConfigs);
+
+ // UPDATE: update the other_configs
+ testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setInterfaceOtherConfigs(updateToInputOtherConfigs);
+ InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ Assert.assertTrue(result);
+
+ // READ: the test interface and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceOtherConfigs> updateToConfigurationOtherConfigs =
+ updateToConfigurationTerminationPointAugmentation
+ .getInterfaceOtherConfigs();
+ assertExpectedInterfaceOtherConfigsExist(updateToExpectedOtherConfigs,
+ updateToConfigurationOtherConfigs);
+ assertExpectedInterfaceOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateToConfigurationOtherConfigs);
+ OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<InterfaceOtherConfigs> updateToOperationalOtherConfigs =
+ updateToOperationalTerminationPointAugmentation
+ .getInterfaceOtherConfigs();
+ if (updateFromExpectedOtherConfigs != null) {
+ assertExpectedInterfaceOtherConfigsExist(updateToExpectedOtherConfigs,
+ updateToOperationalOtherConfigs);
+ assertExpectedInterfaceOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateToOperationalOtherConfigs);
+ }
+
+ // DELETE
+ Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ }
+ }
+
+ /*
+ * Generates the test cases involved in testing Port other_configs. See inline comments for descriptions of
+ * the particular cases considered.
+ *
+ * The return value is a Map in the form (K,V)=(testCaseName,testCase).
+ * - testCaseName is a String
+ * - testCase is a Map in the form (K,V) s.t. K=(EXPECTED_VALUES_KEY|INPUT_VALUES_KEY) and V is a List of
+ * either corresponding INPUT port other_configs, or EXPECTED port other_configs
+ * INPUT is the List we use when calling
+ * <code>TerminationPointAugmentationBuilder.setPortOtherConfigs()</code>
+ * EXPECTED is the List we expect to receive after calling
+ * <code>TerminationPointAugmentationBuilder.getPortOtherConfigs()</code>
+ */
+ private Map<String, Map<String, List<PortOtherConfigs>>> generatePortOtherConfigsTestCases() {
+ Map<String, Map<String, List<PortOtherConfigs>>> testMap =
+ new HashMap<String, Map<String, List<PortOtherConfigs>>>();
+
+ final String PORT_OTHER_CONFIGS_KEY = "PortOtherConfigsKey";
+ final String PORT_OTHER_CONFIGS_VALUE = "PortOtherConfigsValue";
+ final String FORMAT_STR = "%s_%s_%d";
+ final String GOOD_KEY = "GoodKey";
+ final String GOOD_VALUE = "GoodValue";
+ final String NO_VALUE_FOR_KEY = "NoValueForKey";
+ final String NO_KEY_FOR_VALUE = "NoKeyForValue";
+
+ // Test Case 1: TestOneOtherConfigs
+ // Test Type: Positive
+ // Description: Create an port with one other_Configs
+ // Expected: A port is created with the single other_configs specified below
+ final String testOneOtherConfigsName = "TestOnePortOtherConfigs";
+ int otherConfigsCounter = 0;
+ List<PortOtherConfigs> oneOtherConfigs = (List<PortOtherConfigs>) Lists.newArrayList(
+ (new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testOneOtherConfigsName,
+ PORT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testOneOtherConfigsName,
+ PORT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()));
+ Map<String,List<PortOtherConfigs>> testCase = Maps.newHashMap();
+ testCase.put(EXPECTED_VALUES_KEY, oneOtherConfigs);
+ testCase.put(INPUT_VALUES_KEY, oneOtherConfigs);
+ testMap.put(testOneOtherConfigsName, testCase);
+
+ // Test Case 2: TestFivePortOtherConfigs
+ // Test Type: Positive
+ // Description: Create a termination point with multiple (five) PortOtherConfigs
+ // Expected: A termination point is created with the five PortOtherConfigs specified below
+ final String testFivePortOtherConfigsName = "TestFivePortOtherConfigs";
+ otherConfigsCounter = 0;
+ List<PortOtherConfigs> fivePortOtherConfigs = (List<PortOtherConfigs>) Lists.newArrayList(
+ (new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()),
+ (new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR, testFivePortOtherConfigsName,
+ PORT_OTHER_CONFIGS_VALUE, otherConfigsCounter))
+ .build()));
+ testCase = Maps.newHashMap();
+ testCase.put(EXPECTED_VALUES_KEY, fivePortOtherConfigs);
+ testCase.put(INPUT_VALUES_KEY, fivePortOtherConfigs);
+ testMap.put(testFivePortOtherConfigsName, testCase);
+
+ // Test Case 3: TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValue
+ // Test Type: Negative
+ // Description:
+ // One perfectly fine PortOtherConfigs
+ // (TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValue_PortOtherConfigsKey_1,
+ // TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigs_PortOtherConfigsValue_1)
+ // and one malformed PortOtherConfigs which only has key specified
+ // (TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValue_NoValueForKey_2,
+ // UNSPECIFIED)
+ // Expected: A termination point is created without any PortOtherConfigs
+ final String testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValueName =
+ "TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValue";
+ otherConfigsCounter = 0;
+ PortOtherConfigs oneGood = new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValueName,
+ GOOD_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR,
+ testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValueName,
+ GOOD_VALUE, otherConfigsCounter))
+ .build();
+ PortOtherConfigs oneBad = new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValueName, NO_VALUE_FOR_KEY,
+ ++otherConfigsCounter))
+ .build();
+ List<PortOtherConfigs> oneGoodOneBadInput = (List<PortOtherConfigs>) Lists.newArrayList(
+ oneGood, oneBad);
+ List<PortOtherConfigs> oneGoodOneBadExpected = null;
+ testCase = Maps.newHashMap();
+ testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
+ testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValueName, testCase);
+
+ // Test Case 4: TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKey
+ // Test Type: Negative
+ // Description:
+ // One perfectly fine PortOtherConfigs
+ // (TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsValue_PortOtherConfigsKey_1,
+ // TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigs_PortOtherConfigsValue_1)
+ // and one malformed PortOtherConfigs which only has key specified
+ // (UNSPECIFIED,
+ // TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKey_NoKeyForValue_2)
+ // Expected: A termination point is created without any PortOtherConfigs
+ final String testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKeyName =
+ "TestOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKey";
+ otherConfigsCounter = 0;
+ oneGood = new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKeyName,
+ GOOD_KEY, ++otherConfigsCounter))
+ .setOtherConfigValue(String.format(FORMAT_STR,
+ testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKeyName,
+ GOOD_VALUE, otherConfigsCounter))
+ .build();
+ oneBad = new PortOtherConfigsBuilder()
+ .setOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKeyName, NO_KEY_FOR_VALUE,
+ ++otherConfigsCounter))
+ .build();
+ oneGoodOneBadInput = (List<PortOtherConfigs>) Lists.newArrayList(
+ oneGood, oneBad);
+ oneGoodOneBadExpected = null;
+ testCase = Maps.newHashMap();
+ testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
+ testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodPortOtherConfigsOneMalformedPortOtherConfigsKeyName, testCase);
+
+ return testMap;
+ }
+
+ /*
+ * @see <code>SouthboundIT.testCRUDPortOtherConfigs()</code>
+ * This is helper test method to compare a test "set" of Options against an expected "set"
+ */
+ private void assertExpectedPortOtherConfigsExist( List<PortOtherConfigs> expected,
+ List<PortOtherConfigs> test ) {
+
+ if (expected != null && test != null) {
+ for (PortOtherConfigs expectedOtherConfigs : expected) {
+ Assert.assertTrue(test.contains(expectedOtherConfigs));
+ }
+ }
+ }
+
+ /*
+ * Tests the CRUD operations for <code>Port</code> <code>other_configs</code>.
+ *
+ * @see <code>SouthboundIT.generatePortExternalIdsTestCases()</code> for specific test case information
+ */
+ @Test
+ public void testCRUDTerminationPointPortOtherConfigs() throws InterruptedException {
+ final String TEST_PREFIX = "CRUDTPPortOtherConfigs";
+
+ ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
+ connectOvsdbNode(connectionInfo);
+
+ // updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
+ // the update has been performed.
+ Map<String, Map<String, List<PortOtherConfigs>>> updateFromTestCases =
+ generatePortOtherConfigsTestCases();
+ Map<String, Map<String, List<PortOtherConfigs>>> updateToTestCases =
+ generatePortOtherConfigsTestCases();
+ Map<String, List<PortOtherConfigs>> updateFromTestCase;
+ List<PortOtherConfigs> updateFromInputOtherConfigs;
+ List<PortOtherConfigs> updateFromExpectedOtherConfigs;
+ Map<String, List<PortOtherConfigs>> updateToTestCase;
+ List<PortOtherConfigs> updateToInputOtherConfigs;
+ List<PortOtherConfigs> updateToExpectedOtherConfigs;
+ String testBridgeName;
+ String testPortName;
+
+ int counter = 1;
+ ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
+ for (String updateFromTestCaseKey : updateFromTestCases.keySet()) {
+ updateFromTestCase = updateFromTestCases.get(updateFromTestCaseKey);
+ updateFromInputOtherConfigs = updateFromTestCase.get(INPUT_VALUES_KEY);
+ updateFromExpectedOtherConfigs = updateFromTestCase.get(EXPECTED_VALUES_KEY);
+ for (String testCaseKey : updateToTestCases.keySet()) {
+ testPortName = testBridgeName = String.format("%s_%s_%d", TEST_PREFIX, testCaseKey, counter);
+ counter += 1;
+ updateToTestCase = updateToTestCases.get(testCaseKey);
+ updateToInputOtherConfigs = updateToTestCase.get(INPUT_VALUES_KEY);
+ updateToExpectedOtherConfigs = updateToTestCase.get(EXPECTED_VALUES_KEY);
+
+ TestCRUDTerminationPointPortOtherConfigsRunnable testRunnable =
+ new TestCRUDTerminationPointPortOtherConfigsRunnable(
+ connectionInfo, testBridgeName, testPortName,
+ updateFromInputOtherConfigs,
+ updateFromExpectedOtherConfigs,
+ updateToInputOtherConfigs,
+ updateToExpectedOtherConfigs);
+ executor.submit(testRunnable);
+ }
+ }
+ executor.shutdown();
+ executor.awaitTermination(5, TimeUnit.MINUTES);
+ Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ }
+
+ class TestCRUDTerminationPointPortOtherConfigsRunnable implements Runnable {
+ ConnectionInfo connectionInfo;
+ String testBridgeName;
+ String testPortName;
+ List<PortOtherConfigs> updateFromInputOtherConfigs;
+ List<PortOtherConfigs> updateFromExpectedOtherConfigs;
+ List<PortOtherConfigs> updateToInputOtherConfigs;
+ List<PortOtherConfigs> updateToExpectedOtherConfigs;
+
+ TestCRUDTerminationPointPortOtherConfigsRunnable(
+ ConnectionInfo connectionInfo, String testBridgeName,
+ String testPortName,
+ List<PortOtherConfigs> updateFromInputOtherConfigs,
+ List<PortOtherConfigs> updateFromExpectedOtherConfigs,
+ List<PortOtherConfigs> updateToInputOtherConfigs,
+ List<PortOtherConfigs> updateToExpectedOtherConfigs) {
+
+ this.connectionInfo = connectionInfo;
+ this.testBridgeName = testBridgeName;
+ this.testPortName = testPortName;
+ this.updateFromInputOtherConfigs = updateFromInputOtherConfigs;
+ this.updateFromExpectedOtherConfigs = updateFromExpectedOtherConfigs;
+ this.updateToInputOtherConfigs = updateToInputOtherConfigs;
+ this.updateToExpectedOtherConfigs = updateToExpectedOtherConfigs;
+ }
+
+ @Override
+ public void run() {
+ try {
+ test();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void test() throws InterruptedException {
+ final int TERMINATION_POINT_TEST_INDEX = 0;
+ // CREATE: Create the test port
+ Assert.assertTrue(addBridge(connectionInfo, null,
+ testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+ true, null, null, null, null));
+ NodeId testBridgeNodeId = createManagedNodeId(createInstanceIdentifier(
+ connectionInfo, new OvsdbBridgeName(testBridgeName)));
+ OvsdbTerminationPointAugmentationBuilder tpCreateAugmentationBuilder =
+ createGenericOvsdbTerminationPointAugmentationBuilder();
+ tpCreateAugmentationBuilder.setName(testPortName);
+ tpCreateAugmentationBuilder.setPortOtherConfigs(updateFromInputOtherConfigs);
+ Assert.assertTrue(addTerminationPoint(testBridgeNodeId, testPortName, tpCreateAugmentationBuilder));
+
+ // READ: Read the test port and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<PortOtherConfigs> updateFromConfigurationOtherConfigs;
+ if (updateFromConfigurationTerminationPointAugmentation != null) {
+ updateFromConfigurationOtherConfigs = updateFromConfigurationTerminationPointAugmentation
+ .getPortOtherConfigs();
+ } else {
+ updateFromConfigurationOtherConfigs = null;
+ }
+ assertExpectedPortOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateFromConfigurationOtherConfigs);
+ OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmenation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<PortOtherConfigs> updateFromOperationalOtherConfigs =
+ updateFromOperationalTerminationPointAugmenation.getPortOtherConfigs();
+ if (updateFromOperationalOtherConfigs != null) {
+ updateFromOperationalOtherConfigs = updateFromOperationalTerminationPointAugmenation
+ .getPortOtherConfigs();
+ } else {
+ updateFromOperationalOtherConfigs = null;
+ }
+ assertExpectedPortOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateFromOperationalOtherConfigs);
+
+ // UPDATE: update the other_configs
+ testBridgeNodeId = getBridgeNode(connectionInfo, testBridgeName).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setPortOtherConfigs(updateToInputOtherConfigs);
+ InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(testPortName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ Assert.assertTrue(result);
+
+ // READ: the test port and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ List<PortOtherConfigs> updateToConfigurationOtherConfigs = updateToConfigurationTerminationPointAugmentation
+ .getPortOtherConfigs();
+ assertExpectedPortOtherConfigsExist(updateToExpectedOtherConfigs,
+ updateToConfigurationOtherConfigs);
+ assertExpectedPortOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateToConfigurationOtherConfigs);
+ OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation =
+ getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeName,
+ LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ List<PortOtherConfigs> updateToOperationalOtherConfigs = updateToOperationalTerminationPointAugmentation
+ .getPortOtherConfigs();
+ if (updateFromExpectedOtherConfigs != null) {
+ assertExpectedPortOtherConfigsExist(updateToExpectedOtherConfigs,
+ updateToOperationalOtherConfigs);
+ assertExpectedPortOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateToOperationalOtherConfigs);
+ }
+
+ // DELETE
+ Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ }
+ }
+
+ @Test
+ public void testCRUDTerminationPointVlan() throws InterruptedException {
+ final Integer CREATED_VLAN_ID = new Integer(4000);
+ final Integer UPDATED_VLAN_ID = new Integer(4001);
+
+ ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
+ connectOvsdbNode(connectionInfo);
+
+ // CREATE
+ Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
+ OvsdbBridgeAugmentation bridge = getBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
+ Assert.assertNotNull(bridge);
+ NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
+ connectionInfo, bridge.getBridgeName()));
+ OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
+ createGenericOvsdbTerminationPointAugmentationBuilder();
+ String portName = "testTerminationPointVlanId";
+ ovsdbTerminationBuilder.setName(portName);
+ ovsdbTerminationBuilder.setVlanTag(new VlanId(CREATED_VLAN_ID));
+ Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
+ Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+ Assert.assertNotNull(terminationPointNode);
+
+ // READ
+ List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
+ OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation = null;
+ for (TerminationPoint terminationPoint : terminationPoints) {
+ ovsdbTerminationPointAugmentation = terminationPoint.getAugmentation(
+ OvsdbTerminationPointAugmentation.class);
+ if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
+ VlanId actualVlanId = ovsdbTerminationPointAugmentation.getVlanTag();
+ Assert.assertNotNull(actualVlanId);
+ Integer actualVlanIdInt = actualVlanId.getValue();
+ Assert.assertEquals(CREATED_VLAN_ID, actualVlanIdInt);
+ }
+ }
+
+ // UPDATE
+ NodeId testBridgeNodeId = getBridgeNode(connectionInfo, SouthboundITConstants.BRIDGE_NAME).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setVlanTag(new VlanId(UPDATED_VLAN_ID));
+ InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(portName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ tpUpdateBuilder.setTpId(new TpId(portName));
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Assert.assertTrue(result);
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+
+ terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+ terminationPoints = terminationPointNode.getTerminationPoint();
+ for (TerminationPoint terminationPoint : terminationPoints) {
+ ovsdbTerminationPointAugmentation = terminationPoint.getAugmentation(
+ OvsdbTerminationPointAugmentation.class);
+ if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
+ VlanId actualVlanId = ovsdbTerminationPointAugmentation.getVlanTag();
+ Assert.assertNotNull(actualVlanId);
+ Integer actualVlanIdInt = actualVlanId.getValue();
+ Assert.assertEquals(UPDATED_VLAN_ID, actualVlanIdInt);
+ }
+ }
+
+ // DELETE
+ Assert.assertTrue(deleteBridge(connectionInfo));
+ Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ }
+
+ @Test
+ public void testCRUDTerminationPointVlanModes() throws InterruptedException {
+ final VlanMode UPDATED_VLAN_MODE = VlanMode.Access;
+ ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
+ connectOvsdbNode(connectionInfo);
VlanMode []vlanModes = VlanMode.values();
for (VlanMode vlanMode : vlanModes) {
-
+ // CREATE
Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
Assert.assertNotNull(bridge);
- NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
+ NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testTerminationPointVlanMode" + vlanMode.toString();
ovsdbTerminationBuilder.setName(portName);
- //setup
ovsdbTerminationBuilder.setVlanMode(vlanMode);
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
Assert.assertNotNull(terminationPointNode);
+ // READ
List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
for (TerminationPoint terminationPoint : terminationPoints) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
Assert.assertTrue(ovsdbTerminationPointAugmentation.getVlanMode().equals(vlanMode));
}
}
+
+ // UPDATE
+ NodeId testBridgeNodeId = getBridgeNode(connectionInfo, SouthboundITConstants.BRIDGE_NAME).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setVlanMode(UPDATED_VLAN_MODE);
+ InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(portName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ tpUpdateBuilder.setTpId(new TpId(portName));
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Assert.assertTrue(result);
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+
+ terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+ terminationPoints = terminationPointNode.getTerminationPoint();
+ for (TerminationPoint terminationPoint : terminationPoints) {
+ OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
+ terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
+ if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
+ //test
+ Assert.assertEquals(UPDATED_VLAN_MODE, ovsdbTerminationPointAugmentation.getVlanMode());
+ }
+ }
+
+ // DELETE
Assert.assertTrue(deleteBridge(connectionInfo));
}
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
@Test
- public void testTerminationPointVlanTrunks() throws InterruptedException {
+ public void testCRUDTerminationPointVlanTrunks() throws InterruptedException {
+ final List<Trunks> UPDATED_TRUNKS = buildTrunkList(Sets.newHashSet(2011));
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
connectOvsdbNode(connectionInfo);
- ArrayList<Set<Integer>> vlanSets = generateVlanSets();
+ Iterable<Set<Integer>> vlanSets = generateVlanSets();
int testCase = 0;
for (Set<Integer> vlanSet : vlanSets) {
++testCase;
+ // CREATE
Assert.assertTrue(addBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME));
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
Assert.assertNotNull(bridge);
- NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundMapper.createInstanceIdentifier(
+ NodeId nodeId = createManagedNodeId(createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testTerminationPointVlanTrunks" + testCase;
ovsdbTerminationBuilder.setName(portName);
- //setup
List<Trunks> trunks = buildTrunkList(vlanSet);
ovsdbTerminationBuilder.setTrunks(trunks);
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
Assert.assertNotNull(terminationPointNode);
+ // READ
List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
for (TerminationPoint terminationPoint : terminationPoints) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
}
}
}
+
+
+ // UPDATE
+ NodeId testBridgeNodeId = getBridgeNode(connectionInfo, SouthboundITConstants.BRIDGE_NAME).getNodeId();
+ OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
+ new OvsdbTerminationPointAugmentationBuilder();
+ tpUpdateAugmentationBuilder.setTrunks(UPDATED_TRUNKS);
+ InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
+ NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
+ NodeId portUpdateNodeId = createManagedNodeId(portIid);
+ portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
+ TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
+ tpUpdateBuilder.setKey(new TerminationPointKey(new TpId(portName)));
+ tpUpdateBuilder.addAugmentation(
+ OvsdbTerminationPointAugmentation.class,
+ tpUpdateAugmentationBuilder.build());
+ tpUpdateBuilder.setTpId(new TpId(portName));
+ portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ portIid, portUpdateNodeBuilder.build());
+ Assert.assertTrue(result);
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+
+ terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
+ terminationPoints = terminationPointNode.getTerminationPoint();
+ for (TerminationPoint terminationPoint : terminationPoints) {
+ OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
+ terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
+ if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
+ //test
+ Assert.assertEquals(UPDATED_TRUNKS, ovsdbTerminationPointAugmentation.getTrunks());
+ }
+ }
+
+ // DELETE
Assert.assertTrue(deleteBridge(connectionInfo));
}
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
.child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, topologyPath);
- Assert.assertEquals("There should only be one node in the topology", 1, topology.getNode().size());
- InstanceIdentifier<Node> expectedNodeIid = SouthboundMapper.createInstanceIdentifier(connectionInfo);
- Node node = topology.getNode().iterator().next();
+ InstanceIdentifier<Node> expectedNodeIid = createInstanceIdentifier(connectionInfo);
NodeId expectedNodeId = expectedNodeIid.firstKeyOf(Node.class, NodeKey.class).getNodeId();
- Assert.assertEquals(expectedNodeId, node.getNodeId());
+ Node foundNode = null;
+ Assert.assertNotNull("Expected to find topology: " + topologyPath, topology);
+ Assert.assertNotNull("Expected to find some nodes" + topology.getNode());
+ LOG.info("expectedNodeId: {}, getNode: {}", expectedNodeId, topology.getNode());
+ for (Node node : topology.getNode()) {
+ if (node.getNodeId().getValue().equals(expectedNodeId.getValue())) {
+ foundNode = node;
+ break;
+ }
+ }
+ Assert.assertNotNull("Expected to find Node: " + expectedNodeId, foundNode);
Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
}
- /*
- * Generates the test cases involved in testing BridgeExternalIds. See inline comments for descriptions of
- * the particular cases considered.
- *
- * The return value is a Map in the form (K,V)=(testCaseName,testCase).
- * - testCaseName is a String
- * - testCase is a Map in the form (K,V) s.t. K=(EXPECTED_VALUES_KEY|INPUT_VALUES_KEY) and V is a List of
- * either corresponding INPUT bridge external ids, or EXPECTED bridge external ids
- * INPUT is the List we use when calling BridgeAugmentationBuilder.setBridgeExternalIds()
- * EXPECTED is the List we expect to receive after calling BridgeAugmentationBuilder.getBridgeExternalIds()
- */
- private Map<String, Map<String, List<BridgeExternalIds>>> generateBridgeExternalIdsTestCases() {
- Map<String, Map<String, List<BridgeExternalIds>>> testMap =
- new HashMap<String, Map<String, List<BridgeExternalIds>>>();
-
- final String BRIDGE_EXTERNAL_ID_KEY = "BridgeExternalIdKey";
- final String BRIDGE_EXTERNAL_ID_VALUE = "BridgeExternalIdValue";
- final String FORMAT_STR = "%s_%s_%d";
- final String GOOD_KEY = "GoodKey";
- final String GOOD_VALUE = "GoodValue";
- final String NO_VALUE_FOR_KEY = "NoValueForKey";
- final String NO_KEY_FOR_VALUE = "NoKeyForValue";
-
- // Test Case 1: TestOneExternalId
- // Test Type: Positive
- // Description: Create a bridge with one BridgeExternalIds
- // Expected: A bridge is created with the single external_ids specified below
- final String testOneExternalIdName = "TestOneExternalId";
- int externalIdCounter = 0;
- List<BridgeExternalIds> oneExternalId = (List<BridgeExternalIds>) Lists.newArrayList(
- (new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testOneExternalIdName,
- BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format(FORMAT_STR, testOneExternalIdName,
- BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()));
- Map<String,List<BridgeExternalIds>> testCase = Maps.newHashMap();
- testCase.put(EXPECTED_VALUES_KEY, oneExternalId);
- testCase.put(INPUT_VALUES_KEY, oneExternalId);
- testMap.put(testOneExternalIdName, testCase);
-
- // Test Case 2: TestFiveExternalId
- // Test Type: Positive
- // Description: Create a bridge with multiple (five) BridgeExternalIds
- // Expected: A bridge is created with the five external_ids specified below
- final String testFiveExternalIdName = "TestFiveExternalId";
- externalIdCounter = 0;
- List<BridgeExternalIds> fiveExternalId = (List<BridgeExternalIds>) Lists.newArrayList(
- (new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()),
- (new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
- BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
- .build()));
- testCase = Maps.newHashMap();
- testCase.put(EXPECTED_VALUES_KEY, fiveExternalId);
- testCase.put(INPUT_VALUES_KEY, fiveExternalId);
- testMap.put(testOneExternalIdName, testCase);
-
- // Test Case 3: TestOneGoodExternalIdOneMalformedExternalIdValue
- // Test Type: Negative
- // Description:
- // One perfectly fine BridgeExternalId
- // (TestOneGoodExternalIdOneMalformedExternalIdValue_BridgeExternalIdKey_1,
- // TestOneGoodExternalIdOneMalformedExternalId_BridgeExternalIdValue_1)
- // and one malformed BridgeExternalId which only has key specified
- // (TestOneGoodExternalIdOneMalformedExternalIdValue_NoValueForKey_2,
- // UNSPECIFIED)
- // Expected: A bridge is created without any external_ids
- final String testOneGoodExternalIdOneMalformedExternalIdValueName =
- "TestOneGoodExternalIdOneMalformedExternalIdValue";
- externalIdCounter = 0;
- BridgeExternalIds oneGood = new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdValueName,
- GOOD_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format("FORMAT_STR",
- testOneGoodExternalIdOneMalformedExternalIdValueName,
- GOOD_VALUE, externalIdCounter))
- .build();
- BridgeExternalIds oneBad = new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR,
- testOneGoodExternalIdOneMalformedExternalIdValueName, NO_VALUE_FOR_KEY, ++externalIdCounter))
- .build();
- List<BridgeExternalIds> oneGoodOneBadInput = (List<BridgeExternalIds>) Lists.newArrayList(
- oneGood, oneBad);
- List<BridgeExternalIds> oneGoodOneBadExpected = null;
- testCase = Maps.newHashMap();
- testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
- testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
-
- // Test Case 4: TestOneGoodExternalIdOneMalformedExternalIdKey
- // Test Type: Negative
- // Description:
- // One perfectly fine BridgeExternalId
- // (TestOneGoodExternalIdOneMalformedExternalIdValue_BridgeExternalIdKey_1,
- // TestOneGoodExternalIdOneMalformedExternalId_BridgeExternalIdValue_1)
- // and one malformed BridgeExternalId which only has key specified
- // (UNSPECIFIED,
- // TestOneGoodExternalIdOneMalformedExternalIdKey_NoKeyForValue_2)
- // Expected: A bridge is created without any external_ids
- final String testOneGoodExternalIdOneMalformedExternalIdKeyName =
- "TestOneGoodExternalIdOneMalformedExternalIdKey";
- externalIdCounter = 0;
- oneGood = new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdKeyName,
- GOOD_KEY, ++externalIdCounter))
- .setBridgeExternalIdValue(String.format("FORMAT_STR",
- testOneGoodExternalIdOneMalformedExternalIdKeyName,
- GOOD_VALUE, externalIdCounter))
- .build();
- oneBad = new BridgeExternalIdsBuilder()
- .setBridgeExternalIdKey(String.format(FORMAT_STR,
- testOneGoodExternalIdOneMalformedExternalIdKeyName, NO_KEY_FOR_VALUE, ++externalIdCounter))
- .build();
- oneGoodOneBadInput = (List<BridgeExternalIds>) Lists.newArrayList(
- oneGood, oneBad);
- oneGoodOneBadExpected = null;
- testCase = Maps.newHashMap();
- testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
- testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
-
- return testMap;
- }
-
/*
* Generates the test cases involved in testing BridgeOtherConfigs. See inline comments for descriptions of
* the particular cases considered.
final String testOneOtherConfigName = "TestOneOtherConfig";
int otherConfigCounter = 0;
List<BridgeOtherConfigs> oneOtherConfig = (List<BridgeOtherConfigs>) Lists.newArrayList(
- (new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testOneOtherConfigName,
- BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format(FORMAT_STR, testOneOtherConfigName,
- BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
- .build()));
+ (new BridgeOtherConfigsBuilder()
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR, testOneOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR, testOneOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
+ .build()));
Map<String,List<BridgeOtherConfigs>> testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, oneOtherConfig);
testCase.put(INPUT_VALUES_KEY, oneOtherConfig);
final String testFiveOtherConfigName = "TestFiveOtherConfig";
otherConfigCounter = 0;
List<BridgeOtherConfigs> fiveOtherConfig = (List<BridgeOtherConfigs>) Lists.newArrayList(
- (new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
- .build()),
- (new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
- .build()),
- (new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
- .build()),
- (new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
- .build()),
- (new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
- BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
- .build()));
+ (new BridgeOtherConfigsBuilder()
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
+ .build()),
+ (new BridgeOtherConfigsBuilder()
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
+ .build()),
+ (new BridgeOtherConfigsBuilder()
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
+ .build()),
+ (new BridgeOtherConfigsBuilder()
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
+ .build()),
+ (new BridgeOtherConfigsBuilder()
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR, testFiveOtherConfigName,
+ BRIDGE_OTHER_CONFIGS_VALUE, otherConfigCounter))
+ .build()));
testCase = Maps.newHashMap();
testCase.put(EXPECTED_VALUES_KEY, fiveOtherConfig);
testCase.put(INPUT_VALUES_KEY, fiveOtherConfig);
- testMap.put(testOneOtherConfigName, testCase);
+ testMap.put(testFiveOtherConfigName, testCase);
// Test Case 3: TestOneGoodOtherConfigOneMalformedOtherConfigValue
// Test Type: Negative
"TestOneGoodOtherConfigOneMalformedOtherConfigValue";
otherConfigCounter = 0;
BridgeOtherConfigs oneGood = new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testOneGoodOtherConfigOneMalformedOtherConfigValueName,
- GOOD_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format("FORMAT_STR",
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodOtherConfigOneMalformedOtherConfigValueName, GOOD_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR,
testOneGoodOtherConfigOneMalformedOtherConfigValueName,
- GOOD_VALUE, otherConfigCounter))
+ GOOD_VALUE, otherConfigCounter))
.build();
BridgeOtherConfigs oneBad = new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR,
- testOneGoodOtherConfigOneMalformedOtherConfigValueName, NO_VALUE_FOR_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodOtherConfigOneMalformedOtherConfigValueName, NO_VALUE_FOR_KEY, ++otherConfigCounter))
.build();
List<BridgeOtherConfigs> oneGoodOneBadInput = (List<BridgeOtherConfigs>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodOtherConfigOneMalformedOtherConfigValueName, testCase);
// Test Case 4: TestOneGoodOtherConfigOneMalformedOtherConfigKey
// Test Type: Negative
"TestOneGoodOtherConfigOneMalformedOtherConfigIdKey";
otherConfigCounter = 0;
oneGood = new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR, testOneGoodOtherConfigOneMalformedOtherConfigKeyName,
- GOOD_KEY, ++otherConfigCounter))
- .setBridgeOtherConfigValue(String.format("FORMAT_STR",
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR, testOneGoodOtherConfigOneMalformedOtherConfigKeyName,
+ GOOD_KEY, ++otherConfigCounter))
+ .setBridgeOtherConfigValue(String.format(FORMAT_STR,
testOneGoodOtherConfigOneMalformedOtherConfigKeyName,
- GOOD_VALUE, otherConfigCounter))
+ GOOD_VALUE, otherConfigCounter))
.build();
oneBad = new BridgeOtherConfigsBuilder()
- .setBridgeOtherConfigKey(String.format(FORMAT_STR,
- testOneGoodOtherConfigOneMalformedOtherConfigKeyName, NO_KEY_FOR_VALUE, ++otherConfigCounter))
+ .setBridgeOtherConfigKey(String.format(FORMAT_STR,
+ testOneGoodOtherConfigOneMalformedOtherConfigKeyName, NO_KEY_FOR_VALUE, ++otherConfigCounter))
.build();
oneGoodOneBadInput = (List<BridgeOtherConfigs>) Lists.newArrayList(
oneGood, oneBad);
testCase = Maps.newHashMap();
testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodOtherConfigOneMalformedOtherConfigKeyName, testCase);
return testMap;
}
+ /*
+ * @see <code>SouthboundIT.testCRUDBridgeOtherConfigs()</code>
+ * This is helper test method to compare a test "set" of BridgeExternalIds against an expected "set"
+ */
+ private void assertExpectedBridgeOtherConfigsExist( List<BridgeOtherConfigs> expected,
+ List<BridgeOtherConfigs> test ) {
+
+ if (expected != null) {
+ for (BridgeOtherConfigs expectedOtherConfig : expected) {
+ Assert.assertTrue(test.contains(expectedOtherConfig));
+ }
+ }
+ }
+
/*
* @see <code>SouthboundIT.generateBridgeOtherConfigsTestCases()</code> for specific test case information.
*/
@Test
- public void testBridgeOtherConfigs() throws InterruptedException {
- final String TEST_BRIDGE_PREFIX = "BridgeOtherConfig";
+ public void testCRUDBridgeOtherConfigs() throws InterruptedException {
+ final String TEST_BRIDGE_PREFIX = "CRUDBridgeOtherConfigs";
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
connectOvsdbNode(connectionInfo);
+ // updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
+ // the update has been performed.
+ Map<String, Map<String, List<BridgeOtherConfigs>>> updateFromTestCases = generateBridgeOtherConfigsTestCases();
+ Map<String, Map<String, List<BridgeOtherConfigs>>> updateToTestCases = generateBridgeOtherConfigsTestCases();
+ Map<String, List<BridgeOtherConfigs>> updateFromTestCase;
+ Map<String, List<BridgeOtherConfigs>> updateToTestCase;
+ List<BridgeOtherConfigs> updateFromInputOtherConfigs;
+ List<BridgeOtherConfigs> updateFromExpectedOtherConfigs;
+ List<BridgeOtherConfigs> updateToInputOtherConfigs;
+ List<BridgeOtherConfigs> updateToExpectedOtherConfigs;
+ String testBridgeName;
+
+ int counter = 1;
+ ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
+ for (String updateFromTestCaseKey : updateFromTestCases.keySet()) {
+ updateFromTestCase = updateFromTestCases.get(updateFromTestCaseKey);
+ updateFromInputOtherConfigs = updateFromTestCase.get(INPUT_VALUES_KEY);
+ updateFromExpectedOtherConfigs = updateFromTestCase.get(EXPECTED_VALUES_KEY);
+ for (String testCaseKey : updateToTestCases.keySet()) {
+ testBridgeName = String.format("%s_%s_%d", TEST_BRIDGE_PREFIX, testCaseKey, counter);
+ counter += 1;
+ updateToTestCase = updateToTestCases.get(testCaseKey);
+ updateToInputOtherConfigs = updateToTestCase.get(INPUT_VALUES_KEY);
+ updateToExpectedOtherConfigs = updateToTestCase.get(EXPECTED_VALUES_KEY);
+
+ TestCRUDBridgeOtherConfigsRunnable testRunnable =
+ new TestCRUDBridgeOtherConfigsRunnable(
+ connectionInfo, testBridgeName,
+ updateFromInputOtherConfigs,
+ updateFromExpectedOtherConfigs,
+ updateToInputOtherConfigs,
+ updateToExpectedOtherConfigs);
+ executor.submit(testRunnable);
+ }
+ }
+ executor.shutdown();
+ executor.awaitTermination(5, TimeUnit.MINUTES);
- Map<String,Map<String, List<BridgeOtherConfigs>>> testCases =
- generateBridgeOtherConfigsTestCases();
- List<BridgeOtherConfigs> inputBridgeOtherConfigs = null;
- List<BridgeOtherConfigs> expectedBridgeOtherConfigs = null;
- List<BridgeOtherConfigs> actualBridgeOtherConfigs = null;
- String testBridgeName = null;
- boolean bridgeAdded = false;
- for (String testCaseKey : testCases.keySet()) {
- testBridgeName = String.format("%s_%s", TEST_BRIDGE_PREFIX, testCaseKey);
- inputBridgeOtherConfigs = testCases.get(testCaseKey).get(INPUT_VALUES_KEY);
- expectedBridgeOtherConfigs = testCases.get(testCaseKey).get(EXPECTED_VALUES_KEY);
- bridgeAdded = addBridge(connectionInfo, null, testBridgeName, null, true,
- SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null,
- null, inputBridgeOtherConfigs);
- Assert.assertTrue(bridgeAdded);
+ Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ }
- actualBridgeOtherConfigs = getBridge(connectionInfo, testBridgeName).getBridgeOtherConfigs();
+ class TestCRUDBridgeOtherConfigsRunnable implements Runnable {
+
+ ConnectionInfo connectionInfo;
+ String testBridgeName;
+ List<BridgeOtherConfigs> updateFromInputOtherConfigs;
+ List<BridgeOtherConfigs> updateFromExpectedOtherConfigs;
+ List<BridgeOtherConfigs> updateToInputOtherConfigs;
+ List<BridgeOtherConfigs> updateToExpectedOtherConfigs;
+
+ TestCRUDBridgeOtherConfigsRunnable(
+ ConnectionInfo connectionInfo, String testBridgeName,
+ List<BridgeOtherConfigs> updateFromInputOtherConfigs,
+ List<BridgeOtherConfigs> updateFromExpectedOtherConfigs,
+ List<BridgeOtherConfigs> updateToInputOtherConfigs,
+ List<BridgeOtherConfigs> updateToExpectedOtherConfigs) {
+
+ this.connectionInfo = connectionInfo;
+ this.testBridgeName = testBridgeName;
+ this.updateFromInputOtherConfigs = updateFromInputOtherConfigs;
+ this.updateFromExpectedOtherConfigs = updateFromExpectedOtherConfigs;
+ this.updateToInputOtherConfigs = updateToInputOtherConfigs;
+ this.updateToExpectedOtherConfigs = updateToExpectedOtherConfigs;
+ }
- // Verify the expected other_config are present, or no (null) other_config are present
- if (expectedBridgeOtherConfigs != null) {
- for (BridgeOtherConfigs expectedOtherConfig : expectedBridgeOtherConfigs) {
- Assert.assertTrue(actualBridgeOtherConfigs.contains(expectedOtherConfig));
- }
- } else {
- Assert.assertNull(actualBridgeOtherConfigs);
+ @Override
+ public void run() {
+ try {
+ test();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void test() throws InterruptedException {
+ // CREATE: Create the test bridge
+ boolean bridgeAdded = addBridge(connectionInfo, null,
+ testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+ true, null, null, null, updateFromInputOtherConfigs);
+ Assert.assertTrue(bridgeAdded);
+
+ // READ: Read the test bridge and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ List<BridgeOtherConfigs> updateFromConfigurationOtherConfigs = getBridge(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION).getBridgeOtherConfigs();
+ assertExpectedBridgeOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateFromConfigurationOtherConfigs);
+ List<BridgeOtherConfigs> updateFromOperationalOtherConfigs = getBridge(connectionInfo, testBridgeName)
+ .getBridgeOtherConfigs();
+ assertExpectedBridgeOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateFromOperationalOtherConfigs);
+
+ // UPDATE: update the external_ids
+ OvsdbBridgeAugmentationBuilder bridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
+ bridgeAugmentationBuilder.setBridgeOtherConfigs(updateToInputOtherConfigs);
+ InstanceIdentifier<Node> bridgeIid =
+ createInstanceIdentifier(connectionInfo,
+ new OvsdbBridgeName(testBridgeName));
+ NodeBuilder bridgeNodeBuilder = new NodeBuilder();
+ Node bridgeNode = getBridgeNode(connectionInfo, testBridgeName);
+ bridgeNodeBuilder.setNodeId(bridgeNode.getNodeId());
+ bridgeNodeBuilder.setKey(bridgeNode.getKey());
+ bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, bridgeAugmentationBuilder.build());
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
+ bridgeNodeBuilder.build());
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ Assert.assertTrue(result);
+
+ // READ: the test bridge and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ List<BridgeOtherConfigs> updateToConfigurationOtherConfigs = getBridge(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION).getBridgeOtherConfigs();
+ assertExpectedBridgeOtherConfigsExist(updateToExpectedOtherConfigs, updateToConfigurationOtherConfigs);
+ assertExpectedBridgeOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateToConfigurationOtherConfigs);
+ List<BridgeOtherConfigs> updateToOperationalOtherConfigs = getBridge(connectionInfo, testBridgeName)
+ .getBridgeOtherConfigs();
+ if (updateFromExpectedOtherConfigs != null) {
+ assertExpectedBridgeOtherConfigsExist(updateToExpectedOtherConfigs,
+ updateToOperationalOtherConfigs);
+ assertExpectedBridgeOtherConfigsExist(updateFromExpectedOtherConfigs,
+ updateToOperationalOtherConfigs);
}
+
+ // DELETE
Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
}
- Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ }
+
+ /*
+ * Generates the test cases involved in testing BridgeExternalIds. See inline comments for descriptions of
+ * the particular cases considered.
+ *
+ * The return value is a Map in the form (K,V)=(testCaseName,testCase).
+ * - testCaseName is a String
+ * - testCase is a Map in the form (K,V) s.t. K=(EXPECTED_VALUES_KEY|INPUT_VALUES_KEY) and V is a List of
+ * either corresponding INPUT bridge external ids, or EXPECTED bridge external ids
+ * INPUT is the List we use when calling BridgeAugmentationBuilder.setBridgeExternalIds()
+ * EXPECTED is the List we expect to receive after calling BridgeAugmentationBuilder.getBridgeExternalIds()
+ */
+ private Map<String, Map<String, List<BridgeExternalIds>>> generateBridgeExternalIdsTestCases() {
+ Map<String, Map<String, List<BridgeExternalIds>>> testMap =
+ new HashMap<String, Map<String, List<BridgeExternalIds>>>();
+
+ final String BRIDGE_EXTERNAL_ID_KEY = "BridgeExternalIdKey";
+ final String BRIDGE_EXTERNAL_ID_VALUE = "BridgeExternalIdValue";
+ final String FORMAT_STR = "%s_%s_%d";
+ final String GOOD_KEY = "GoodKey";
+ final String GOOD_VALUE = "GoodValue";
+ final String NO_VALUE_FOR_KEY = "NoValueForKey";
+ final String NO_KEY_FOR_VALUE = "NoKeyForValue";
+
+ // Test Case 1: TestOneExternalId
+ // Test Type: Positive
+ // Description: Create a bridge with one BridgeExternalIds
+ // Expected: A bridge is created with the single external_ids specified below
+ final String testOneExternalIdName = "TestOneExternalId";
+ int externalIdCounter = 0;
+ List<BridgeExternalIds> oneExternalId = (List<BridgeExternalIds>) Lists.newArrayList(
+ (new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testOneExternalIdName,
+ BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR, testOneExternalIdName,
+ BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()));
+ Map<String,List<BridgeExternalIds>> testCase = Maps.newHashMap();
+ testCase.put(EXPECTED_VALUES_KEY, oneExternalId);
+ testCase.put(INPUT_VALUES_KEY, oneExternalId);
+ testMap.put(testOneExternalIdName, testCase);
+
+ // Test Case 2: TestFiveExternalId
+ // Test Type: Positive
+ // Description: Create a bridge with multiple (five) BridgeExternalIds
+ // Expected: A bridge is created with the five external_ids specified below
+ final String testFiveExternalIdName = "TestFiveExternalId";
+ externalIdCounter = 0;
+ List<BridgeExternalIds> fiveExternalId = (List<BridgeExternalIds>) Lists.newArrayList(
+ (new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()),
+ (new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR, testFiveExternalIdName,
+ BRIDGE_EXTERNAL_ID_VALUE, externalIdCounter))
+ .build()));
+ testCase = Maps.newHashMap();
+ testCase.put(EXPECTED_VALUES_KEY, fiveExternalId);
+ testCase.put(INPUT_VALUES_KEY, fiveExternalId);
+ testMap.put(testFiveExternalIdName, testCase);
+
+ // Test Case 3: TestOneGoodExternalIdOneMalformedExternalIdValue
+ // Test Type: Negative
+ // Description:
+ // One perfectly fine BridgeExternalId
+ // (TestOneGoodExternalIdOneMalformedExternalIdValue_BridgeExternalIdKey_1,
+ // TestOneGoodExternalIdOneMalformedExternalId_BridgeExternalIdValue_1)
+ // and one malformed BridgeExternalId which only has key specified
+ // (TestOneGoodExternalIdOneMalformedExternalIdValue_NoValueForKey_2,
+ // UNSPECIFIED)
+ // Expected: A bridge is created without any external_ids
+ final String testOneGoodExternalIdOneMalformedExternalIdValueName =
+ "TestOneGoodExternalIdOneMalformedExternalIdValue";
+ externalIdCounter = 0;
+ BridgeExternalIds oneGood = new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdValueName,
+ GOOD_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdValueName,
+ GOOD_VALUE, externalIdCounter))
+ .build();
+ BridgeExternalIds oneBad = new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdValueName, NO_VALUE_FOR_KEY, ++externalIdCounter))
+ .build();
+ List<BridgeExternalIds> oneGoodOneBadInput = (List<BridgeExternalIds>) Lists.newArrayList(
+ oneGood, oneBad);
+ List<BridgeExternalIds> oneGoodOneBadExpected = null;
+ testCase = Maps.newHashMap();
+ testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
+ testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodExternalIdOneMalformedExternalIdValueName, testCase);
+
+ // Test Case 4: TestOneGoodExternalIdOneMalformedExternalIdKey
+ // Test Type: Negative
+ // Description:
+ // One perfectly fine BridgeExternalId
+ // (TestOneGoodExternalIdOneMalformedExternalIdValue_BridgeExternalIdKey_1,
+ // TestOneGoodExternalIdOneMalformedExternalId_BridgeExternalIdValue_1)
+ // and one malformed BridgeExternalId which only has key specified
+ // (UNSPECIFIED,
+ // TestOneGoodExternalIdOneMalformedExternalIdKey_NoKeyForValue_2)
+ // Expected: A bridge is created without any external_ids
+ final String testOneGoodExternalIdOneMalformedExternalIdKeyName =
+ "TestOneGoodExternalIdOneMalformedExternalIdKey";
+ externalIdCounter = 0;
+ oneGood = new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR, testOneGoodExternalIdOneMalformedExternalIdKeyName,
+ GOOD_KEY, ++externalIdCounter))
+ .setBridgeExternalIdValue(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdKeyName,
+ GOOD_VALUE, externalIdCounter))
+ .build();
+ oneBad = new BridgeExternalIdsBuilder()
+ .setBridgeExternalIdKey(String.format(FORMAT_STR,
+ testOneGoodExternalIdOneMalformedExternalIdKeyName, NO_KEY_FOR_VALUE, ++externalIdCounter))
+ .build();
+ oneGoodOneBadInput = (List<BridgeExternalIds>) Lists.newArrayList(
+ oneGood, oneBad);
+ oneGoodOneBadExpected = null;
+ testCase = Maps.newHashMap();
+ testCase.put(INPUT_VALUES_KEY, oneGoodOneBadInput);
+ testCase.put(EXPECTED_VALUES_KEY, oneGoodOneBadExpected);
+ testMap.put(testOneGoodExternalIdOneMalformedExternalIdKeyName, testCase);
+ return testMap;
}
/*
* This is helper test method to compare a test "set" of BridgeExternalIds against an expected "set"
*/
private void assertExpectedBridgeExternalIdsExist( List<BridgeExternalIds> expected,
- List<BridgeExternalIds> test ) {
+ List<BridgeExternalIds> test ) {
if (expected != null) {
for (BridgeExternalIds expectedExternalId : expected) {
Assert.assertTrue(test.contains(expectedExternalId));
}
- } else {
- Assert.assertNull(test);
- }
- }
-
- /*
- * @see <code>SouthboundIT.testCRUDBridgeExternalIds()</code>
- * This is a helper test method. The method only checks if
- * <code>updateFromInputExternalIds != updateToInputExternalIds</code>, (i.e., the updateTo "set" isn't the same
- * as the updateFrom "set". Then, the method ensures each element of erase is not an element of test, as the input
- * test cases are divergent.
- */
- private void assertBridgeExternalIdsErased( List<BridgeExternalIds> updateFromInputExternalIds,
- List<BridgeExternalIds> updateToInputExternalIds,
- List<BridgeExternalIds> updateFromExpectedExternalIds,
- List<BridgeExternalIds> updateToTestExternalIds ) {
-
- if (!updateFromInputExternalIds.containsAll(updateToInputExternalIds)) {
- for (BridgeExternalIds erasedExternalId : updateFromExpectedExternalIds) {
- Assert.assertTrue(!updateToTestExternalIds.contains(erasedExternalId));
- }
}
}
// the update has been performed.
Map<String, Map<String, List<BridgeExternalIds>>> updateFromTestCases = generateBridgeExternalIdsTestCases();
Map<String, Map<String, List<BridgeExternalIds>>> updateToTestCases = generateBridgeExternalIdsTestCases();
- Map<String, List<BridgeExternalIds>> updateFromTestCase = null;
- List<BridgeExternalIds> updateFromInputExternalIds = null;
- List<BridgeExternalIds> updateFromExpectedExternalIds = null;
- List<BridgeExternalIds> updateFromConfigurationExternalIds = null;
- List<BridgeExternalIds> updateFromOperationalExternalIds = null;
- Map<String, List<BridgeExternalIds>> updateToTestCase = null;
- List<BridgeExternalIds> updateToInputExternalIds = null;
- List<BridgeExternalIds> updateToExpectedExternalIds = null;
- List<BridgeExternalIds> updateToConfigurationExternalIds = null;
- List<BridgeExternalIds> updateToOperationalExternalIds = null;
- String testBridgeName = null;
+ Map<String, List<BridgeExternalIds>> updateFromTestCase;
+ List<BridgeExternalIds> updateFromInputExternalIds;
+ List<BridgeExternalIds> updateFromExpectedExternalIds;
+ Map<String, List<BridgeExternalIds>> updateToTestCase;
+ List<BridgeExternalIds> updateToInputExternalIds;
+ List<BridgeExternalIds> updateToExpectedExternalIds;
+ String testBridgeName;
+
+ int counter = 1;
+ ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
for (String updateFromTestCaseKey : updateFromTestCases.keySet()) {
updateFromTestCase = updateFromTestCases.get(updateFromTestCaseKey);
updateFromInputExternalIds = updateFromTestCase.get(INPUT_VALUES_KEY);
updateFromExpectedExternalIds = updateFromTestCase.get(EXPECTED_VALUES_KEY);
for (String testCaseKey : updateToTestCases.keySet()) {
- testBridgeName = String.format("%s_%s", TEST_BRIDGE_PREFIX, testCaseKey);
+ testBridgeName = String.format("%s_%s_d", TEST_BRIDGE_PREFIX, testCaseKey, counter);
+ counter += 1;
updateToTestCase = updateToTestCases.get(testCaseKey);
updateToInputExternalIds = updateToTestCase.get(INPUT_VALUES_KEY);
updateToExpectedExternalIds = updateToTestCase.get(EXPECTED_VALUES_KEY);
- // CREATE: Create the test bridge
- boolean bridgeAdded = addBridge(connectionInfo, null,
- testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
- true, null, updateFromInputExternalIds, null);
- Assert.assertTrue(bridgeAdded);
-
- // READ: Read the test bridge and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateFromConfigurationExternalIds = getBridge(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION).getBridgeExternalIds();
- assertExpectedBridgeExternalIdsExist(updateFromExpectedExternalIds, updateFromConfigurationExternalIds);
- updateFromOperationalExternalIds = getBridge(connectionInfo, testBridgeName).getBridgeExternalIds();
- assertExpectedBridgeExternalIdsExist(updateFromExpectedExternalIds, updateFromOperationalExternalIds);
-
- // UPDATE: update the external_ids
- OvsdbBridgeAugmentationBuilder bridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
- bridgeAugmentationBuilder.setBridgeExternalIds(updateToInputExternalIds);
- InstanceIdentifier<Node> bridgeIid =
- SouthboundMapper.createInstanceIdentifier(connectionInfo,
- new OvsdbBridgeName(testBridgeName));
- NodeBuilder bridgeNodeBuilder = new NodeBuilder();
- Node bridgeNode = getBridgeNode(connectionInfo, testBridgeName);
- bridgeNodeBuilder.setNodeId(bridgeNode.getNodeId());
- bridgeNodeBuilder.setKey(bridgeNode.getKey());
- bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, bridgeAugmentationBuilder.build());
- boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
- bridgeNodeBuilder.build());
- Thread.sleep(OVSDB_UPDATE_TIMEOUT);
- Assert.assertTrue(result);
-
- // READ: the test bridge and ensure changes are propagated to the CONFIGURATION data store,
- // then repeat for OPERATIONAL data store
- updateToConfigurationExternalIds = getBridge(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION).getBridgeExternalIds();
- assertExpectedBridgeExternalIdsExist(updateToExpectedExternalIds, updateToConfigurationExternalIds);
- updateToOperationalExternalIds = getBridge(connectionInfo, testBridgeName)
- .getBridgeExternalIds();
- assertExpectedBridgeExternalIdsExist(updateToExpectedExternalIds, updateToOperationalExternalIds);
+ TestCRUDBridgeExternalIdsRunnable testRunnable =
+ new TestCRUDBridgeExternalIdsRunnable(
+ connectionInfo, testBridgeName,
+ updateFromInputExternalIds,
+ updateFromExpectedExternalIds,
+ updateToInputExternalIds,
+ updateToExpectedExternalIds);
+ executor.submit(testRunnable);
+ }
+ }
+ executor.shutdown();
+ executor.awaitTermination(5, TimeUnit.MINUTES);
- // Make sure the old bridge external ids aren't present in the CONFIGURATION data store
- assertBridgeExternalIdsErased(updateFromInputExternalIds, updateToInputExternalIds,
- updateFromExpectedExternalIds, updateToConfigurationExternalIds);
- assertBridgeExternalIdsErased(updateFromInputExternalIds, updateToInputExternalIds,
- updateFromExpectedExternalIds, updateToConfigurationExternalIds);
+ Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+ }
- // DELETE
- Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ class TestCRUDBridgeExternalIdsRunnable implements Runnable {
+ ConnectionInfo connectionInfo;
+ String testBridgeName;
+ List<BridgeExternalIds> updateFromInputExternalIds;
+ List<BridgeExternalIds> updateFromExpectedExternalIds;
+ List<BridgeExternalIds> updateToInputExternalIds;
+ List<BridgeExternalIds> updateToExpectedExternalIds;
+
+ TestCRUDBridgeExternalIdsRunnable(
+ ConnectionInfo connectionInfo, String testBridgeName,
+ List<BridgeExternalIds> updateFromInputExternalIds,
+ List<BridgeExternalIds> updateFromExpectedExternalIds,
+ List<BridgeExternalIds> updateToInputExternalIds,
+ List<BridgeExternalIds> updateToExpectedExternalIds) {
+
+ this.connectionInfo = connectionInfo;
+ this.testBridgeName = testBridgeName;
+ this.updateFromInputExternalIds = updateFromInputExternalIds;
+ this.updateFromExpectedExternalIds = updateFromExpectedExternalIds;
+ this.updateToInputExternalIds = updateToInputExternalIds;
+ this.updateToExpectedExternalIds = updateToExpectedExternalIds;
+ }
+
+ @Override
+ public void run() {
+ try {
+ test();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
}
- Assert.assertTrue(disconnectOvsdbNode(connectionInfo));
+
+ public void test() throws InterruptedException {
+ // CREATE: Create the test bridge
+ boolean bridgeAdded = addBridge(connectionInfo, null,
+ testBridgeName, null, true, SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
+ true, null, updateFromInputExternalIds, null, null);
+ Assert.assertTrue(bridgeAdded);
+
+ // READ: Read the test bridge and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ List<BridgeExternalIds> updateFromConfigurationExternalIds = getBridge(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION).getBridgeExternalIds();
+ assertExpectedBridgeExternalIdsExist(updateFromExpectedExternalIds, updateFromConfigurationExternalIds);
+ List<BridgeExternalIds> updateFromOperationalExternalIds = getBridge(connectionInfo, testBridgeName)
+ .getBridgeExternalIds();
+ assertExpectedBridgeExternalIdsExist(updateFromExpectedExternalIds, updateFromOperationalExternalIds);
+
+ // UPDATE: update the external_ids
+ OvsdbBridgeAugmentationBuilder bridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
+ bridgeAugmentationBuilder.setBridgeExternalIds(updateToInputExternalIds);
+ InstanceIdentifier<Node> bridgeIid =
+ createInstanceIdentifier(connectionInfo,
+ new OvsdbBridgeName(testBridgeName));
+ NodeBuilder bridgeNodeBuilder = new NodeBuilder();
+ Node bridgeNode = getBridgeNode(connectionInfo, testBridgeName);
+ bridgeNodeBuilder.setNodeId(bridgeNode.getNodeId());
+ bridgeNodeBuilder.setKey(bridgeNode.getKey());
+ bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, bridgeAugmentationBuilder.build());
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
+ bridgeNodeBuilder.build());
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ Assert.assertTrue(result);
+
+ // READ: the test bridge and ensure changes are propagated to the CONFIGURATION data store,
+ // then repeat for OPERATIONAL data store
+ List<BridgeExternalIds> updateToConfigurationExternalIds = getBridge(connectionInfo, testBridgeName,
+ LogicalDatastoreType.CONFIGURATION).getBridgeExternalIds();
+ assertExpectedBridgeExternalIdsExist(updateToExpectedExternalIds, updateToConfigurationExternalIds);
+ assertExpectedBridgeExternalIdsExist(updateFromExpectedExternalIds, updateToConfigurationExternalIds);
+ List<BridgeExternalIds> updateToOperationalExternalIds = getBridge(connectionInfo, testBridgeName)
+ .getBridgeExternalIds();
+ if (updateFromExpectedExternalIds != null) {
+ assertExpectedBridgeExternalIdsExist(updateToExpectedExternalIds, updateToOperationalExternalIds);
+ assertExpectedBridgeExternalIdsExist(updateFromExpectedExternalIds, updateToOperationalExternalIds);
+ }
+
+ // DELETE
+ Assert.assertTrue(deleteBridge(connectionInfo, testBridgeName));
+ }
+ }
+
+ public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key,OvsdbBridgeName bridgeName) {
+ return SouthboundMapper.createInstanceIdentifier(createManagedNodeId(key, bridgeName));
+ }
+
+ public static NodeId createManagedNodeId(ConnectionInfo key, OvsdbBridgeName bridgeName) {
+ return createManagedNodeId(key.getRemoteIp(),key.getRemotePort(),bridgeName);
+ }
+
+ public static NodeId createManagedNodeId(IpAddress ip, PortNumber port, OvsdbBridgeName bridgeName) {
+ return new NodeId(createNodeId(ip,port).getValue()
+ + "/" + SouthboundConstants.BRIDGE_URI_PREFIX + "/" + bridgeName.getValue());
+ }
+
+ public static NodeId createNodeId(IpAddress ip, PortNumber port) {
+ String uriString = SouthboundConstants.OVSDB_URI_PREFIX + "://"
+ + new String(ip.getValue()) + ":" + port.getValue();
+ Uri uri = new Uri(uriString);
+ NodeId nodeId = new NodeId(uri);
+ return nodeId;
+ }
+
+ public static NodeKey createNodeKey(IpAddress ip, PortNumber port) {
+ return new NodeKey(createNodeId(ip,port));
+ }
+
+ public static Node createNode(ConnectionInfo key) {
+ NodeBuilder nodeBuilder = new NodeBuilder();
+ nodeBuilder.setNodeId(createNodeId(key.getRemoteIp(),key.getRemotePort()));
+ nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, createOvsdbAugmentation(key));
+ return nodeBuilder.build();
+ }
+
+ public static OvsdbNodeAugmentation createOvsdbAugmentation(ConnectionInfo key) {
+ OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = new OvsdbNodeAugmentationBuilder();
+ ovsdbNodeBuilder.setConnectionInfo(key);
+ return ovsdbNodeBuilder.build();
+ }
+
+ public static NodeId createManagedNodeId(InstanceIdentifier<Node> iid) {
+ NodeKey nodeKey = iid.firstKeyOf(Node.class, NodeKey.class);
+ return nodeKey.getNodeId();
}
}