*/
package org.opendaylight.ovsdb.southbound.it;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeFalse;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import com.google.common.collect.ImmutableBiMap;
-import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.inject.Inject;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.junit.After;
-import org.junit.Assert;
-import org.junit.Assume;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.RunWith;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.ovsdb.lib.notation.Version;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.ovsdb.southbound.SouthboundUtil;
-import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.QosTypeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
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.BridgeExternalIdsKey;
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.BridgeOtherConfigsKey;
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.ControllerEntryKey;
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.bridge.attributes.ProtocolEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.Autoattach;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.AutoattachBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.AutoattachKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfoBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.DatapathTypeEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.DatapathTypeEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.InterfaceTypeEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntriesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntriesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QueuesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.autoattach.AutoattachExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.autoattach.AutoattachExternalIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.autoattach.AutoattachExternalIdsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.autoattach.Mappings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.autoattach.MappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.autoattach.MappingsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosExternalIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosExternalIdsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosOtherConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosOtherConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosOtherConfigKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QueueList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QueueListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QueueListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesExternalIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesExternalIdsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesOtherConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesOtherConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesOtherConfigKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldpKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortExternalIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortExternalIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortExternalIdsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortOtherConfigs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortOtherConfigsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.PortOtherConfigsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Trunks;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.TrunksBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
private static final String FORMAT_STR = "%s_%s_%d";
private static final Version AUTOATTACH_FROM_VERSION = Version.fromString("7.11.2");
private static final Version IF_INDEX_FROM_VERSION = Version.fromString("7.2.1");
- private static final Long MAX_BACKOFF = 10000L;
- private static final Long INACTIVITY_PROBE = 30000L;
+ private static final Uint32 MAX_BACKOFF = Uint32.valueOf(10000);
+ private static final Uint32 INACTIVITY_PROBE = Uint32.valueOf(30000);
private static String addressStr;
- private static int portNumber;
+ private static Uint16 portNumber;
private static String connectionType;
private static boolean setup = false;
- private static ControllerMdsalUtils mdsalUtils = null;
+ private static MdsalUtils mdsalUtils = null;
private static Node ovsdbNode;
private static int testMethodsRemaining;
private static Version schemaVersion;
private final Set<InstanceIdentifier<?>> updatedIids = new HashSet<>();
private final InstanceIdentifier<?> iid;
- private NotifyingDataChangeListener(LogicalDatastoreType type) {
+ private NotifyingDataChangeListener(final LogicalDatastoreType type) {
this.type = type;
this.iid = null;
}
- private NotifyingDataChangeListener(LogicalDatastoreType type, InstanceIdentifier<?> iid) {
+ private NotifyingDataChangeListener(final LogicalDatastoreType type, final InstanceIdentifier<?> iid) {
this.type = type;
this.iid = iid;
}
@Override
- public void onDataTreeChanged(Collection<DataTreeModification<DataObject>> changes) {
+ public void onDataTreeChanged(final Collection<DataTreeModification<DataObject>> changes) {
for (DataTreeModification<DataObject> change: changes) {
DataObjectModification<DataObject> rootNode = change.getRootNode();
final InstanceIdentifier<DataObject> identifier = change.getRootPath().getRootIdentifier();
}
}
- public boolean isCreated(InstanceIdentifier<?> path) {
+ public boolean isCreated(final InstanceIdentifier<?> path) {
return createdIids.remove(path);
}
- public boolean isRemoved(InstanceIdentifier<?> path) {
+ public boolean isRemoved(final InstanceIdentifier<?> path) {
return removedIids.remove(path);
}
- public boolean isUpdated(InstanceIdentifier<?> path) {
+ public boolean isUpdated(final InstanceIdentifier<?> path) {
return updatedIids.remove(path);
}
}
public void registerDataChangeListener() {
- dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(type,
+ dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(type,
(InstanceIdentifier)iid), this);
}
- public void waitForCreation(long timeout) throws InterruptedException {
+ public void waitForCreation(final long timeout) throws InterruptedException {
synchronized (this) {
long start = System.currentTimeMillis();
LOG.info("Waiting for {} DataChanged creation on {}", type, iid);
}
}
- public void waitForDeletion(long timeout) throws InterruptedException {
+ public void waitForDeletion(final long timeout) throws InterruptedException {
synchronized (this) {
long start = System.currentTimeMillis();
LOG.info("Waiting for {} DataChanged deletion on {}", type, iid);
}
}
- public void waitForUpdate(long timeout) throws InterruptedException {
+ public void waitForUpdate(final long timeout) throws InterruptedException {
synchronized (this) {
long start = System.currentTimeMillis();
LOG.info("Waiting for {} DataChanged update on {}", type, iid);
return combinedOptions;
}
- private Option[] getOtherOptions() {
+ private static Option[] getOtherOptions() {
return new Option[] {
vmOption("-javaagent:../jars/org.jacoco.agent.jar=destfile=../../jacoco-it.exec"),
keepRuntimeFolder()
super.getLoggingOption());
}
- private Option[] getPropertiesOptions() {
+ private static Option[] getPropertiesOptions() {
Properties props = new Properties(System.getProperties());
String ipAddressStr = props.getProperty(SouthboundITConstants.SERVER_IPADDRESS,
SouthboundITConstants.DEFAULT_SERVER_IPADDRESS);
}
super.setup();
- Assert.assertNotNull("db should not be null", dataBroker);
+ assertNotNull("db should not be null", dataBroker);
LOG.info("sleeping for 10s to let the features finish installing");
Thread.sleep(10000);
addressStr = bundleContext.getProperty(SouthboundITConstants.SERVER_IPADDRESS);
String portStr = bundleContext.getProperty(SouthboundITConstants.SERVER_PORT);
try {
- portNumber = Integer.parseInt(portStr);
- } catch (NumberFormatException e) {
+ portNumber = Uint16.valueOf(portStr);
+ } catch (IllegalArgumentException e) {
fail("Invalid port number " + portStr + System.lineSeparator() + usage());
}
connectionType = bundleContext.getProperty(SouthboundITConstants.CONNECTION_TYPE);
}
}
- mdsalUtils = new ControllerMdsalUtils(dataBroker);
+ mdsalUtils = new MdsalUtils(dataBroker);
assertTrue("Did not find " + SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue(), getOvsdbTopology());
final ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
- dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
+ dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
(InstanceIdentifier)iid), CONFIGURATION_LISTENER);
- dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+ dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
(InstanceIdentifier)iid), OPERATIONAL_LISTENER);
ovsdbNode = connectOvsdbNode(connectionInfo);
}
}
- private Boolean getOvsdbTopology() {
+ private static Boolean getOvsdbTopology() {
LOG.info("getOvsdbTopology: looking for {}...", SouthboundUtils.OVSDB_TOPOLOGY_ID.getValue());
Boolean found = false;
final TopologyId topologyId = SouthboundUtils.OVSDB_TOPOLOGY_ID;
}
}
- private static ConnectionInfo getConnectionInfo(final String ipAddressStr, final int portNum) {
+ private static ConnectionInfo getConnectionInfo(final String ipAddressStr, final Uint16 portNum) {
InetAddress inetAddress = null;
try {
inetAddress = InetAddress.getByName(ipAddressStr);
public void testNetworkTopology() throws InterruptedException {
NetworkTopology networkTopology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.create(NetworkTopology.class));
- Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.CONFIGURATION,
- networkTopology);
+ assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.CONFIGURATION, networkTopology);
networkTopology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(NetworkTopology.class));
- Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.OPERATIONAL,
- networkTopology);
+ assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.OPERATIONAL, networkTopology);
}
@Test
.child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
Topology topology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
- Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.CONFIGURATION,
- topology);
+ assertNotNull("Topology could not be found in " + LogicalDatastoreType.CONFIGURATION, topology);
topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
- Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.OPERATIONAL,
- topology);
+ assertNotNull("Topology could not be found in " + LogicalDatastoreType.OPERATIONAL, topology);
}
- private Node connectOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
+ private static Node connectOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
- Assert.assertTrue(
+ assertTrue(
mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, iid, SouthboundUtils.createNode(connectionInfo)));
waitForOperationalCreation(iid);
Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, iid);
- Assert.assertNotNull(node);
+ assertNotNull(node);
LOG.info("Connected to {}", SouthboundUtils.connectionInfoToString(connectionInfo));
return node;
}
- private void waitForOperationalCreation(InstanceIdentifier<Node> iid) throws InterruptedException {
+ private static void waitForOperationalCreation(final InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
long start = System.currentTimeMillis();
LOG.info("Waiting for OPERATIONAL DataChanged creation on {}", iid);
}
}
- private static void waitForOperationalDeletion(InstanceIdentifier<Node> iid) throws InterruptedException {
+ private static void waitForOperationalDeletion(final InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
long start = System.currentTimeMillis();
LOG.info("Waiting for OPERATIONAL DataChanged deletion on {}", iid);
}
}
- private void waitForOperationalUpdate(InstanceIdentifier<Node> iid) throws InterruptedException {
+ private static void waitForOperationalUpdate(final InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
long start = System.currentTimeMillis();
LOG.info("Waiting for OPERATIONAL DataChanged update on {}", iid);
private static void disconnectOvsdbNode(final ConnectionInfo connectionInfo) throws InterruptedException {
final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
waitForOperationalDeletion(iid);
Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, iid);
- Assert.assertNull(node);
+ assertNull(node);
LOG.info("Disconnected from {}", SouthboundUtils.connectionInfoToString(connectionInfo));
}
@Test
public void testDpdkSwitch() throws InterruptedException {
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
- List<DatapathTypeEntry> datapathTypeEntries = ovsdbNode.augmentation(OvsdbNodeAugmentation.class)
- .getDatapathTypeEntry();
+ Map<DatapathTypeEntryKey, DatapathTypeEntry> datapathTypeEntries =
+ ovsdbNode.augmentation(OvsdbNodeAugmentation.class).nonnullDatapathTypeEntry();
if (datapathTypeEntries == null) {
LOG.info("DPDK not supported on this node.");
} else {
- for (DatapathTypeEntry dpTypeEntry : datapathTypeEntries) {
+ for (DatapathTypeEntry dpTypeEntry : datapathTypeEntries.values()) {
Class<? extends DatapathTypeBase> dpType = dpTypeEntry.getDatapathType();
String dpTypeStr = SouthboundConstants.DATAPATH_TYPE_MAP.get(dpType);
LOG.info("dp type is {}", dpTypeStr);
null)) {
// Verify that the device is netdev
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
- Assert.assertEquals(dpType, bridge.getDatapathType());
+ assertNotNull(bridge);
+ assertEquals(dpType, bridge.getDatapathType());
// Add port for all dpdk interface types (dpdkvhost not supported in existing dpdk ovs)
List<String> dpdkTypes = new ArrayList<>();
for (String dpdkType : dpdkTypes) {
String testPortname = "test" + dpdkType + "port";
LOG.info("DPDK portname and type is {}, {}", testPortname, dpdkType);
- Class<? extends InterfaceTypeBase> dpdkIfType = SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP
- .get(dpdkType);
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationpointBuilder =
createSpecificDpdkOvsdbTerminationPointAugmentationBuilder(testPortname,
- dpdkIfType);
- Assert.assertTrue(
- addTerminationPoint(bridgeNodeId, testPortname, ovsdbTerminationpointBuilder));
+ SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.get(dpdkType));
+ assertTrue(addTerminationPoint(bridgeNodeId, testPortname, ovsdbTerminationpointBuilder));
}
// Verify that all DPDK ports are created
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
// Verify that each termination point has the specific DPDK ifType
for (String dpdkType : dpdkTypes) {
String testPortname = "test" + dpdkType + "port";
- Class<? extends InterfaceTypeBase> dpdkIfType = SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP
- .get(dpdkType);
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ Class<? extends InterfaceTypeBase> dpdkIfType =
+ SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.get(dpdkType);
+ for (TerminationPoint terminationPoint
+ : terminationPointNode.nonnullTerminationPoint().values()) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation = terminationPoint
.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(testPortname)) {
- Class<? extends InterfaceTypeBase> opPort = ovsdbTerminationPointAugmentation
- .getInterfaceType();
- Assert.assertEquals(dpdkIfType, opPort);
+ assertEquals(dpdkIfType, ovsdbTerminationPointAugmentation.getInterfaceType());
}
}
}
@Test
public void testOvsdbNodeOvsVersion() throws InterruptedException {
OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.augmentation(OvsdbNodeAugmentation.class);
- Assert.assertNotNull(ovsdbNodeAugmentation);
+ assertNotNull(ovsdbNodeAugmentation);
assertNotNull(ovsdbNodeAugmentation.getOvsVersion());
}
@Test
public void testOvsdbNodeDbVersion() throws InterruptedException {
OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.augmentation(OvsdbNodeAugmentation.class);
- Assert.assertNotNull(ovsdbNodeAugmentation);
+ assertNotNull(ovsdbNodeAugmentation);
assertNotNull(ovsdbNodeAugmentation.getDbVersion());
}
@Test
public void testOpenVSwitchOtherConfig() throws InterruptedException {
OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.augmentation(OvsdbNodeAugmentation.class);
- Assert.assertNotNull(ovsdbNodeAugmentation);
- List<OpenvswitchOtherConfigs> otherConfigsList = ovsdbNodeAugmentation.getOpenvswitchOtherConfigs();
+ assertNotNull(ovsdbNodeAugmentation);
+ Map<OpenvswitchOtherConfigsKey, OpenvswitchOtherConfigs> otherConfigsList =
+ ovsdbNodeAugmentation.getOpenvswitchOtherConfigs();
if (otherConfigsList != null) {
- for (OpenvswitchOtherConfigs otherConfig : otherConfigsList) {
+ for (OpenvswitchOtherConfigs otherConfig : otherConfigsList.values()) {
if (otherConfig.getOtherConfigKey().equals("local_ip")) {
LOG.info("local_ip: {}", otherConfig.getOtherConfigValue());
break;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr,portNumber);
String controllerTarget = SouthboundUtil.getControllerTarget(ovsdbNode);
assertNotNull("Failed to get controller target", controllerTarget);
- List<ControllerEntry> setControllerEntry = createControllerEntry(controllerTarget);
+ ControllerEntry setControllerEntry = createControllerEntry(controllerTarget);
Uri setUri = new Uri(controllerTarget);
try (TestBridge testBridge = new TestBridge(connectionInfo, null, SouthboundITConstants.BRIDGE_NAME,null, true,
SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null,
- setControllerEntry, null)) {
+ BindingMap.of(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) {
+ assertNotNull("bridge was not found: " + SouthboundITConstants.BRIDGE_NAME, bridge);
+ assertNotNull("ControllerEntry was not found: " + setControllerEntry, bridge.getControllerEntry());
+ for (ControllerEntry entry : bridge.getControllerEntry().values()) {
if (entry.getTarget() != null) {
- Assert.assertEquals(setUri.toString(), entry.getTarget().toString());
+ assertEquals(setUri.toString(), entry.getTarget().toString());
}
if (entry.getMaxBackoff() != null) {
- Assert.assertEquals(entry.getMaxBackoff(), MAX_BACKOFF);
+ assertEquals(MAX_BACKOFF, entry.getMaxBackoff());
}
if (entry.getInactivityProbe() != null) {
- Assert.assertEquals(entry.getInactivityProbe(),INACTIVITY_PROBE);
+ assertEquals(INACTIVITY_PROBE, entry.getInactivityProbe());
}
}
}
}
- private List<ControllerEntry> createControllerEntry(String controllerTarget) {
- List<ControllerEntry> controllerEntriesList = new ArrayList<>();
- controllerEntriesList.add(new ControllerEntryBuilder()
+ private static @NonNull ControllerEntry createControllerEntry(final String controllerTarget) {
+ return new ControllerEntryBuilder()
.setTarget(new Uri(controllerTarget))
.setMaxBackoff(MAX_BACKOFF)
.setInactivityProbe(INACTIVITY_PROBE)
- .build());
- return controllerEntriesList;
+ .build();
}
private static void setManagedBy(final OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder,
ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(connectionNodePath));
}
- private static List<ProtocolEntry> createMdsalProtocols() {
- List<ProtocolEntry> protocolList = new ArrayList<>();
+ private static Map<ProtocolEntryKey, ProtocolEntry> createMdsalProtocols() {
ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse();
- protocolList.add(new ProtocolEntryBuilder().setProtocol(mapper.get("OpenFlow13")).build());
- return protocolList;
+ return BindingMap.of(new ProtocolEntryBuilder().setProtocol(mapper.get("OpenFlow13")).build());
}
- private OvsdbTerminationPointAugmentationBuilder createGenericOvsdbTerminationPointAugmentationBuilder() {
+ private static OvsdbTerminationPointAugmentationBuilder createGenericOvsdbTerminationPointAugmentationBuilder() {
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointAugmentationBuilder =
new OvsdbTerminationPointAugmentationBuilder();
ovsdbTerminationPointAugmentationBuilder.setInterfaceType(
return ovsdbTerminationPointAugmentationBuilder;
}
- private OvsdbTerminationPointAugmentationBuilder createGenericDpdkOvsdbTerminationPointAugmentationBuilder(
+ private static OvsdbTerminationPointAugmentationBuilder createGenericDpdkOvsdbTerminationPointAugmentationBuilder(
final String portName) {
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
return ovsdbTerminationBuilder;
}
- private OvsdbTerminationPointAugmentationBuilder createSpecificDpdkOvsdbTerminationPointAugmentationBuilder(
- String testPortname,Class<? extends InterfaceTypeBase> dpdkIfType) {
- OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
- createGenericOvsdbTerminationPointAugmentationBuilder();
- ovsdbTerminationBuilder.setName(testPortname);
- ovsdbTerminationBuilder.setInterfaceType(dpdkIfType);
- return ovsdbTerminationBuilder;
+ private static OvsdbTerminationPointAugmentationBuilder createSpecificDpdkOvsdbTerminationPointAugmentationBuilder(
+ final String testPortname, final Class<? extends InterfaceTypeBase> dpdkIfType) {
+ return createGenericOvsdbTerminationPointAugmentationBuilder()
+ .setName(testPortname)
+ .setInterfaceType(dpdkIfType);
}
- private boolean addTerminationPoint(final NodeId bridgeNodeId, final String portName,
- final OvsdbTerminationPointAugmentationBuilder
- ovsdbTerminationPointAugmentationBuilder)
+ private static boolean addTerminationPoint(final NodeId bridgeNodeId, final String portName,
+ final OvsdbTerminationPointAugmentationBuilder
+ ovsdbTerminationPointAugmentationBuilder)
throws InterruptedException {
InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(bridgeNodeId);
NodeBuilder portNodeBuilder = new NodeBuilder();
NodeId portNodeId = SouthboundMapper.createManagedNodeId(portIid);
portNodeBuilder.setNodeId(portNodeId);
- TerminationPointBuilder entry = new TerminationPointBuilder();
- entry.withKey(new TerminationPointKey(new TpId(portName)));
- entry.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- ovsdbTerminationPointAugmentationBuilder.build());
- portNodeBuilder.setTerminationPoint(Collections.singletonList(entry.build()));
- boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
- portIid, portNodeBuilder.build());
+ TerminationPointBuilder entry = new TerminationPointBuilder()
+ .withKey(new TerminationPointKey(new TpId(portName)))
+ .addAugmentation(ovsdbTerminationPointAugmentationBuilder.build());
+ portNodeBuilder.setTerminationPoint(BindingMap.of(entry.build()));
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portNodeBuilder.build());
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
return result;
}
final String bridgeName, NodeId bridgeNodeId, final boolean setProtocolEntries,
final Class<? extends OvsdbFailModeBase> failMode, final boolean setManagedBy,
@Nullable final Class<? extends DatapathTypeBase> dpType,
- @Nullable final List<BridgeExternalIds> externalIds,
- @Nullable final List<ControllerEntry> controllerEntries,
- @Nullable final List<BridgeOtherConfigs> otherConfigs) {
+ @Nullable final Map<BridgeExternalIdsKey, BridgeExternalIds> externalIds,
+ @Nullable final Map<ControllerEntryKey, ControllerEntry> controllerEntries,
+ @Nullable final Map<BridgeOtherConfigsKey, BridgeOtherConfigs> otherConfigs) {
this.connectionInfo = connectionInfo;
this.bridgeName = bridgeName;
NodeBuilder bridgeNodeBuilder = new NodeBuilder();
ovsdbBridgeAugmentationBuilder.setBridgeExternalIds(externalIds);
ovsdbBridgeAugmentationBuilder.setControllerEntry(controllerEntries);
ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(otherConfigs);
- bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build());
- LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder.toString());
- Assert.assertTrue(
- mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid, bridgeNodeBuilder.build()));
+ bridgeNodeBuilder.addAugmentation(ovsdbBridgeAugmentationBuilder.build());
+ LOG.debug("Built with the intent to store bridge data {}", ovsdbBridgeAugmentationBuilder);
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid, bridgeNodeBuilder.build()));
try {
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
} catch (InterruptedException e) {
public void close() {
final InstanceIdentifier<Node> iid =
SouthboundUtils.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
try {
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
} catch (InterruptedException e) {
final Uri bridgeId,
@Nullable final String systemName,
@Nullable final String systemDescription,
- @Nullable final List<Mappings> mappings,
- @Nullable final List<AutoattachExternalIds> externalIds) {
+ @Nullable final Map<MappingsKey, Mappings> mappings,
+ @Nullable final Map<AutoattachExternalIdsKey, AutoattachExternalIds> externalIds) {
this.connectionInfo = connectionInfo;
this.autoattachId = autoattachId;
this.bridgeId = bridgeId;
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, iid);
aaOperationalListener.registerDataChangeListener();
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, iid, aaEntry));
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, iid, aaEntry));
try {
aaOperationalListener.waitForCreation(OVSDB_ROUNDTRIP_TIMEOUT);
} catch (InterruptedException e) {
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, iid);
aaOperationalListener.registerDataChangeListener();
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
try {
aaOperationalListener.waitForDeletion(OVSDB_ROUNDTRIP_TIMEOUT);
} catch (InterruptedException e) {
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
// CREATE: Create Autoattach table
NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
Autoattach operAa = getAutoAttach(ovsdbNodeAugmentation, new Uri(testAutoattachId));
// skip tests after verifying that Autoattach doesn't break with unsupported schema
- Assume.assumeFalse(isOldSchema);
+ assumeFalse(isOldSchema);
// FIXME: Remove once CRUD is supported
- Assume.assumeFalse(operAa == null);
+ assumeFalse(operAa == null);
- Assert.assertNotNull(operAa);
- Assert.assertEquals(testSystemName, operAa.getSystemName());
+ assertNotNull(operAa);
+ assertEquals(testSystemName, operAa.getSystemName());
bridge = getBridge(connectionInfo);
Uuid aaUuid = new Uuid(operAa.getAutoattachUuid().getValue());
- Assert.assertEquals(aaUuid, bridge.getAutoAttach());
+ assertEquals(aaUuid, bridge.getAutoAttach());
// UPDATE: Update mappings column of AutoAttach table that was created
- List<Mappings> mappings = ImmutableList.of(new MappingsBuilder().setMappingsKey(100L)
- .setMappingsValue(200).build());
+ Map<MappingsKey, Mappings> mappings = BindingMap.of(new MappingsBuilder()
+ .setMappingsKey(Uint32.valueOf(100))
+ .setMappingsValue(Uint16.valueOf(200))
+ .build());
Autoattach updatedAa = new AutoattachBuilder()
.setAutoattachId(new Uri(testAutoattachId))
.setMappings(mappings)
final NotifyingDataChangeListener aaOperationalListener =
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, iid);
aaOperationalListener.registerDataChangeListener();
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, iid, updatedAa));
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, iid, updatedAa));
aaOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
// UPDATE: Update external_ids column of AutoAttach table that was created
- List<AutoattachExternalIds> externalIds = new ArrayList<>();
+ BindingMap.Builder<AutoattachExternalIdsKey, AutoattachExternalIds> externalIds = BindingMap.builder();
externalIds.add(new AutoattachExternalIdsBuilder()
.setAutoattachExternalIdKey(testAutoattachExternalKey)
.setAutoattachExternalIdValue(testAutoattachExternalValue)
.build());
updatedAa = new AutoattachBuilder()
.setAutoattachId(new Uri(testAutoattachId))
- .setAutoattachExternalIds(externalIds)
+ .setAutoattachExternalIds(externalIds.build())
.build();
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, iid, updatedAa));
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, iid, updatedAa));
aaOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
// READ: Read the updated AutoAttach table for latest mappings and external_ids column value
ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
operAa = getAutoAttach(ovsdbNodeAugmentation, new Uri(testAutoattachId));
- Assert.assertNotNull(operAa);
- List<Mappings> operMappingsList = operAa.getMappings();
- for (Mappings operMappings: operMappingsList) {
- Assert.assertEquals(mappings.get(operMappingsList.indexOf(operMappings))
- .getMappingsKey(), operMappings.getMappingsKey());
- Assert.assertEquals(mappings.get(operMappingsList.indexOf(operMappings))
- .getMappingsValue(), operMappings.getMappingsValue());
+ assertNotNull(operAa);
+ Map<MappingsKey, Mappings> operMappingsList = operAa.getMappings();
+ for (Mappings operMappings : operMappingsList.values()) {
+ assertTrue(mappings.containsValue(operMappings));
}
- List<AutoattachExternalIds> operExternalIds = operAa.getAutoattachExternalIds();
- externalIds.add(new AutoattachExternalIdsBuilder()
- .setAutoattachExternalIdKey(SouthboundConstants.AUTOATTACH_ID_EXTERNAL_ID_KEY)
- .setAutoattachExternalIdValue(operAa.getAutoattachId().getValue())
- .build());
- for (AutoattachExternalIds operExternalId : operExternalIds) {
- Assert.assertEquals(externalIds.get(operExternalIds.indexOf(operExternalId))
- .getAutoattachExternalIdKey(), operExternalId.getAutoattachExternalIdKey());
- Assert.assertEquals(externalIds.get(operExternalIds.indexOf(operExternalId))
- .getAutoattachExternalIdValue(), operExternalId.getAutoattachExternalIdValue());
+ Map<AutoattachExternalIdsKey, AutoattachExternalIds> operExternalIds =
+ operAa.getAutoattachExternalIds();
+ final Collection<AutoattachExternalIds> ids = externalIds.add(new AutoattachExternalIdsBuilder()
+ .setAutoattachExternalIdKey(SouthboundConstants.AUTOATTACH_ID_EXTERNAL_ID_KEY)
+ .setAutoattachExternalIdValue(operAa.getAutoattachId().getValue())
+ .build())
+ .build().values();
+
+ for (AutoattachExternalIds operExternalId : operExternalIds.values()) {
+ assertTrue(ids.contains(operExternalId));
}
// DELETE: Delete AutoAttach table
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, iid));
aaOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
- ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
- LogicalDatastoreType.OPERATIONAL);
+ ovsdbNodeAugmentation = getOvsdbNode(connectionInfo, LogicalDatastoreType.OPERATIONAL);
operAa = getAutoAttach(ovsdbNodeAugmentation, new Uri(testAutoattachId));
- Assert.assertNull(operAa);
+ assertNull(operAa);
} catch (AssumptionViolatedException e) {
LOG.warn("Skipped test for Autoattach due to unsupported schema", e);
}
}
}
- private Autoattach getAutoAttach(OvsdbNodeAugmentation ovsdbNodeAugmentation, Uri uri) {
- if (ovsdbNodeAugmentation.getAutoattach() != null
- && !ovsdbNodeAugmentation.getAutoattach().isEmpty()) {
- for (Autoattach aa : ovsdbNodeAugmentation.getAutoattach()) {
- if (aa.key().getAutoattachId().equals(uri)) {
- return aa;
- }
+ private static Autoattach getAutoAttach(final OvsdbNodeAugmentation ovsdbNodeAugmentation, final Uri uri) {
+ for (Autoattach aa : ovsdbNodeAugmentation.nonnullAutoattach().values()) {
+ if (aa.key().getAutoattachId().equals(uri)) {
+ return aa;
}
}
return null;
TestQos(final ConnectionInfo connectionInfo,
final Uri qosId,
final Class<? extends QosTypeBase> qosType,
- @Nullable final List<QosExternalIds> externalIds,
- @Nullable final List<QosOtherConfig> otherConfigs) {
+ final @Nullable Map<QosExternalIdsKey, QosExternalIds> externalIds,
+ final @Nullable Map<QosOtherConfigKey, QosOtherConfig> otherConfigs) {
this.connectionInfo = connectionInfo;
this.qosId = qosId;
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, qeIid);
qosOperationalListener.registerDataChangeListener();
- Assert.assertTrue(
- mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
- qeIid, qosEntry));
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, qeIid, qosEntry));
try {
qosOperationalListener.waitForCreation(OVSDB_ROUNDTRIP_TIMEOUT);
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, qeIid);
qosOperationalListener.registerDataChangeListener();
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qeIid));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qeIid));
try {
qosOperationalListener.waitForDeletion(OVSDB_ROUNDTRIP_TIMEOUT);
} catch (InterruptedException e) {
* @param externalIds The external identifiers if any.
* @param otherConfigs The other configuration items if any.
*/
- TestQueue(final ConnectionInfo connectionInfo,
- final Uri queueId,
- final Short queueDscp,
- @Nullable final List<QueuesExternalIds> externalIds,
- @Nullable final List<QueuesOtherConfig> otherConfigs) {
+ TestQueue(final ConnectionInfo connectionInfo, final Uri queueId, final Uint8 queueDscp,
+ final @Nullable Map<QueuesExternalIdsKey, QueuesExternalIds> externalIds,
+ final @Nullable Map<QueuesOtherConfigKey, QueuesOtherConfig> otherConfigs) {
this.connectionInfo = connectionInfo;
this.queueId = queueId;
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, queueIid);
queueOperationalListener.registerDataChangeListener();
- Assert.assertTrue(
- mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
- queueIid, queue));
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, queueIid, queue));
try {
queueOperationalListener.waitForCreation(OVSDB_ROUNDTRIP_TIMEOUT);
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, queuesIid);
queueOperationalListener.registerDataChangeListener();
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, queuesIid));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, queuesIid));
try {
queueOperationalListener.waitForDeletion(OVSDB_ROUNDTRIP_TIMEOUT);
} catch (InterruptedException e) {
}
}
- private OvsdbNodeAugmentation getOvsdbNode(ConnectionInfo connectionInfo, LogicalDatastoreType store) {
+ private static OvsdbNodeAugmentation getOvsdbNode(final ConnectionInfo connectionInfo,
+ final LogicalDatastoreType store) {
InstanceIdentifier<Node> nodeIid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
Node node = mdsalUtils.read(store, nodeIid);
- Assert.assertNotNull(node);
+ assertNotNull(node);
OvsdbNodeAugmentation ovsdbNodeAugmentation = node.augmentation(OvsdbNodeAugmentation.class);
- Assert.assertNotNull(ovsdbNodeAugmentation);
+ assertNotNull(ovsdbNodeAugmentation);
return ovsdbNodeAugmentation;
}
- private OvsdbBridgeAugmentation getBridge(ConnectionInfo connectionInfo) {
+ private static OvsdbBridgeAugmentation getBridge(final ConnectionInfo connectionInfo) {
return getBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
}
* @param store defined by the <code>LogicalDatastoreType</code> enumeration
* @return <code>store</code> type data store contents
*/
- private OvsdbBridgeAugmentation getBridge(ConnectionInfo connectionInfo, String bridgeName,
- LogicalDatastoreType store) {
+ private static OvsdbBridgeAugmentation getBridge(final ConnectionInfo connectionInfo, final String bridgeName,
+ final LogicalDatastoreType store) {
Node bridgeNode = getBridgeNode(connectionInfo, bridgeName, store);
- Assert.assertNotNull(bridgeNode);
+ assertNotNull(bridgeNode);
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = bridgeNode.augmentation(OvsdbBridgeAugmentation.class);
- Assert.assertNotNull(ovsdbBridgeAugmentation);
+ assertNotNull(ovsdbBridgeAugmentation);
return ovsdbBridgeAugmentation;
}
* @see SouthboundIT#getBridge(ConnectionInfo, String, LogicalDatastoreType)
* @return <code>LogicalDatastoreType.OPERATIONAL</code> type data store contents
*/
- private OvsdbBridgeAugmentation getBridge(ConnectionInfo connectionInfo, String bridgeName) {
+ private static OvsdbBridgeAugmentation getBridge(final ConnectionInfo connectionInfo, final String bridgeName) {
return getBridge(connectionInfo, bridgeName, LogicalDatastoreType.OPERATIONAL);
}
* @param store defined by the <code>LogicalDatastoreType</code> enumeration
* @return <code>store</code> type data store contents
*/
- private Node getBridgeNode(ConnectionInfo connectionInfo, String bridgeName, LogicalDatastoreType store) {
+ private static Node getBridgeNode(final ConnectionInfo connectionInfo, final String bridgeName,
+ final LogicalDatastoreType store) {
InstanceIdentifier<Node> bridgeIid =
SouthboundUtils.createInstanceIdentifier(connectionInfo, new OvsdbBridgeName(bridgeName));
return mdsalUtils.read(store, bridgeIid);
* @param bridgeName the bridge name
* @return <code>LogicalDatastoreType.OPERATIONAL</code> type data store contents
*/
- private Node getBridgeNode(ConnectionInfo connectionInfo, String bridgeName) {
+ private static Node getBridgeNode(final ConnectionInfo connectionInfo, final String bridgeName) {
return getBridgeNode(connectionInfo, bridgeName, LogicalDatastoreType.OPERATIONAL);
}
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
LOG.info("bridge: {}", bridge);
}
}
- private InstanceIdentifier<Node> getTpIid(ConnectionInfo connectionInfo, OvsdbBridgeAugmentation bridge) {
+ private static InstanceIdentifier<Node> getTpIid(final ConnectionInfo connectionInfo,
+ final OvsdbBridgeAugmentation bridge) {
return SouthboundUtils.createInstanceIdentifier(connectionInfo, bridge.getBridgeName());
}
* @param index the index we're interested in
* @return the augmentation (or {@code null} if none)
*/
- private OvsdbTerminationPointAugmentation getOvsdbTerminationPointAugmentation(
- ConnectionInfo connectionInfo, String bridgeName, LogicalDatastoreType store, int index) {
+ private static OvsdbTerminationPointAugmentation getOvsdbTerminationPointAugmentation(
+ final ConnectionInfo connectionInfo, final String bridgeName, final LogicalDatastoreType store,
+ final int index) {
- List<TerminationPoint> tpList = getBridgeNode(connectionInfo, bridgeName, store).getTerminationPoint();
+ Map<TerminationPointKey, TerminationPoint> tpList = getBridgeNode(connectionInfo, bridgeName, store)
+ .getTerminationPoint();
if (tpList == null) {
return null;
}
- return tpList.get(index).augmentation(OvsdbTerminationPointAugmentation.class);
+ return Iterables.get(tpList.values(), index).augmentation(OvsdbTerminationPointAugmentation.class);
}
@Test
public void testCRUDTerminationPointIfIndex() throws InterruptedException {
final boolean isOldSchema = schemaVersion.compareTo(IF_INDEX_FROM_VERSION) < 0;
- Assume.assumeFalse(isOldSchema);
+ assumeFalse(isOldSchema);
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// Test create ifIndex
SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"),
true, SouthboundMapper.createDatapathType("netdev"), null, null, null)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
LOG.info("bridge: {}", bridge);
NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
String portName = "testIfIndex";
ovsdbTerminationBuilder.setName(portName);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
// Test read ifIndex
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
- Long ifIndex = ovsdbTerminationPointAugmentation.getIfindex();
- Assert.assertNotNull(ifIndex);
+ Long ifIndex = ovsdbTerminationPointAugmentation.getIfindex().toJava();
+ assertNotNull(ifIndex);
LOG.info("ifIndex: {} for the port:{}", ifIndex, portName);
}
}
@Test
public void testCRDTerminationPointOfPort() throws InterruptedException {
- final Long ofportExpected = 45002L;
+ final Uint32 ofportExpected = Uint32.valueOf(45002);
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// CREATE
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
LOG.info("bridge: {}", bridge);
NodeId nodeId = SouthboundMapper.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
ovsdbTerminationBuilder.setName(portName);
ovsdbTerminationBuilder.setOfport(ofportExpected);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
// READ
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
- Long ofPort = ovsdbTerminationPointAugmentation.getOfport();
+ Uint32 ofPort = ovsdbTerminationPointAugmentation.getOfport();
// if ephemeral port 45002 is in use, ofPort is set to 1
- Assert.assertTrue(ofPort.equals(ofportExpected) || ofPort.equals(1L));
+ assertTrue(ofPort.equals(ofportExpected) || ofPort.equals(Uint32.ONE));
LOG.info("ofPort: {}", ofPort);
}
}
@Test
public void testCRDTerminationPointOfPortRequest() throws InterruptedException {
- final Long ofportExpected = 45008L;
- final Long ofportInput = 45008L;
+ final Uint32 ofportExpected = Uint32.valueOf(45008);
+ final Uint32 ofportInput = Uint32.valueOf(45008);
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// CREATE
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
final NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testOfPortRequest";
ovsdbTerminationBuilder.setName(portName);
- Integer ofPortRequestExpected = ofportExpected.intValue();
+ Uint16 ofPortRequestExpected = ofportExpected.toUint16();
ovsdbTerminationBuilder.setOfport(ofportInput);
ovsdbTerminationBuilder.setOfportRequest(ofPortRequestExpected);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
// READ
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
- Long ofPort = ovsdbTerminationPointAugmentation.getOfport();
+ Uint32 ofPort = ovsdbTerminationPointAugmentation.getOfport();
// if ephemeral port 45008 is in use, ofPort is set to 1
- Assert.assertTrue(ofPort.equals(ofportExpected) || ofPort.equals(1L));
+ assertTrue(ofPort.equals(ofportExpected) || ofPort.equals(Uint32.ONE));
LOG.info("ofPort: {}", ofPort);
- Integer ofPortRequest = ovsdbTerminationPointAugmentation.getOfportRequest();
- Assert.assertTrue(ofPortRequest.equals(ofPortRequestExpected));
+ Uint16 ofPortRequest = ovsdbTerminationPointAugmentation.getOfportRequest();
+ assertEquals(ofPortRequestExpected, ofPortRequest);
LOG.info("ofPortRequest: {}", ofPortRequest);
}
}
}
}
- private <T> void assertExpectedExist(List<T> expected, List<T> test) {
+ private static <I extends Identifier<T>, T extends Identifiable<I>> void assertExpectedExist(
+ final Map<I, T> expected, final Map<I, T> test) {
if (expected != null && test != null) {
- for (T exp : expected) {
- Assert.assertTrue("The retrieved values don't contain " + exp, test.contains(exp));
+ for (T exp : expected.values()) {
+ assertTrue("The retrieved values don't contain " + exp, test.containsValue(exp));
}
}
}
- private interface SouthboundTerminationPointHelper<T> {
- void writeValues(OvsdbTerminationPointAugmentationBuilder builder, List<T> values);
+ private interface SouthboundTerminationPointHelper<I extends Identifier<T>, T extends Identifiable<I>> {
+ void writeValues(OvsdbTerminationPointAugmentationBuilder builder, Map<I, T> values);
- List<T> readValues(OvsdbTerminationPointAugmentation augmentation);
+ Map<I, T> readValues(OvsdbTerminationPointAugmentation augmentation);
}
/*
*
* @see <code>SouthboundIT.generatePortExternalIdsTestCases()</code> for specific test case information
*/
- private <T> void testCRUDTerminationPoint(
- KeyValueBuilder<T> builder, String prefix, SouthboundTerminationPointHelper<T> helper)
+ private static <I extends Identifier<T>, T extends Identifiable<I>> void testCRUDTerminationPoint(
+ final KeyValueBuilder<T> builder, final String prefix, final SouthboundTerminationPointHelper<I, T> helper)
throws InterruptedException {
final int terminationPointTestIndex = 0;
// updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
// the update has been performed.
- List<SouthboundTestCase<T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
- List<SouthboundTestCase<T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
+ List<SouthboundTestCase<I, T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
+ List<SouthboundTestCase<I, T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
- for (SouthboundTestCase<T> updateFromTestCase : updateFromTestCases) {
- for (SouthboundTestCase<T> updateToTestCase : updateToTestCases) {
+ for (SouthboundTestCase<I, T> updateFromTestCase : updateFromTestCases) {
+ for (SouthboundTestCase<I, T> updateToTestCase : updateToTestCases) {
String testBridgeAndPortName = String.format("%s_%s", prefix, updateToTestCase.name);
// CREATE: Create the test bridge
createGenericOvsdbTerminationPointAugmentationBuilder();
tpCreateAugmentationBuilder.setName(testBridgeAndPortName);
helper.writeValues(tpCreateAugmentationBuilder, updateFromTestCase.inputValues);
- Assert.assertTrue(
+ assertTrue(
addTerminationPoint(testBridgeNodeId, testBridgeAndPortName, tpCreateAugmentationBuilder));
// READ: Read the test port and ensure changes are propagated to the CONFIGURATION data store,
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
LogicalDatastoreType.CONFIGURATION, terminationPointTestIndex);
if (updateFromConfigurationTerminationPointAugmentation != null) {
- List<T> updateFromConfigurationValues =
+ Map<I, T> updateFromConfigurationValues =
helper.readValues(updateFromConfigurationTerminationPointAugmentation);
assertExpectedExist(updateFromTestCase.expectedValues, updateFromConfigurationValues);
}
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
LogicalDatastoreType.OPERATIONAL, terminationPointTestIndex);
if (updateFromOperationalTerminationPointAugmentation != null) {
- List<T> updateFromOperationalValues =
+ Map<I, T> updateFromOperationalValues =
helper.readValues(updateFromOperationalTerminationPointAugmentation);
assertExpectedExist(updateFromTestCase.expectedValues, updateFromOperationalValues);
}
portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
tpUpdateBuilder.withKey(new TerminationPointKey(new TpId(testBridgeAndPortName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
- portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ tpUpdateBuilder.addAugmentation(tpUpdateAugmentationBuilder.build());
+ portUpdateNodeBuilder.setTerminationPoint(BindingMap.of(tpUpdateBuilder.build()));
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
LogicalDatastoreType.CONFIGURATION, terminationPointTestIndex);
if (updateToConfigurationTerminationPointAugmentation != null) {
- List<T> updateToConfigurationValues =
+ Map<I, T> updateToConfigurationValues =
helper.readValues(updateToConfigurationTerminationPointAugmentation);
assertExpectedExist(updateToTestCase.expectedValues, updateToConfigurationValues);
assertExpectedExist(updateFromTestCase.expectedValues, updateToConfigurationValues);
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
LogicalDatastoreType.OPERATIONAL, terminationPointTestIndex);
if (updateToOperationalTerminationPointAugmentation != null) {
- List<T> updateToOperationalValues =
+ Map<I, T> updateToOperationalValues =
helper.readValues(updateToOperationalTerminationPointAugmentation);
if (updateFromTestCase.expectedValues != null) {
assertExpectedExist(updateToTestCase.expectedValues, updateToOperationalValues);
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
// add and delete a single port
String portName = port1;
ovsdbTerminationBuilder.setName(portName);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
SouthboundUtils.createInstanceIdentifier(connectionInfo,
new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME));
new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME))
.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
- Assert.assertTrue("failed to delete port " + portName,
+ assertTrue("failed to delete port " + portName,
mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, nodePath));
LOG.info("shague: waiting for delete {}", portName);
Thread.sleep(1000);
TerminationPoint terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodePath);
- Assert.assertNull(terminationPoint);
+ assertNull(terminationPoint);
// add two ports, then delete them
portName = port1;
ovsdbTerminationBuilder.setName(portName);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
terminationPointIid = getTpIid(connectionInfo, bridge);
terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
portName = port2;
ovsdbTerminationBuilder.setName(portName);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
terminationPointIid = getTpIid(connectionInfo, bridge);
terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
SouthboundUtils.createInstanceIdentifier(connectionInfo,
new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME));
new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME))
.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
- Assert.assertTrue("failed to delete port " + portName,
+ assertTrue("failed to delete port " + portName,
mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, nodePath));
LOG.info("shague: waiting for delete {}", portName);
Thread.sleep(1000);
terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodePath);
- Assert.assertNull(terminationPoint);
+ assertNull(terminationPoint);
portName = port2;
nodePath = SouthboundUtils.createInstanceIdentifier(connectionInfo,
new OvsdbBridgeName(SouthboundITConstants.BRIDGE_NAME))
.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
- Assert.assertTrue("failed to delete port " + portName,
+ assertTrue("failed to delete port " + portName,
mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, nodePath));
LOG.info("shague: waiting for delete {}", portName);
Thread.sleep(1000);
terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodePath);
- Assert.assertNull(terminationPoint);
+ assertNull(terminationPoint);
// DELETE handled by TestBridge
}
@Test
public void testCRUDTerminationPointVlan() throws InterruptedException {
- final Integer createdVlanId = 4000;
- final Integer updatedVlanId = 4001;
+ final Uint16 createdVlanId = Uint16.valueOf(4000);
+ final Uint16 updatedVlanId = Uint16.valueOf(4001);
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// CREATE
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
String portName = "testTerminationPointVlanId";
ovsdbTerminationBuilder.setName(portName);
ovsdbTerminationBuilder.setVlanTag(new VlanId(createdVlanId));
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
// READ
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation;
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
ovsdbTerminationPointAugmentation = terminationPoint.augmentation(
OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
VlanId actualVlanId = ovsdbTerminationPointAugmentation.getVlanTag();
- Assert.assertNotNull(actualVlanId);
- Integer actualVlanIdInt = actualVlanId.getValue();
- Assert.assertEquals(createdVlanId, actualVlanIdInt);
+ assertNotNull(actualVlanId);
+ assertEquals(createdVlanId, actualVlanId.getValue());
}
}
portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
tpUpdateBuilder.withKey(new TerminationPointKey(new TpId(portName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
+ tpUpdateBuilder.addAugmentation(tpUpdateAugmentationBuilder.build());
tpUpdateBuilder.setTpId(new TpId(portName));
- portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
- Assert.assertTrue(
+ portUpdateNodeBuilder.setTerminationPoint(BindingMap.of(tpUpdateBuilder.build()));
+ assertTrue(
mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
ovsdbTerminationPointAugmentation = terminationPoint.augmentation(
OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
VlanId actualVlanId = ovsdbTerminationPointAugmentation.getVlanTag();
- Assert.assertNotNull(actualVlanId);
- Integer actualVlanIdInt = actualVlanId.getValue();
- Assert.assertEquals(updatedVlanId, actualVlanIdInt);
+ assertNotNull(actualVlanId);
+ assertEquals(updatedVlanId, actualVlanId.getValue());
}
}
// CREATE
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
String portName = "testTerminationPointVlanMode" + vlanMode.toString();
ovsdbTerminationBuilder.setName(portName);
ovsdbTerminationBuilder.setVlanMode(vlanMode);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
// READ
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
//test
- Assert.assertTrue(ovsdbTerminationPointAugmentation.getVlanMode().equals(vlanMode));
+ assertTrue(ovsdbTerminationPointAugmentation.getVlanMode().equals(vlanMode));
}
}
portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
tpUpdateBuilder.withKey(new TerminationPointKey(new TpId(portName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
+ tpUpdateBuilder.addAugmentation(tpUpdateAugmentationBuilder.build());
tpUpdateBuilder.setTpId(new TpId(portName));
- portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
- Assert.assertTrue(
+ portUpdateNodeBuilder.setTerminationPoint(BindingMap.of(tpUpdateBuilder.build()));
+ assertTrue(
mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
//test
- Assert.assertEquals(updatedVlanMode, ovsdbTerminationPointAugmentation.getVlanMode());
+ assertEquals(updatedVlanMode, ovsdbTerminationPointAugmentation.getVlanMode());
}
}
}
}
- private List<Set<Integer>> generateVlanSets() {
+ private static List<Set<Uint16>> generateVlanSets() {
int min = 0;
int max = 4095;
return Lists.newArrayList(
- Collections.<Integer>emptySet(),
- Collections.singleton(2222),
- Sets.newHashSet(min, max, min + 1, max - 1, (max - min) / 2));
+ Collections.<Uint16>emptySet(),
+ Collections.singleton(Uint16.valueOf(2222)),
+ Sets.newHashSet(Uint16.valueOf(min), Uint16.valueOf(max), Uint16.valueOf(min + 1),
+ Uint16.valueOf(max - 1), Uint16.valueOf((max - min) / 2)));
}
- private List<Trunks> buildTrunkList(Set<Integer> trunkSet) {
+ private static List<Trunks> buildTrunkList(final Set<Uint16> trunkSet) {
List<Trunks> trunkList = new ArrayList<>();
- for (Integer trunk : trunkSet) {
- TrunksBuilder trunkBuilder = new TrunksBuilder();
- trunkBuilder.setTrunk(new VlanId(trunk));
- trunkList.add(trunkBuilder.build());
+ for (Uint16 trunk : trunkSet) {
+ trunkList.add(new TrunksBuilder().setTrunk(new VlanId(trunk)).build());
}
return trunkList;
}
@Test
public void testCRUDTerminationPointVlanTrunks() throws InterruptedException {
- final List<Trunks> updatedTrunks = buildTrunkList(Collections.singleton(2011));
+ final List<Trunks> updatedTrunks = buildTrunkList(Collections.singleton(Uint16.valueOf(2011)));
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
- Iterable<Set<Integer>> vlanSets = generateVlanSets();
+ Iterable<Set<Uint16>> vlanSets = generateVlanSets();
int testCase = 0;
- for (Set<Integer> vlanSet : vlanSets) {
+ for (Set<Uint16> vlanSet : vlanSets) {
++testCase;
// CREATE
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
NodeId nodeId = SouthboundUtils.createManagedNodeId(connectionInfo, bridge.getBridgeName());
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
ovsdbTerminationBuilder.setName(portName);
List<Trunks> trunks = buildTrunkList(vlanSet);
ovsdbTerminationBuilder.setTrunks(trunks);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- Assert.assertNotNull(terminationPointNode);
+ assertNotNull(terminationPointNode);
// READ
- List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
+ Collection<TerminationPoint> terminationPoints =
+ terminationPointNode.nonnullTerminationPoint().values();
for (TerminationPoint terminationPoint : terminationPoints) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
List<Trunks> actualTrunks = ovsdbTerminationPointAugmentation.getTrunks();
for (Trunks trunk : trunks) {
- Assert.assertTrue(actualTrunks.contains(trunk));
+ assertTrue(actualTrunks.contains(trunk));
}
}
}
portUpdateNodeBuilder.setNodeId(portUpdateNodeId);
TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
tpUpdateBuilder.withKey(new TerminationPointKey(new TpId(portName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
+ tpUpdateBuilder.addAugmentation(tpUpdateAugmentationBuilder.build());
tpUpdateBuilder.setTpId(new TpId(portName));
- portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
- Assert.assertTrue(
+ portUpdateNodeBuilder.setTerminationPoint(BindingMap.of(tpUpdateBuilder.build()));
+ assertTrue(
mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
- terminationPoints = terminationPointNode.getTerminationPoint();
- for (TerminationPoint terminationPoint : terminationPoints) {
+ for (TerminationPoint terminationPoint : terminationPointNode.nonnullTerminationPoint().values()) {
OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
terminationPoint.augmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
//test
- Assert.assertEquals(updatedTrunks, ovsdbTerminationPointAugmentation.getTrunks());
+ assertEquals(updatedTrunks, ovsdbTerminationPointAugmentation.getTrunks());
}
}
OvsdbNodeAugmentation ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
QosEntries operQos = getQos(new Uri(testQosId), ovsdbNodeAugmentation);
- Assert.assertNotNull(operQos);
+ assertNotNull(operQos);
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
- Assert.assertNotNull(bridge);
+ assertNotNull(bridge);
NodeId nodeId = SouthboundUtils.createManagedNodeId(connectionInfo, bridge.getBridgeName());
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testTerminationPointQos";
ovsdbTerminationBuilder.setName(portName);
- Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
+ assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
// READ and check that qos uuid has been added to the port
InstanceIdentifier<TerminationPoint> tpEntryIid = getTpIid(connectionInfo, bridge)
.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
TerminationPoint terminationPoint = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, tpEntryIid);
- Assert.assertNotNull(terminationPoint);
+ assertNotNull(terminationPoint);
// UPDATE - remove the qos entry from the port
OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
tpUpdateAugmentationBuilder.setName(portName);
TerminationPointBuilder tpUpdateBuilder = new TerminationPointBuilder();
tpUpdateBuilder.withKey(new TerminationPointKey(new TpId(portName)));
- tpUpdateBuilder.addAugmentation(
- OvsdbTerminationPointAugmentation.class,
- tpUpdateAugmentationBuilder.build());
+ tpUpdateBuilder.addAugmentation(tpUpdateAugmentationBuilder.build());
tpUpdateBuilder.setTpId(new TpId(portName));
- Assert.assertTrue(
+ assertTrue(
mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, tpEntryIid, tpUpdateBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
// READ and verify that qos uuid has been removed from port
TerminationPoint terminationPointUpdate = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, tpEntryIid);
- Assert.assertNotNull(terminationPointUpdate);
+ assertNotNull(terminationPointUpdate);
// DELETE handled by TestBridge
}
InstanceIdentifier<Node> expectedNodeIid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
NodeId expectedNodeId = expectedNodeIid.firstKeyOf(Node.class).getNodeId();
Node foundNode = null;
- Assert.assertNotNull("Expected to find topology: " + topologyPath, topology);
- Assert.assertNotNull("Expected to find some nodes" + topology.getNode());
+ assertNotNull("Expected to find topology: " + topologyPath, topology);
+ assertNotNull("Expected to find some nodes" + topology.getNode());
LOG.info("expectedNodeId: {}, getNode: {}", expectedNodeId, topology.getNode());
- for (Node node : topology.getNode()) {
+ for (Node node : topology.nonnullNode().values()) {
if (node.getNodeId().getValue().equals(expectedNodeId.getValue())) {
foundNode = node;
break;
}
}
- Assert.assertNotNull("Expected to find Node: " + expectedNodeId, foundNode);
+ assertNotNull("Expected to find Node: " + expectedNodeId, foundNode);
}
/*
new BridgeOtherConfigsSouthboundHelper());
}
- private interface SouthboundBridgeHelper<T> {
- void writeValues(OvsdbBridgeAugmentationBuilder builder, List<T> values);
+ private interface SouthboundBridgeHelper<I extends Identifier<T>, T extends Identifiable<I>> {
+ void writeValues(OvsdbBridgeAugmentationBuilder builder, Map<I, T> values);
- List<T> readValues(OvsdbBridgeAugmentation augmentation);
+ Map<I, T> readValues(OvsdbBridgeAugmentation augmentation);
}
- private <T> void testCRUDBridge(String prefix, KeyValueBuilder<T> builder, SouthboundBridgeHelper<T> helper)
- throws InterruptedException {
+ private static <I extends Identifier<T>, T extends Identifiable<I>> void testCRUDBridge(final String prefix,
+ final KeyValueBuilder<T> builder, final SouthboundBridgeHelper<I, T> helper) throws InterruptedException {
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
// the update has been performed.
- List<SouthboundTestCase<T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
- List<SouthboundTestCase<T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
- for (SouthboundTestCase<T> updateFromTestCase : updateFromTestCases) {
- for (SouthboundTestCase<T> updateToTestCase : updateToTestCases) {
+ List<SouthboundTestCase<I, T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
+ List<SouthboundTestCase<I, T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
+ for (SouthboundTestCase<I, T> updateFromTestCase : updateFromTestCases) {
+ for (SouthboundTestCase<I, T> updateToTestCase : updateToTestCases) {
String testBridgeName = String.format("%s_%s", prefix, updateToTestCase.name);
// CREATE: Create the test bridge
SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"));
setManagedBy(bridgeCreateAugmentationBuilder, connectionInfo);
helper.writeValues(bridgeCreateAugmentationBuilder, updateFromTestCase.inputValues);
- bridgeCreateNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class,
- bridgeCreateAugmentationBuilder.build());
- LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder.toString());
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
+ bridgeCreateNodeBuilder.addAugmentation(bridgeCreateAugmentationBuilder.build());
+ LOG.debug("Built with the intent to store bridge data {}", bridgeCreateAugmentationBuilder);
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
bridgeCreateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
// READ: Read the test bridge and ensure changes are propagated to the CONFIGURATION data store,
// then repeat for OPERATIONAL data store
- List<T> updateFromConfigurationExternalIds = helper.readValues(getBridge(connectionInfo, testBridgeName,
- LogicalDatastoreType.CONFIGURATION));
+ Map<I, T> updateFromConfigurationExternalIds = helper.readValues(getBridge(connectionInfo,
+ testBridgeName, LogicalDatastoreType.CONFIGURATION));
assertExpectedExist(updateFromTestCase.expectedValues, updateFromConfigurationExternalIds);
- List<T> updateFromOperationalExternalIds = helper.readValues(getBridge(connectionInfo, testBridgeName));
+ Map<I, T> updateFromOperationalExternalIds = helper.readValues(getBridge(connectionInfo,
+ testBridgeName));
assertExpectedExist(updateFromTestCase.expectedValues, updateFromOperationalExternalIds);
// UPDATE: update the values
final Node bridgeNode = getBridgeNode(connectionInfo, testBridgeName);
bridgeUpdateNodeBuilder.setNodeId(bridgeNode.getNodeId());
bridgeUpdateNodeBuilder.withKey(bridgeNode.key());
- bridgeUpdateNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class,
- bridgeUpdateAugmentationBuilder.build());
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
+ bridgeUpdateNodeBuilder.addAugmentation(bridgeUpdateAugmentationBuilder.build());
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, bridgeIid,
bridgeUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
// READ: the test bridge and ensure changes are propagated to the CONFIGURATION data store,
// then repeat for OPERATIONAL data store
- List<T> updateToConfigurationExternalIds = helper.readValues(getBridge(connectionInfo, testBridgeName,
+ Map<I, T> updateToConfigurationExternalIds = helper.readValues(getBridge(connectionInfo, testBridgeName,
LogicalDatastoreType.CONFIGURATION));
assertExpectedExist(updateToTestCase.expectedValues, updateToConfigurationExternalIds);
assertExpectedExist(updateFromTestCase.expectedValues, updateToConfigurationExternalIds);
- List<T> updateToOperationalExternalIds = helper.readValues(getBridge(connectionInfo, testBridgeName));
+ Map<I, T> updateToOperationalExternalIds = helper.readValues(getBridge(connectionInfo, testBridgeName));
if (updateFromTestCase.expectedValues != null) {
assertExpectedExist(updateToTestCase.expectedValues, updateToOperationalExternalIds);
assertExpectedExist(updateFromTestCase.expectedValues, updateToOperationalExternalIds);
}
// DELETE
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, bridgeIid));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, bridgeIid));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
}
}
ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
QosEntries operQosHtb = getQos(qosUri, ovsdbNodeAugmentation);
- Assert.assertNotNull(operQosHtb);
+ assertNotNull(operQosHtb);
}
ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
QosEntries operQosHtb = getQos(qosUri, ovsdbNodeAugmentation);
- Assert.assertNull(operQosHtb);
+ assertNull(operQosHtb);
}
}
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
Uri queueUri = new Uri("QUEUE-A1");
- try (TestQueue testQueue = new TestQueue(connectionInfo, queueUri, new Short("25"), null, null)) {
+ try (TestQueue testQueue = new TestQueue(connectionInfo, queueUri, Uint8.valueOf(25), null, null)) {
OvsdbNodeAugmentation ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
Queues operQueue = getQueue(queueUri, ovsdbNodeAugmentation);
- Assert.assertNotNull(operQueue);
+ assertNotNull(operQueue);
}
OvsdbNodeAugmentation ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
Queues operQueue = getQueue(queueUri, ovsdbNodeAugmentation);
- Assert.assertNull(operQueue);
+ assertNull(operQueue);
}
- private static class SouthboundQueuesExternalIdsHelper implements SouthboundQueueHelper<QueuesExternalIds> {
+ private static class SouthboundQueuesExternalIdsHelper
+ implements SouthboundQueueHelper<QueuesExternalIdsKey, QueuesExternalIds> {
@Override
- public void writeValues(QueuesBuilder builder, List<QueuesExternalIds> values) {
+ public void writeValues(final QueuesBuilder builder,
+ final Map<QueuesExternalIdsKey, QueuesExternalIds> values) {
builder.setQueuesExternalIds(values);
}
@Override
- public List<QueuesExternalIds> readValues(Queues queue) {
+ public Map<QueuesExternalIdsKey, QueuesExternalIds> readValues(final Queues queue) {
return queue.getQueuesExternalIds();
}
}
- private static class SouthboundQueuesOtherConfigHelper implements SouthboundQueueHelper<QueuesOtherConfig> {
+ private static class SouthboundQueuesOtherConfigHelper
+ implements SouthboundQueueHelper<QueuesOtherConfigKey, QueuesOtherConfig> {
@Override
- public void writeValues(QueuesBuilder builder, List<QueuesOtherConfig> values) {
+ public void writeValues(final QueuesBuilder builder,
+ final Map<QueuesOtherConfigKey, QueuesOtherConfig> values) {
builder.setQueuesOtherConfig(values);
}
@Override
- public List<QueuesOtherConfig> readValues(Queues queue) {
+ public Map<QueuesOtherConfigKey, QueuesOtherConfig> readValues(final Queues queue) {
return queue.getQueuesOtherConfig();
}
}
- private interface SouthboundQueueHelper<T> {
- void writeValues(QueuesBuilder builder, List<T> values);
+ private interface SouthboundQueueHelper<I extends Identifier<T>, T extends Identifiable<I>> {
+ void writeValues(QueuesBuilder builder, Map<I, T> values);
- List<T> readValues(Queues queue);
+ Map<I, T> readValues(Queues queue);
}
- private Queues getQueue(Uri queueId, OvsdbNodeAugmentation node) {
- for (Queues queue : node.getQueues()) {
+ private static Queues getQueue(final Uri queueId, final OvsdbNodeAugmentation node) {
+ for (Queues queue : node.nonnullQueues().values()) {
if (queue.key().getQueueId().getValue().equals(queueId.getValue())) {
return queue;
}
return null;
}
- private static class SouthboundQosExternalIdsHelper implements SouthboundQosHelper<QosExternalIds> {
+ private static class SouthboundQosExternalIdsHelper
+ implements SouthboundQosHelper<QosExternalIdsKey, QosExternalIds> {
@Override
- public void writeValues(QosEntriesBuilder builder, List<QosExternalIds> values) {
+ public void writeValues(final QosEntriesBuilder builder, final Map<QosExternalIdsKey, QosExternalIds> values) {
builder.setQosExternalIds(values);
}
@Override
- public List<QosExternalIds> readValues(QosEntries qos) {
+ public Map<QosExternalIdsKey, QosExternalIds> readValues(final QosEntries qos) {
return qos.getQosExternalIds();
}
}
- private static class SouthboundQosOtherConfigHelper implements SouthboundQosHelper<QosOtherConfig> {
+ private static class SouthboundQosOtherConfigHelper
+ implements SouthboundQosHelper<QosOtherConfigKey, QosOtherConfig> {
@Override
- public void writeValues(QosEntriesBuilder builder, List<QosOtherConfig> values) {
+ public void writeValues(final QosEntriesBuilder builder, final Map<QosOtherConfigKey, QosOtherConfig> values) {
builder.setQosOtherConfig(values);
}
@Override
- public List<QosOtherConfig> readValues(QosEntries qos) {
+ public Map<QosOtherConfigKey, QosOtherConfig> readValues(final QosEntries qos) {
return qos.getQosOtherConfig();
}
}
- private interface SouthboundQosHelper<T> {
- void writeValues(QosEntriesBuilder builder, List<T> values);
+ private interface SouthboundQosHelper<I extends Identifier<T>, T extends Identifiable<I>> {
+ void writeValues(QosEntriesBuilder builder, Map<I, T> values);
- List<T> readValues(QosEntries qos);
+ Map<I, T> readValues(QosEntries qos);
}
- private QosEntries getQos(Uri qosId, OvsdbNodeAugmentation node) {
- for (QosEntries qos : node.getQosEntries()) {
+ private static QosEntries getQos(final Uri qosId, final OvsdbNodeAugmentation node) {
+ for (QosEntries qos : node.nonnullQosEntries().values()) {
if (qos.key().getQosId().equals(qosId)) {
return qos;
}
return null;
}
- private <T> void testCRUDQueue(
- KeyValueBuilder<T> builder, String prefix, SouthboundQueueHelper<T> helper)
+ private static <I extends Identifier<T>, T extends Identifiable<I>> void testCRUDQueue(
+ final KeyValueBuilder<T> builder, final String prefix, final SouthboundQueueHelper<I, T> helper)
throws InterruptedException {
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
// the update has been performed.
- List<SouthboundTestCase<T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
- List<SouthboundTestCase<T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
+ List<SouthboundTestCase<I, T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
+ List<SouthboundTestCase<I, T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
- for (SouthboundTestCase<T> updateFromTestCase : updateFromTestCases) {
- for (SouthboundTestCase<T> updateToTestCase : updateToTestCases) {
+ for (SouthboundTestCase<I, T> updateFromTestCase : updateFromTestCases) {
+ for (SouthboundTestCase<I, T> updateToTestCase : updateToTestCases) {
String testQueueId = String.format("%s_%s", prefix, updateToTestCase.name);
// CREATE: and update the test queue with starting values.
try (TestQueue testQueue = new TestQueue(connectionInfo, new Uri(testQueueId),
- new Short("45"), null, null)) {
+ Uint8.valueOf(45), null, null)) {
QueuesBuilder queuesBuilder = new QueuesBuilder();
queuesBuilder.setQueueId(new Uri(testQueueId));
InstanceIdentifier<Queues> queueIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
queueOperationalListener.registerDataChangeListener();
helper.writeValues(queuesBuilder, updateFromTestCase.inputValues);
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
queueIid, queuesBuilder.build()));
queueConfigurationListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
Queues queueFromConfig =
getQueue(new Uri(testQueueId), updateFromConfigurationOvsdbNodeAugmentation);
if (queueFromConfig != null) {
- List<T> updateFromConfigurationValues =
- helper.readValues(queueFromConfig);
- assertExpectedExist(updateFromTestCase.expectedValues, updateFromConfigurationValues);
+ assertExpectedExist(updateFromTestCase.expectedValues, helper.readValues(queueFromConfig));
}
queueOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
LogicalDatastoreType.OPERATIONAL);
Queues queueFromOper = getQueue(new Uri(testQueueId), updateFromOperationalOvsdbNodeAugmentation);
if (queueFromOper != null) {
- List<T> updateFromOperationalValues =
- helper.readValues(queueFromOper);
- assertExpectedExist(updateFromTestCase.expectedValues, updateFromOperationalValues);
+ assertExpectedExist(updateFromTestCase.expectedValues, helper.readValues(queueFromOper));
}
// UPDATE: update the values
QueuesBuilder queuesUpdateBuilder = new QueuesBuilder();
queuesUpdateBuilder.setQueueId(new Uri(testQueueId));
helper.writeValues(queuesUpdateBuilder, updateToTestCase.inputValues);
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
queueIid, queuesUpdateBuilder.build()));
queueConfigurationListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
LogicalDatastoreType.CONFIGURATION);
Queues queueToConfig = getQueue(new Uri(testQueueId), updateToConfigurationOvsdbNodeAugmentation);
if (queueToConfig != null) {
- List<T> updateToConfigurationValues =
- helper.readValues(queueToConfig);
- assertExpectedExist(updateToTestCase.expectedValues, updateToConfigurationValues);
+ assertExpectedExist(updateToTestCase.expectedValues, helper.readValues(queueToConfig));
}
queueOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
LogicalDatastoreType.OPERATIONAL);
Queues queueToOper = getQueue(new Uri(testQueueId), updateToOperationalOvsdbNodeAugmentation);
if (queueToOper != null) {
- List<T> updateToOperationalValues =
- helper.readValues(queueToOper);
- assertExpectedExist(updateToTestCase.expectedValues, updateToOperationalValues);
+ assertExpectedExist(updateToTestCase.expectedValues, helper.readValues(queueToOper));
}
// DELETE handled by TestQueue
String testQueueId = "testQueueDscp";
// CREATE: and update the test queue with starting values.
- try (TestQueue testQueue = new TestQueue(connectionInfo, new Uri(testQueueId), new Short("0"), null, null)) {
- for (Short dscp = 1; dscp < 64; dscp++) {
+ try (TestQueue testQueue = new TestQueue(connectionInfo, new Uri(testQueueId), Uint8.ZERO, null, null)) {
+ for (short dscp = 1; dscp < 64; dscp++) {
QueuesBuilder queuesBuilder = new QueuesBuilder();
queuesBuilder.setQueueId(new Uri(testQueueId));
InstanceIdentifier<Queues> queueIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, queueIid);
queueOperationalListener.registerDataChangeListener();
- queuesBuilder.setDscp(dscp);
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ queuesBuilder.setDscp(Uint8.valueOf(dscp));
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
queueIid, queuesBuilder.build()));
queueOperationalListener.waitForUpdate(OVSDB_ROUNDTRIP_TIMEOUT);
OvsdbNodeAugmentation ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
Queues operQueue = getQueue(new Uri(testQueueId), ovsdbNodeAugmentation);
- Assert.assertNotNull(operQueue);
- Short operDscp = operQueue.getDscp();
- Assert.assertNotNull(operDscp);
- Assert.assertEquals(dscp, operDscp);
+ assertNotNull(operQueue);
+ assertEquals(dscp, operQueue.getDscp().toJava());
}
// DELETE handled by TestQueue
}
- private <T> void testCRUDQos(
- KeyValueBuilder<T> builder, String prefix, SouthboundQosHelper<T> helper)
+ private static <I extends Identifier<T>, T extends Identifiable<I>> void testCRUDQos(
+ final KeyValueBuilder<T> builder, final String prefix, final SouthboundQosHelper<I, T> helper)
throws InterruptedException {
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// updateFromTestCases represent the original test case value. updateToTestCases represent the new value after
// the update has been performed.
- List<SouthboundTestCase<T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
- List<SouthboundTestCase<T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
+ List<SouthboundTestCase<I, T>> updateFromTestCases = generateKeyValueTestCases(builder, prefix + "From");
+ List<SouthboundTestCase<I, T>> updateToTestCases = generateKeyValueTestCases(builder, prefix + "To");
- for (SouthboundTestCase<T> updateFromTestCase : updateFromTestCases) {
- for (SouthboundTestCase<T> updateToTestCase : updateToTestCases) {
+ for (SouthboundTestCase<I, T> updateFromTestCase : updateFromTestCases) {
+ for (SouthboundTestCase<I, T> updateToTestCase : updateToTestCases) {
String testQosId = String.format("%s_%s", prefix, updateToTestCase.name);
// CREATE: and update the test qos with starting values.
qosOperationalListener.registerDataChangeListener();
helper.writeValues(qosBuilder, updateFromTestCase.inputValues);
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
qosIid, qosBuilder.build()));
qosConfigurationListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
LogicalDatastoreType.CONFIGURATION);
QosEntries qosFromConfig = getQos(new Uri(testQosId), updateFromConfigurationOvsdbNodeAugmentation);
if (qosFromConfig != null) {
- List<T> updateFromConfigurationValues =
- helper.readValues(qosFromConfig);
- assertExpectedExist(updateFromTestCase.expectedValues, updateFromConfigurationValues);
+ assertExpectedExist(updateFromTestCase.expectedValues, helper.readValues(qosFromConfig));
}
qosOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
LogicalDatastoreType.OPERATIONAL);
QosEntries qosFromOper = getQos(new Uri(testQosId), updateFromOperationalOvsdbNodeAugmentation);
if (qosFromOper != null) {
- List<T> updateFromOperationalValues =
- helper.readValues(qosFromOper);
- assertExpectedExist(updateFromTestCase.expectedValues, updateFromOperationalValues);
+ assertExpectedExist(updateFromTestCase.expectedValues, helper.readValues(qosFromOper));
}
// UPDATE: update the values
QosEntriesBuilder qosUpdateBuilder = new QosEntriesBuilder();
qosUpdateBuilder.setQosId(new Uri(testQosId));
helper.writeValues(qosUpdateBuilder, updateToTestCase.inputValues);
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
qosIid, qosUpdateBuilder.build()));
qosConfigurationListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
LogicalDatastoreType.CONFIGURATION);
QosEntries qosToConfig = getQos(new Uri(testQosId), updateToConfigurationOvsdbNodeAugmentation);
if (qosToConfig != null) {
- List<T> updateToConfigurationValues =
- helper.readValues(qosToConfig);
- assertExpectedExist(updateToTestCase.expectedValues, updateToConfigurationValues);
+ assertExpectedExist(updateToTestCase.expectedValues, helper.readValues(qosToConfig));
}
qosOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
LogicalDatastoreType.OPERATIONAL);
QosEntries qosToOper = getQos(new Uri(testQosId), updateToOperationalOvsdbNodeAugmentation);
if (qosToOper != null) {
- List<T> updateToOperationalValues =
- helper.readValues(qosToOper);
- assertExpectedExist(updateToTestCase.expectedValues, updateToOperationalValues);
+ assertExpectedExist(updateToTestCase.expectedValues, helper.readValues(qosToOper));
}
// DELETE handled by TestQueue
// CREATE: and update the test queue with starting values.
try (TestQos testQos = new TestQos(connectionInfo, new Uri(testQosId),
SouthboundMapper.createQosType(SouthboundConstants.QOS_LINUX_HTB), null, null);
- TestQueue testQueue1 = new TestQueue(connectionInfo, new Uri("queue1"), new Short("12"), null, null);
- TestQueue testQueue2 = new TestQueue(connectionInfo, new Uri("queue2"), new Short("35"), null, null)) {
+ TestQueue testQueue1 = new TestQueue(connectionInfo, new Uri("queue1"), Uint8.valueOf(12), null,
+ null);
+ TestQueue testQueue2 = new TestQueue(connectionInfo, new Uri("queue2"), Uint8.valueOf(35), null,
+ null)) {
QosEntriesBuilder qosBuilder = new QosEntriesBuilder();
qosBuilder.setQosId(new Uri(testQosId));
InstanceIdentifier<QosEntries> qosIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
Queues operQueue1 = getQueue(new Uri("queue1"), ovsdbNodeAugmentation);
- Assert.assertNotNull(operQueue1);
+ assertNotNull(operQueue1);
InstanceIdentifier<Queues> queue1Iid = testQueue1.getInstanceIdentifier();
OvsdbQueueRef queue1Ref = new OvsdbQueueRef(queue1Iid);
Queues operQueue2 = getQueue(new Uri("queue2"), ovsdbNodeAugmentation);
- Assert.assertNotNull(operQueue2);
+ assertNotNull(operQueue2);
InstanceIdentifier<Queues> queue2Iid = testQueue2.getInstanceIdentifier();
OvsdbQueueRef queue2Ref = new OvsdbQueueRef(queue2Iid);
- List<QueueList> queueList = new ArrayList<>();
- queueList.add(new QueueListBuilder().setQueueNumber(new Long("1")).setQueueRef(queue1Ref).build());
- queueList.add(new QueueListBuilder().setQueueNumber(new Long("2")).setQueueRef(queue2Ref).build());
+ Map<QueueListKey, QueueList> queueList = BindingMap.of(
+ new QueueListBuilder().setQueueNumber(Uint32.ONE).setQueueRef(queue1Ref).build(),
+ new QueueListBuilder().setQueueNumber(Uint32.TWO).setQueueRef(queue2Ref).build());
qosBuilder.setQueueList(queueList);
- Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
+ assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
qosIid, qosBuilder.build()));
qosOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
QosEntries operQos = getQos(new Uri(testQosId), ovsdbNodeAugmentation);
- Assert.assertNotNull(operQos);
- List<QueueList> operQueueList = operQos.getQueueList();
- Assert.assertNotNull(operQueueList);
- for (QueueList queueEntry : queueList) {
- Assert.assertTrue(isQueueInList(operQueueList, queueEntry));
+ assertNotNull(operQos);
+ Map<QueueListKey, QueueList> operQueueList = operQos.getQueueList();
+ assertNotNull(operQueueList);
+ for (QueueList queueEntry : queueList.values()) {
+ assertTrue(isQueueInList(operQueueList, queueEntry));
}
// DELETE one queue from queue list and check that one remains
KeyedInstanceIdentifier<QueueList, QueueListKey> qosQueueIid = qosIid
- .child(QueueList.class, new QueueListKey(new Long("1")));
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qosQueueIid));
+ .child(QueueList.class, new QueueListKey(Uint32.ONE));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qosQueueIid));
qosOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
// READ: Read the test qos and ensure changes are propagated to the OPERATIONAL data store
ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
operQos = getQos(new Uri(testQosId), ovsdbNodeAugmentation);
- Assert.assertNotNull(operQos);
+ assertNotNull(operQos);
operQueueList = operQos.getQueueList();
- Assert.assertNotNull(operQueueList);
+ assertNotNull(operQueueList);
- for (QueueList queueEntry : queueList) {
+ for (QueueList queueEntry : queueList.values()) {
if (queueEntry.getQueueRef().equals(queue2Ref)) {
- Assert.assertTrue(isQueueInList(operQueueList, queueEntry));
+ assertTrue(isQueueInList(operQueueList, queueEntry));
} else if (queueEntry.getQueueRef().equals(queue1Ref)) {
- Assert.assertFalse(isQueueInList(operQueueList, queueEntry));
+ assertFalse(isQueueInList(operQueueList, queueEntry));
} else {
- Assert.assertTrue("Unknown queue entry in qos queue list", false);
+ assertTrue("Unknown queue entry in qos queue list", false);
}
}
// DELETE queue list and check that list is empty
qosQueueIid = qosIid
- .child(QueueList.class, new QueueListKey(new Long("1")));
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qosQueueIid));
+ .child(QueueList.class, new QueueListKey(Uint32.ONE));
+ assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qosQueueIid));
qosOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
operQos = getQos(new Uri(testQosId), ovsdbNodeAugmentation);
- Assert.assertNotNull(operQos);
+ assertNotNull(operQos);
operQueueList = operQos.getQueueList();
- Assert.assertNotNull(operQueueList);
- Assert.assertTrue(operQueueList.isEmpty());
+ assertNotNull(operQueueList);
+ assertTrue(operQueueList.isEmpty());
}
}
- private Boolean isQueueInList(List<QueueList> queueList, QueueList queue) {
- for (QueueList queueEntry : queueList) {
+ private static Boolean isQueueInList(final Map<QueueListKey, QueueList> queueList, final QueueList queue) {
+ for (QueueList queueEntry : queueList.values()) {
if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())
&& queueEntry.getQueueRef().equals(queue.getQueueRef())) {
return true;
*
* @param <T> The type of data used for the test case.
*/
- private static final class SouthboundTestCase<T> {
+ private static final class SouthboundTestCase<I extends Identifier<T>, T extends Identifiable<I>> {
private final String name;
- private final List<T> inputValues;
- private final List<T> expectedValues;
+ private final Map<I, T> inputValues;
+ private final Map<I, T> expectedValues;
/**
* Creates an instance of a southbound test case.
*/
SouthboundTestCase(final String name, final List<T> inputValues, final List<T> expectedValues) {
this.name = name;
- this.inputValues = inputValues;
- this.expectedValues = expectedValues;
+ this.inputValues = BindingMap.ordered(inputValues);
+ this.expectedValues = BindingMap.of(expectedValues);
}
}
*
* @param <T> The type of data used for the test case.
*/
- private static final class SouthboundTestCaseBuilder<T> {
+ private static final class SouthboundTestCaseBuilder<I extends Identifier<T>, T extends Identifiable<I>> {
private String name;
private List<T> inputValues;
private List<T> expectedValues;
* @param value The test case's name.
* @return The builder.
*/
- public SouthboundTestCaseBuilder<T> name(final String value) {
+ public SouthboundTestCaseBuilder<I, T> name(final String value) {
this.name = value;
return this;
}
* @return The builder.
*/
@SafeVarargs
- public final SouthboundTestCaseBuilder<T> input(final T... values) {
+ public final SouthboundTestCaseBuilder<I, T> input(final T... values) {
this.inputValues = Lists.newArrayList(values);
return this;
}
*
* @return The builder.
*/
- public SouthboundTestCaseBuilder<T> expectInputAsOutput() {
+ public SouthboundTestCaseBuilder<I, T> expectInputAsOutput() {
this.expectedValues = this.inputValues;
return this;
}
*
* @return The builder.
*/
- public SouthboundTestCaseBuilder<T> expectNoOutput() {
+ public SouthboundTestCaseBuilder<I, T> expectNoOutput() {
this.expectedValues = null;
return this;
}
*
* @return The test case.
*/
- public SouthboundTestCase<T> build() {
+ public SouthboundTestCase<I, T> build() {
return new SouthboundTestCase<>(name, inputValues, expectedValues);
}
}
}
@Override
- protected void setKey(Builder<QueuesExternalIds> builder, String key) {
+ protected void setKey(final Builder<QueuesExternalIds> builder, final String key) {
((QueuesExternalIdsBuilder) builder).setQueuesExternalIdKey(key);
}
@Override
- protected void setValue(Builder<QueuesExternalIds> builder, String value) {
+ protected void setValue(final Builder<QueuesExternalIds> builder, final String value) {
((QueuesExternalIdsBuilder) builder).setQueuesExternalIdValue(value);
}
}
@Override
- protected void setKey(Builder<QueuesOtherConfig> builder, String key) {
+ protected void setKey(final Builder<QueuesOtherConfig> builder, final String key) {
((QueuesOtherConfigBuilder) builder).setQueueOtherConfigKey(key);
}
@Override
- protected void setValue(Builder<QueuesOtherConfig> builder, String value) {
+ protected void setValue(final Builder<QueuesOtherConfig> builder, final String value) {
((QueuesOtherConfigBuilder) builder).setQueueOtherConfigValue(value);
}
}
@Override
- protected void setKey(Builder<QosExternalIds> builder, String key) {
+ protected void setKey(final Builder<QosExternalIds> builder, final String key) {
((QosExternalIdsBuilder) builder).setQosExternalIdKey(key);
}
@Override
- protected void setValue(Builder<QosExternalIds> builder, String value) {
+ protected void setValue(final Builder<QosExternalIds> builder, final String value) {
((QosExternalIdsBuilder) builder).setQosExternalIdValue(value);
}
}
@Override
- protected void setKey(Builder<QosOtherConfig> builder, String key) {
+ protected void setKey(final Builder<QosOtherConfig> builder, final String key) {
((QosOtherConfigBuilder) builder).setOtherConfigKey(key);
}
@Override
- protected void setValue(Builder<QosOtherConfig> builder, String value) {
+ protected void setValue(final Builder<QosOtherConfig> builder, final String value) {
((QosOtherConfigBuilder) builder).setOtherConfigValue(value);
}
}
@Override
- protected void setKey(Builder<PortExternalIds> builder, String key) {
+ protected void setKey(final Builder<PortExternalIds> builder, final String key) {
((PortExternalIdsBuilder) builder).setExternalIdKey(key);
}
@Override
- protected void setValue(Builder<PortExternalIds> builder, String value) {
+ protected void setValue(final Builder<PortExternalIds> builder, final String value) {
((PortExternalIdsBuilder) builder).setExternalIdValue(value);
}
}
@Override
- protected void setKey(Builder<InterfaceExternalIds> builder, String key) {
+ protected void setKey(final Builder<InterfaceExternalIds> builder, final String key) {
((InterfaceExternalIdsBuilder) builder).setExternalIdKey(key);
}
@Override
- protected void setValue(Builder<InterfaceExternalIds> builder, String value) {
+ protected void setValue(final Builder<InterfaceExternalIds> builder, final String value) {
((InterfaceExternalIdsBuilder) builder).setExternalIdValue(value);
}
}
@Override
- protected void setKey(Builder<InterfaceLldp> builder, String key) {
+ protected void setKey(final Builder<InterfaceLldp> builder, final String key) {
((InterfaceLldpBuilder) builder).setLldpKey(key);
}
@Override
- protected void setValue(Builder<InterfaceLldp> builder, String value) {
+ protected void setValue(final Builder<InterfaceLldp> builder, final String value) {
((InterfaceLldpBuilder) builder).setLldpValue(value);
}
}
@Override
- protected void setKey(Builder<Options> builder, String key) {
+ protected void setKey(final Builder<Options> builder, final String key) {
((OptionsBuilder) builder).setOption(key);
}
@Override
- protected void setValue(Builder<Options> builder, String value) {
+ protected void setValue(final Builder<Options> builder, final String value) {
((OptionsBuilder) builder).setValue(value);
}
}
@Override
- protected void setKey(Builder<InterfaceOtherConfigs> builder, String key) {
+ protected void setKey(final Builder<InterfaceOtherConfigs> builder, final String key) {
((InterfaceOtherConfigsBuilder) builder).setOtherConfigKey(key);
}
@Override
- protected void setValue(Builder<InterfaceOtherConfigs> builder, String value) {
+ protected void setValue(final Builder<InterfaceOtherConfigs> builder, final String value) {
((InterfaceOtherConfigsBuilder) builder).setOtherConfigValue(value);
}
}
@Override
- protected void setKey(Builder<PortOtherConfigs> builder, String key) {
+ protected void setKey(final Builder<PortOtherConfigs> builder, final String key) {
((PortOtherConfigsBuilder) builder).setOtherConfigKey(key);
}
@Override
- protected void setValue(Builder<PortOtherConfigs> builder, String value) {
+ protected void setValue(final Builder<PortOtherConfigs> builder, final String value) {
((PortOtherConfigsBuilder) builder).setOtherConfigValue(value);
}
}
@Override
- protected void setKey(Builder<BridgeOtherConfigs> builder, String key) {
+ protected void setKey(final Builder<BridgeOtherConfigs> builder, final String key) {
((BridgeOtherConfigsBuilder) builder).setBridgeOtherConfigKey(key);
}
@Override
- protected void setValue(Builder<BridgeOtherConfigs> builder, String value) {
+ protected void setValue(final Builder<BridgeOtherConfigs> builder, final String value) {
((BridgeOtherConfigsBuilder) builder).setBridgeOtherConfigValue(value);
}
}
@Override
- protected void setKey(Builder<BridgeExternalIds> builder, String key) {
+ protected void setKey(final Builder<BridgeExternalIds> builder, final String key) {
((BridgeExternalIdsBuilder) builder).setBridgeExternalIdKey(key);
}
@Override
- protected void setValue(Builder<BridgeExternalIds> builder, String value) {
+ protected void setValue(final Builder<BridgeExternalIds> builder, final String value) {
((BridgeExternalIdsBuilder) builder).setBridgeExternalIdValue(value);
}
* Generates the test cases involved in testing key-value-based data. See inline comments for descriptions of
* the particular cases considered.
*/
- private static <T> List<SouthboundTestCase<T>> generateKeyValueTestCases(
- KeyValueBuilder<T> builder, String testName) {
- List<SouthboundTestCase<T>> testCases = new ArrayList<>();
+ private static <I extends Identifier<T>, T extends Identifiable<I>> List<SouthboundTestCase<I, T>>
+ generateKeyValueTestCases(final KeyValueBuilder<T> builder, final String testName) {
+ List<SouthboundTestCase<I, T>> testCases = new ArrayList<>();
final String goodKey = "GoodKey";
final String goodValue = "GoodValue";
// Description: Create a termination point with one value
// Expected: A port is created with the single value specified below
final String testOneName = "TestOne" + testName;
- testCases.add(new SouthboundTestCaseBuilder<T>()
+ testCases.add(new SouthboundTestCaseBuilder<I, T>()
.name(testOneName)
.input(builder.build(testOneName, idKey, idValue))
.expectInputAsOutput()
// Description: Create a termination point with multiple (five) values
// Expected: A port is created with the five values specified below
final String testFiveName = "TestFive" + testName;
- testCases.add(new SouthboundTestCaseBuilder<T>()
+ testCases.add(new SouthboundTestCaseBuilder<I, T>()
.name(testFiveName)
.input(
builder.build(testFiveName, idKey, idValue),
// UNSPECIFIED)
// Expected: A port is created without any values
final String testOneGoodOneMalformedValueName = "TestOneGoodOneMalformedValue" + testName;
- testCases.add(new SouthboundTestCaseBuilder<T>()
+ testCases.add(new SouthboundTestCaseBuilder<I, T>()
.name(testOneGoodOneMalformedValueName)
.input(
builder.build(testOneGoodOneMalformedValueName, goodKey, goodValue),
return testCases;
}
- private static class PortExternalIdsSouthboundHelper implements SouthboundTerminationPointHelper<PortExternalIds> {
+ private static class PortExternalIdsSouthboundHelper
+ implements SouthboundTerminationPointHelper<PortExternalIdsKey, PortExternalIds> {
@Override
- public void writeValues(OvsdbTerminationPointAugmentationBuilder builder, List<PortExternalIds> values) {
+ public void writeValues(final OvsdbTerminationPointAugmentationBuilder builder,
+ final Map<PortExternalIdsKey, PortExternalIds> values) {
builder.setPortExternalIds(values);
}
@Override
- public List<PortExternalIds> readValues(OvsdbTerminationPointAugmentation augmentation) {
+ public Map<PortExternalIdsKey, PortExternalIds> readValues(
+ final OvsdbTerminationPointAugmentation augmentation) {
return augmentation.getPortExternalIds();
}
}
- private static class InterfaceExternalIdsSouthboundHelper implements
- SouthboundTerminationPointHelper<InterfaceExternalIds> {
+ private static class InterfaceExternalIdsSouthboundHelper
+ implements SouthboundTerminationPointHelper<InterfaceExternalIdsKey, InterfaceExternalIds> {
@Override
- public void writeValues(
- OvsdbTerminationPointAugmentationBuilder builder, List<InterfaceExternalIds> values) {
+ public void writeValues(final OvsdbTerminationPointAugmentationBuilder builder,
+ final Map<InterfaceExternalIdsKey, InterfaceExternalIds> values) {
builder.setInterfaceExternalIds(values);
}
@Override
- public List<InterfaceExternalIds> readValues(OvsdbTerminationPointAugmentation augmentation) {
+ public Map<InterfaceExternalIdsKey, InterfaceExternalIds> readValues(
+ final OvsdbTerminationPointAugmentation augmentation) {
return augmentation.getInterfaceExternalIds();
}
}
- private static class InterfaceLldpSouthboundHelper implements SouthboundTerminationPointHelper<InterfaceLldp> {
+ private static class InterfaceLldpSouthboundHelper
+ implements SouthboundTerminationPointHelper<InterfaceLldpKey, InterfaceLldp> {
@Override
- public void writeValues(
- OvsdbTerminationPointAugmentationBuilder builder, List<InterfaceLldp> values) {
+ public void writeValues(final OvsdbTerminationPointAugmentationBuilder builder,
+ final Map<InterfaceLldpKey, InterfaceLldp> values) {
builder.setInterfaceLldp(values);
}
@Override
- public List<InterfaceLldp> readValues(OvsdbTerminationPointAugmentation augmentation) {
+ public Map<InterfaceLldpKey, InterfaceLldp> readValues(final OvsdbTerminationPointAugmentation augmentation) {
return augmentation.getInterfaceLldp();
}
}
- private static class OptionsSouthboundHelper implements SouthboundTerminationPointHelper<Options> {
+ private static class OptionsSouthboundHelper implements SouthboundTerminationPointHelper<OptionsKey, Options> {
@Override
- public void writeValues(
- OvsdbTerminationPointAugmentationBuilder builder, List<Options> values) {
+ public void writeValues(final OvsdbTerminationPointAugmentationBuilder builder,
+ final Map<OptionsKey, Options> values) {
builder.setOptions(values);
}
@Override
- public List<Options> readValues(OvsdbTerminationPointAugmentation augmentation) {
+ public Map<OptionsKey, Options> readValues(final OvsdbTerminationPointAugmentation augmentation) {
return augmentation.getOptions();
}
}
- private static class InterfaceOtherConfigsSouthboundHelper implements
- SouthboundTerminationPointHelper<InterfaceOtherConfigs> {
+ private static class InterfaceOtherConfigsSouthboundHelper
+ implements SouthboundTerminationPointHelper<InterfaceOtherConfigsKey, InterfaceOtherConfigs> {
@Override
- public void writeValues(
- OvsdbTerminationPointAugmentationBuilder builder, List<InterfaceOtherConfigs> values) {
+ public void writeValues(final OvsdbTerminationPointAugmentationBuilder builder,
+ final Map<InterfaceOtherConfigsKey, InterfaceOtherConfigs> values) {
builder.setInterfaceOtherConfigs(values);
}
@Override
- public List<InterfaceOtherConfigs> readValues(OvsdbTerminationPointAugmentation augmentation) {
+ public Map<InterfaceOtherConfigsKey, InterfaceOtherConfigs> readValues(
+ final OvsdbTerminationPointAugmentation augmentation) {
return augmentation.getInterfaceOtherConfigs();
}
}
private static class PortOtherConfigsSouthboundHelper implements
- SouthboundTerminationPointHelper<PortOtherConfigs> {
+ SouthboundTerminationPointHelper<PortOtherConfigsKey, PortOtherConfigs> {
@Override
- public void writeValues(
- OvsdbTerminationPointAugmentationBuilder builder, List<PortOtherConfigs> values) {
+ public void writeValues(final OvsdbTerminationPointAugmentationBuilder builder,
+ final Map<PortOtherConfigsKey, PortOtherConfigs> values) {
builder.setPortOtherConfigs(values);
}
@Override
- public List<PortOtherConfigs> readValues(OvsdbTerminationPointAugmentation augmentation) {
+ public Map<PortOtherConfigsKey, PortOtherConfigs> readValues(
+ final OvsdbTerminationPointAugmentation augmentation) {
return augmentation.getPortOtherConfigs();
}
}
- private static class BridgeExternalIdsSouthboundHelper implements SouthboundBridgeHelper<BridgeExternalIds> {
+ private static class BridgeExternalIdsSouthboundHelper
+ implements SouthboundBridgeHelper<BridgeExternalIdsKey, BridgeExternalIds> {
@Override
- public void writeValues(
- OvsdbBridgeAugmentationBuilder builder, List<BridgeExternalIds> values) {
+ public void writeValues(final OvsdbBridgeAugmentationBuilder builder,
+ final Map<BridgeExternalIdsKey, BridgeExternalIds> values) {
builder.setBridgeExternalIds(values);
}
@Override
- public List<BridgeExternalIds> readValues(OvsdbBridgeAugmentation augmentation) {
+ public Map<BridgeExternalIdsKey, BridgeExternalIds> readValues(final OvsdbBridgeAugmentation augmentation) {
return augmentation.getBridgeExternalIds();
}
}
- private static class BridgeOtherConfigsSouthboundHelper implements SouthboundBridgeHelper<BridgeOtherConfigs> {
+ private static class BridgeOtherConfigsSouthboundHelper
+ implements SouthboundBridgeHelper<BridgeOtherConfigsKey, BridgeOtherConfigs> {
@Override
- public void writeValues(
- OvsdbBridgeAugmentationBuilder builder, List<BridgeOtherConfigs> values) {
+ public void writeValues(final OvsdbBridgeAugmentationBuilder builder,
+ final Map<BridgeOtherConfigsKey, BridgeOtherConfigs> values) {
builder.setBridgeOtherConfigs(values);
}
@Override
- public List<BridgeOtherConfigs> readValues(OvsdbBridgeAugmentation augmentation) {
+ public Map<BridgeOtherConfigsKey, BridgeOtherConfigs> readValues(final OvsdbBridgeAugmentation augmentation) {
return augmentation.getBridgeOtherConfigs();
}
}