/*
- * Copyright (c) 2015 Red Hat, Inc. and others. All rights reserved.
+ * Copyright © 2015, 2017 Red Hat, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
import org.opendaylight.ovsdb.lib.notation.Version;
+import org.opendaylight.ovsdb.schema.openvswitch.Queue;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.ovsdb.southbound.SouthboundUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbQueueRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
private static final NotifyingDataChangeListener OPERATIONAL_LISTENER =
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL);
+
private static class NotifyingDataChangeListener implements DataChangeListener {
private final LogicalDatastoreType type;
private final Set<InstanceIdentifier<?>> createdIids = new HashSet<>();
synchronized (this) {
long _start = System.currentTimeMillis();
LOG.info("Waiting for {} DataChanged creation on {}", type, iid);
- while (!isCreated(iid) && System.currentTimeMillis() - _start < timeout) {
+ while (!isCreated(iid) && (System.currentTimeMillis() - _start) < timeout) {
wait(RETRY_WAIT);
}
- LOG.info("Woke up, waited {}ms for creation of {}", System.currentTimeMillis() - _start, iid);
+ LOG.info("Woke up, waited {}ms for creation of {}", (System.currentTimeMillis() - _start), iid);
}
}
synchronized (this) {
long _start = System.currentTimeMillis();
LOG.info("Waiting for {} DataChanged deletion on {}", type, iid);
- while (!isRemoved(iid) && System.currentTimeMillis() - _start < timeout) {
+ while (!isRemoved(iid) && (System.currentTimeMillis() - _start) < timeout) {
wait(RETRY_WAIT);
}
- LOG.info("Woke up, waited {}ms for deletion of {}", System.currentTimeMillis() - _start, iid);
+ LOG.info("Woke up, waited {}ms for deletion of {}", (System.currentTimeMillis() - _start), iid);
}
}
synchronized (this) {
long _start = System.currentTimeMillis();
LOG.info("Waiting for {} DataChanged update on {}", type, iid);
- while (!isUpdated(iid) && System.currentTimeMillis() - _start < timeout) {
+ while (!isUpdated(iid) && (System.currentTimeMillis() - _start) < timeout) {
wait(RETRY_WAIT);
}
- LOG.info("Woke up, waited {}ms for update of {}", System.currentTimeMillis() - _start, iid);
+ LOG.info("Woke up, waited {}ms for update of {}", (System.currentTimeMillis() - _start), iid);
}
}
}
- @Override
@Configuration
public Option[] config() {
Option[] options = super.config();
long _start = System.currentTimeMillis();
LOG.info("Waiting for OPERATIONAL DataChanged creation on {}", iid);
while (!OPERATIONAL_LISTENER.isCreated(
- iid) && System.currentTimeMillis() - _start < OVSDB_ROUNDTRIP_TIMEOUT) {
+ iid) && (System.currentTimeMillis() - _start) < OVSDB_ROUNDTRIP_TIMEOUT) {
OPERATIONAL_LISTENER.wait(OVSDB_UPDATE_TIMEOUT);
}
- LOG.info("Woke up, waited {} for creation of {}", System.currentTimeMillis() - _start, iid);
+ LOG.info("Woke up, waited {} for creation of {}", (System.currentTimeMillis() - _start), iid);
}
}
long _start = System.currentTimeMillis();
LOG.info("Waiting for OPERATIONAL DataChanged deletion on {}", iid);
while (!OPERATIONAL_LISTENER.isRemoved(
- iid) && System.currentTimeMillis() - _start < OVSDB_ROUNDTRIP_TIMEOUT) {
+ iid) && (System.currentTimeMillis() - _start) < OVSDB_ROUNDTRIP_TIMEOUT) {
OPERATIONAL_LISTENER.wait(OVSDB_UPDATE_TIMEOUT);
}
- LOG.info("Woke up, waited {} for deletion of {}", System.currentTimeMillis() - _start, iid);
+ LOG.info("Woke up, waited {} for deletion of {}", (System.currentTimeMillis() - _start), iid);
}
}
long _start = System.currentTimeMillis();
LOG.info("Waiting for OPERATIONAL DataChanged update on {}", iid);
while (!OPERATIONAL_LISTENER.isUpdated(
- iid) && System.currentTimeMillis() - _start < OVSDB_ROUNDTRIP_TIMEOUT) {
+ iid) && (System.currentTimeMillis() - _start) < OVSDB_ROUNDTRIP_TIMEOUT) {
OPERATIONAL_LISTENER.wait(OVSDB_UPDATE_TIMEOUT);
}
- LOG.info("Woke up, waited {} for update of {}", System.currentTimeMillis() - _start, iid);
+ LOG.info("Woke up, waited {} for update of {}", (System.currentTimeMillis() - _start), iid);
}
}
entry.addAugmentation(
OvsdbTerminationPointAugmentation.class,
ovsdbTerminationPointAugmentationBuilder.build());
- portNodeBuilder.setTerminationPoint(Lists.newArrayList(entry.build()));
+ portNodeBuilder.setTerminationPoint(Collections.singletonList(entry.build()));
boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
portIid, portNodeBuilder.build());
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
final boolean isOldSchema = schemaVersion.compareTo(AUTOATTACH_FROM_VERSION) < 0;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
- String testAutoattachId = new String("testAutoattachEntry");
- String testSystemName = new String("testSystemName");
- String testSystemDescription = new String("testSystemDescription");
- String testAutoattachExternalKey = new String("testAutoattachExternalKey");
- String testAutoattachExternalValue = new String("testAutoattachExternalValue");
+ String testAutoattachId = "testAutoattachEntry";
+ String testSystemName = "testSystemName";
+ String testSystemDescription = "testSystemDescription";
+ String testAutoattachExternalKey = "testAutoattachExternalKey";
+ String testAutoattachExternalValue = "testAutoattachExternalValue";
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
private static class TestQueue implements AutoCloseable {
private final ConnectionInfo connectionInfo;
private final Uri queueId;
+ private final InstanceIdentifier<Queues> qIid;
/**
* Creates a test queue entry which can be automatically removed when no longer necessary.
.setQueuesExternalIds(externalIds)
.setQueuesOtherConfig(otherConfigs)
.build();
- InstanceIdentifier<Queues> qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
+ qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
.augmentation(OvsdbNodeAugmentation.class)
.child(Queues.class, queue.getKey());
final NotifyingDataChangeListener queueOperationalListener =
}
}
+ public InstanceIdentifier<Queues> getInstanceIdentifier() {
+ return qIid;
+ }
@Override
public void close() {
InstanceIdentifier<Queues> qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
tpUpdateBuilder.addAugmentation(
OvsdbTerminationPointAugmentation.class,
tpUpdateAugmentationBuilder.build());
- portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
OvsdbTerminationPointAugmentation.class,
tpUpdateAugmentationBuilder.build());
tpUpdateBuilder.setTpId(new TpId(portName));
- portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
Assert.assertTrue(
mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
OvsdbTerminationPointAugmentation.class,
tpUpdateAugmentationBuilder.build());
tpUpdateBuilder.setTpId(new TpId(portName));
- portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
Assert.assertTrue(
mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
int max = 4095;
return Lists.newArrayList(
Collections.<Integer>emptySet(),
- Sets.newHashSet(2222),
+ Collections.singleton(2222),
Sets.newHashSet(min, max, min + 1, max - 1, (max - min) / 2));
}
private List<Trunks> buildTrunkList(Set<Integer> trunkSet) {
- List<Trunks> trunkList = Lists.newArrayList();
+ List<Trunks> trunkList = new ArrayList<>();
for (Integer trunk : trunkSet) {
TrunksBuilder trunkBuilder = new TrunksBuilder();
trunkBuilder.setTrunk(new VlanId(trunk));
@Test
public void testCRUDTerminationPointVlanTrunks() throws InterruptedException {
- final List<Trunks> UPDATED_TRUNKS = buildTrunkList(Sets.newHashSet(2011));
+ final List<Trunks> UPDATED_TRUNKS = buildTrunkList(Collections.singleton(2011));
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
Iterable<Set<Integer>> vlanSets = generateVlanSets();
int testCase = 0;
OvsdbTerminationPointAugmentation.class,
tpUpdateAugmentationBuilder.build());
tpUpdateBuilder.setTpId(new TpId(portName));
- portUpdateNodeBuilder.setTerminationPoint(Lists.newArrayList(tpUpdateBuilder.build()));
+ portUpdateNodeBuilder.setTerminationPoint(Collections.singletonList(tpUpdateBuilder.build()));
Assert.assertTrue(
mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, portIid, portUpdateNodeBuilder.build()));
Thread.sleep(OVSDB_UPDATE_TIMEOUT);
@Test
public void testCRUDTerminationPointQos() throws InterruptedException {
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
- String testQosId = new String("testQosEntry");
+ String testQosId = "testQosEntry";
// CREATE
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME);
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testTerminationPointQos";
ovsdbTerminationBuilder.setName(portName);
- ovsdbTerminationBuilder.setQos(qosUuid);
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
- // READ and check that qos uuid has been added to the port
+
+ // 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);
- OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation =
- terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
- Assert.assertEquals(ovsdbTerminationPointAugmentation.getQos(), qosUuid);
// UPDATE - remove the qos entry from the port
OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
// READ and verify that qos uuid has been removed from port
TerminationPoint terminationPointUpdate = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, tpEntryIid);
Assert.assertNotNull(terminationPointUpdate);
- OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentationUpdate =
- terminationPointUpdate.getAugmentation(OvsdbTerminationPointAugmentation.class);
- Assert.assertNull(ovsdbTerminationPointAugmentationUpdate.getQos());
// DELETE handled by TestBridge
}
private Queues getQueue(Uri queueId, OvsdbNodeAugmentation node) {
for (Queues queue : node.getQueues()) {
- if (queue.getKey().getQueueId().getValue().equals(queueId.getValue())) {
+ if (queue.getKey().getQueueId().getValue().equals(queueId.getValue()))
return queue;
- }
}
return null;
}
private QosEntries getQos(Uri qosId, OvsdbNodeAugmentation node) {
for (QosEntries qos : node.getQosEntries()) {
- if (qos.getKey().getQosId().equals(qosId)) {
+ if (qos.getKey().getQosId().equals(qosId))
return qos;
- }
}
return null;
}
// configuration of the Qos row.
OvsdbNodeAugmentation ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
+
Queues operQueue1 = getQueue(new Uri("queue1"), ovsdbNodeAugmentation);
+
Assert.assertNotNull(operQueue1);
- Uuid queue1Uuid = new Uuid(operQueue1.getQueueUuid().getValue());
+
+ InstanceIdentifier<Queues> queue1Iid = testQueue1.getInstanceIdentifier();
+ OvsdbQueueRef queue1Ref = new OvsdbQueueRef(queue1Iid);
+
Queues operQueue2 = getQueue(new Uri("queue2"), ovsdbNodeAugmentation);
Assert.assertNotNull(operQueue2);
- Uuid queue2Uuid = new Uuid(operQueue2.getQueueUuid().getValue());
+ InstanceIdentifier<Queues> queue2Iid = testQueue2.getInstanceIdentifier();
+ OvsdbQueueRef queue2Ref = new OvsdbQueueRef(queue2Iid);
List<QueueList> queueList = new ArrayList<>();
- queueList.add(new QueueListBuilder().setQueueNumber(new Long("0"))
- .setQueueUuid(queue1Uuid).build());
- queueList.add(new QueueListBuilder().setQueueNumber(new Long("1"))
- .setQueueUuid(queue2Uuid).build());
+ queueList.add(new QueueListBuilder().setQueueNumber(new Long("1")).setQueueRef(queue1Ref).build());
+ queueList.add(new QueueListBuilder().setQueueNumber(new Long("2")).setQueueRef(queue2Ref).build());
+
qosBuilder.setQueueList(queueList);
Assert.assertTrue(mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
// DELETE one queue from queue list and check that one remains
KeyedInstanceIdentifier<QueueList, QueueListKey> qosQueueIid = qosIid
- .child(QueueList.class, new QueueListKey(new Long("0")));
+ .child(QueueList.class, new QueueListKey(new Long("1")));
Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qosQueueIid));
qosOperationalListener.waitForUpdate(OVSDB_UPDATE_TIMEOUT);
Assert.assertNotNull(operQos);
operQueueList = operQos.getQueueList();
Assert.assertNotNull(operQueueList);
+
for (QueueList queueEntry : queueList) {
- if (queueEntry.getQueueUuid().equals(queue2Uuid)) {
+ if (queueEntry.getQueueRef().equals(queue2Ref)) {
Assert.assertTrue(isQueueInList(operQueueList, queueEntry));
- } else if (queueEntry.getQueueUuid().equals(queue1Uuid)) {
+ } else if (queueEntry.getQueueRef().equals(queue1Ref)) {
Assert.assertFalse(isQueueInList(operQueueList, queueEntry));
} else {
Assert.assertTrue("Unknown queue entry in qos queue list", false);
}
}
+
+
private Boolean isQueueInList(List<QueueList> queueList, QueueList queue) {
for (QueueList queueEntry : queueList) {
- if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())
- && queueEntry.getQueueUuid().equals(queue.getQueueUuid())) {
+ if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())&& queueEntry.getQueueRef().equals(queue.getQueueRef())) {
return true;
}
}
@Override
protected void setKey(Builder<InterfaceLldp> builder, String key) {
- ((InterfaceLldpBuilder) builder).setLldpKey(key);
+ ((InterfaceLldpBuilder) builder).setLldpKey((key));
}
@Override