<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
//Constants
- public static final String ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg";
public static final String CUSTOM_PROPERTIES = "etc/custom.properties";
public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
public static final String DEFAULT_SERVER_IPADDRESS = "127.0.0.1";
private static int portNumber;
private static String connectionType;
private static Node hwvtepNode;
- @Inject @Filter(timeout=60000)
+ @Inject @Filter(timeout = 60000)
private static DataBroker dataBroker = null;
@Inject
private BundleContext bundleContext;
private static final NotifyingDataChangeListener OPERATIONAL_LISTENER =
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL);
- private static class NotifyingDataChangeListener implements DataTreeChangeListener<Node> {
+ private static final class NotifyingDataChangeListener implements DataTreeChangeListener<Node> {
private final LogicalDatastoreType type;
private final Set<InstanceIdentifier<Node>> createdNodes = new HashSet<>();
private final Set<InstanceIdentifier<Node>> removedNodes = new HashSet<>();
for (DataTreeModification<Node> change : changes) {
final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
final DataObjectModification<Node> mod = change.getRootNode();
- switch (mod.getModificationType()) {
+ switch (mod.getModificationType()) {
case DELETE:
removedNodes.add(key);
break;
break;
default:
throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
- }
+ }
}
}
private Option[] getPropertiesOptions() {
Properties props = new Properties(System.getProperties());
- String addressStr = props.getProperty(SERVER_IPADDRESS, DEFAULT_SERVER_IPADDRESS);
+ String ipAddressStr = props.getProperty(SERVER_IPADDRESS, DEFAULT_SERVER_IPADDRESS);
String portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT);
- String connectionType = props.getProperty(CONNECTION_TYPE, CONNECTION_TYPE_ACTIVE);
+ String connectionTypeStr = props.getProperty(CONNECTION_TYPE, CONNECTION_TYPE_ACTIVE);
LOG.info("getPropertiesOptions: Using the following properties: mode= {}, ip:port= {}:{}",
- connectionType, addressStr, portStr);
+ connectionTypeStr, ipAddressStr, portStr);
return new Option[] {
- editConfigurationFilePut(CUSTOM_PROPERTIES, SERVER_IPADDRESS, addressStr),
+ editConfigurationFilePut(CUSTOM_PROPERTIES, SERVER_IPADDRESS, ipAddressStr),
editConfigurationFilePut(CUSTOM_PROPERTIES, SERVER_PORT, portStr),
- editConfigurationFilePut(CUSTOM_PROPERTIES, CONNECTION_TYPE, connectionType),
+ editConfigurationFilePut(CUSTOM_PROPERTIES, CONNECTION_TYPE, connectionTypeStr),
};
}
@Before
@Override
- public void setup() throws InterruptedException {
+ public void setup() throws Exception {
if (setup) {
LOG.info("Skipping setup, already initialized");
return;
}
- try {
- super.setup();
- } catch (Exception e) {
- LOG.warn("Failed to setup test", e);
- fail("Failed to setup test: " + e);
- }
+ super.setup();
addressStr = bundleContext.getProperty(SERVER_IPADDRESS);
String portStr = bundleContext.getProperty(SERVER_PORT);
private void waitForOperationalCreation(InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
private static void waitForOperationalDeletion(InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
- private ConnectionInfo getConnectionInfo(String addressStr, int portNumber) {
+ private ConnectionInfo getConnectionInfo(String ipAddressStr, int portNum) {
InetAddress inetAddress = null;
try {
- inetAddress = InetAddress.getByName(addressStr);
+ inetAddress = InetAddress.getByName(ipAddressStr);
} catch (UnknownHostException e) {
- fail("Could not resolve " + addressStr + ": " + e);
+ fail("Could not resolve " + ipAddressStr + ": " + e);
}
IpAddress address = HwvtepSouthboundMapper.createIpAddress(inetAddress);
- PortNumber port = new PortNumber(portNumber);
+ PortNumber port = new PortNumber(portNum);
final ConnectionInfo connectionInfo = new ConnectionInfoBuilder()
.setRemoteIp(address)
private final String psName;
- public TestPhysicalSwitch(final ConnectionInfo connectionInfo, String psName) {
+ TestPhysicalSwitch(final ConnectionInfo connectionInfo, String psName) {
this(connectionInfo, psName, null, null, null, true, null, null, null);
}
- public TestPhysicalSwitch (final ConnectionInfo connectionInfo, final String name,
+ TestPhysicalSwitch(final ConnectionInfo connectionInfo, final String name,
@Nullable InstanceIdentifier<Node> psIid, @Nullable NodeId psNodeId,
@Nullable final String description, final boolean setManagedBy,
@Nullable final List<ManagementIps> managementIps,
this.connectionInfo = connectionInfo;
this.psName = name;
NodeBuilder psNodeBuilder = new NodeBuilder();
- if(psIid == null) {
+ if (psIid == null) {
psIid = HwvtepSouthboundUtils.createInstanceIdentifier(connectionInfo, new HwvtepNodeName(psName));
}
- if(psNodeId == null) {
+ if (psNodeId == null) {
psNodeId = HwvtepSouthboundMapper.createManagedNodeId(psIid);
}
psNodeBuilder.setNodeId(psNodeId);
PhysicalSwitchAugmentationBuilder psAugBuilder = new PhysicalSwitchAugmentationBuilder();
psAugBuilder.setHwvtepNodeName(new HwvtepNodeName(psName));
- if(description != null) {
+ if (description != null) {
psAugBuilder.setHwvtepNodeDescription(description);
}
- if(setManagedBy) {
+ if (setManagedBy) {
InstanceIdentifier<Node> nodePath = HwvtepSouthboundUtils.createInstanceIdentifier(connectionInfo);
psAugBuilder.setManagedBy(new HwvtepGlobalRef(nodePath));
}
psNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, psAugBuilder.build());
LOG.debug("Built with intent to store PhysicalSwitch data {}", psAugBuilder.toString());
Assert.assertTrue(
- mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, psIid, psNodeBuilder.build()));
- try {
- Thread.sleep(OVSDB_UPDATE_TIMEOUT);
- } catch (InterruptedException e) {
- LOG.warn("Sleep interrupted while waiting for bridge creation (bridge {})", psName, e);
- }
+ mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, psIid, psNodeBuilder.build()));
+ try {
+ Thread.sleep(OVSDB_UPDATE_TIMEOUT);
+ } catch (InterruptedException e) {
+ LOG.warn("Sleep interrupted while waiting for bridge creation (bridge {})", psName, e);
+ }
}
@Override
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
try (TestPhysicalSwitch testPSwitch = new TestPhysicalSwitch(connectionInfo, PS_NAME)) {
- PhysicalSwitchAugmentation pSwitch = getPhysicalSwitch(connectionInfo);
- Assert.assertNotNull(pSwitch);
- LOG.info("PhysicalSwitch: {}", pSwitch);
+ PhysicalSwitchAugmentation phySwitch = getPhysicalSwitch(connectionInfo);
+ Assert.assertNotNull(phySwitch);
+ LOG.info("PhysicalSwitch: {}", phySwitch);
}
}
private Node getPhysicalSwitchNode(ConnectionInfo connectionInfo, String psName, LogicalDatastoreType dataStore) {
InstanceIdentifier<Node> psIid =
HwvtepSouthboundUtils.createInstanceIdentifier(connectionInfo, new HwvtepNodeName(psName));
- return mdsalUtils.read(dataStore, psIid);
+ return mdsalUtils.read(dataStore, psIid);
}
-
}
import static org.opendaylight.ovsdb.lib.operations.Operations.op;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
/**
* Test general OVSDB transactions (viz., insert, select, update,
* mutate, comment, delete, where, commit) as well as the special
- * transactions (viz., abort and assert)
+ * transactions (viz., abort and assert).
*/
@Test
public void testTransact() throws IOException, InterruptedException, ExecutionException {
GenericTableSchema bridge = dbSchema.table("Bridge", GenericTableSchema.class);
List<MonitorRequest> monitorRequests = new ArrayList<>();
- ColumnSchema<GenericTableSchema, Set<Integer>> flood_vlans = bridge.multiValuedColumn("flood_vlans", Integer.class);
- ColumnSchema<GenericTableSchema, Map<String, String>> externalIds = bridge.multiValuedColumn("external_ids", String.class, String.class);
+ ColumnSchema<GenericTableSchema, Set<Integer>> floodVlans =
+ bridge.multiValuedColumn("flood_vlans", Integer.class);
+ ColumnSchema<GenericTableSchema, Map<String, String>> externalIds =
+ bridge.multiValuedColumn("external_ids", String.class, String.class);
ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
MonitorRequestBuilder<GenericTableSchema> builder = new MonitorRequestBuilder<>(bridge);
if (filter) {
builder.addColumn(bridge.column("name"))
.addColumn(bridge.column("fail_mode", String.class))
- .addColumn(flood_vlans)
+ .addColumn(floodVlans)
.addColumn(externalIds);
}
monitorRequests.add(builder.with(new MonitorSelect(true, true, true, true))
TableUpdates updates = ovs.monitor(dbSchema, monitorRequests, new MonitorCallBack() {
@Override
- public void update(TableUpdates result, DatabaseSchema dbSchema) {
+ public void update(TableUpdates result, DatabaseSchema unused) {
results.add(result);
LOG.info("result = {}", result);
}
@Override
- public void exception(Throwable t) {
- results.add(t);
- LOG.warn("t = ", t);
+ public void exception(Throwable ex) {
+ results.add(ex);
+ LOG.warn("t = ", ex);
}
});
if (updates != null) {
TableUpdate<GenericTableSchema> update = updates.getUpdate(bridge);
assertTrue(update.getRows().size() > 0);
for (UUID uuid : update.getRows().keySet()) {
- Row<GenericTableSchema> aNew = update.getNew(uuid);
- if (!aNew.getColumn(name).getData().equals(TEST_BRIDGE_NAME)) {
+ Row<GenericTableSchema> row = update.getNew(uuid);
+ if (!row.getColumn(name).getData().equals(TEST_BRIDGE_NAME)) {
continue;
}
if (filter) {
- assertEquals(builder.getColumns().size(), aNew.getColumns().size());
+ assertEquals(builder.getColumns().size(), row.getColumns().size());
} else {
- // As per RFC7047, Section 4.1.5 : If "columns" is omitted, all columns in the table, except for "_uuid", are monitored.
- assertEquals(bridge.getColumns().size() - 1, aNew.getColumns().size());
+ // As per RFC7047, Section 4.1.5 : If "columns" is omitted, all columns in the table, except
+ // for "_uuid", are monitored.
+ assertEquals(bridge.getColumns().size() - 1, row.getColumns().size());
}
- for (Column<GenericTableSchema, ?> column: aNew.getColumns()) {
- if (column.getSchema().equals(flood_vlans)) {
+ for (Column<GenericTableSchema, ?> column: row.getColumns()) {
+ if (column.getSchema().equals(floodVlans)) {
// Test for the 5 flood_vlans inserted in Bridge br-test in createBridgeTransaction
- Set<Integer> data = column.getData(flood_vlans);
+ Set<Integer> data = column.getData(floodVlans);
assertNotNull(data);
assertTrue(!data.isEmpty());
assertEquals(5, data.size());
assertNotNull(data);
assertNotNull(data.get("key"));
assertEquals("value", data.get("key"));
- // Test for {"key2", "value2"} external_ids mutation-inserted in Bridge br-test in createBridgeTransaction
+ // Test for {"key2", "value2"} external_ids mutation-inserted in Bridge br-test in
+ // createBridgeTransaction
assertNotNull(data.get("key2"));
assertEquals("value2", data.get("key2"));
}
}
return;
}
- fail("Bridge being monitored :"+ TEST_BRIDGE_NAME +" Not found");
+ fail("Bridge being monitored :" + TEST_BRIDGE_NAME + " Not found");
}
/*
assertNotNull(dbSchema);
GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
- ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+ ColumnSchema<GenericTableSchema, UUID> uuid = ovsTable.column("_uuid", UUID.class);
List<OperationResult> results = ovs.transactBuilder(dbSchema)
.add(op.select(ovsTable)
- .column(_uuid))
+ .column(uuid))
.execute()
.get();
OperationResult result = results.get(0);
List<Row<GenericTableSchema>> rows = result.getRows();
Row<GenericTableSchema> ovsTableRow = rows.get(0);
- return ovsTableRow.getColumn(_uuid).getData();
+ return ovsTableRow.getColumn(uuid).getData();
}
private void createBridgeTransaction() throws IOException, InterruptedException, ExecutionException {
GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
- ColumnSchema<GenericTableSchema, String> fail_mode = bridge.column("fail_mode", String.class);
- ColumnSchema<GenericTableSchema, Set<Integer>> flood_vlans = bridge.multiValuedColumn("flood_vlans", Integer.class);
- ColumnSchema<GenericTableSchema, Map<String, String>> externalIds = bridge.multiValuedColumn("external_ids", String.class, String.class);
+ ColumnSchema<GenericTableSchema, String> failMode = bridge.column("fail_mode", String.class);
+ ColumnSchema<GenericTableSchema, Set<Integer>> floodVlans =
+ bridge.multiValuedColumn("flood_vlans", Integer.class);
+ ColumnSchema<GenericTableSchema, Map<String, String>> externalIds =
+ bridge.multiValuedColumn("external_ids", String.class, String.class);
ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
- ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+ ColumnSchema<GenericTableSchema, UUID> uuid = ovsTable.column("_uuid", UUID.class);
String namedUuid = "br_test";
- int insertOperationIndex = 0;
UUID parentTable = selectOpenVSwitchTableUuid();
TransactionBuilder transactionBuilder = ovs.transactBuilder(dbSchema)
/*
.add(op.insert(bridge)
.withId(namedUuid)
.value(name, TEST_BRIDGE_NAME)
- .value(flood_vlans, Sets.newHashSet(100, 101, 4001))
+ .value(floodVlans, Sets.newHashSet(100, 101, 4001))
.value(externalIds, ImmutableMap.of("key","value")))
.add(op.comment("Inserting Bridge br-int"))
.add(op.update(bridge)
- .set(fail_mode, "secure")
+ .set(failMode, "secure")
.where(name.opEqual(TEST_BRIDGE_NAME))
.build())
.add(op.select(bridge)
.column(name)
- .column(_uuid)
+ .column(uuid)
.where(name.opEqual(TEST_BRIDGE_NAME))
.build())
.add(op.mutate(bridge)
- .addMutation(flood_vlans, Mutator.INSERT, Sets.newHashSet(200,400))
+ .addMutation(floodVlans, Mutator.INSERT, Sets.newHashSet(200,400))
.where(name.opEqual(TEST_BRIDGE_NAME))
.build())
.add(op.mutate(bridge)
.build())
.add(op.mutate(ovsTable)
.addMutation(bridges, Mutator.INSERT, Collections.singleton(new UUID(namedUuid)))
- .where(_uuid.opEqual(parentTable))
+ .where(uuid.opEqual(parentTable))
.build())
.add(op.commit(true));
for (OperationResult result : operationResults) {
assertNull(result.getError());
}
+
+ int insertOperationIndex = 0;
testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
}
List<String> dbNames = databases.get();
assertNotNull(dbNames);
boolean hasOpenVswitchSchema = false;
- for(String dbName : dbNames) {
- if (dbName.equals(LibraryIntegrationTestUtils.OPEN_VSWITCH)) {
+ for (String dbName : dbNames) {
+ if (dbName.equals(LibraryIntegrationTestUtils.OPEN_VSWITCH)) {
hasOpenVswitchSchema = true;
break;
- }
+ }
}
assertTrue(LibraryIntegrationTestUtils.OPEN_VSWITCH
+ " schema is not supported by the switch", hasOpenVswitchSchema);
}
+ @Override
@Before
public void setup() throws Exception {
schema = LibraryIntegrationTestUtils.OPEN_VSWITCH;
ColumnSchema<GenericTableSchema, String> name = bridge.column("name", String.class);
GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
- ColumnSchema<GenericTableSchema, UUID> _uuid = ovsTable.column("_uuid", UUID.class);
+ ColumnSchema<GenericTableSchema, UUID> uuid = ovsTable.column("_uuid", UUID.class);
UUID parentTable = selectOpenVSwitchTableUuid();
ListenableFuture<List<OperationResult>> results = ovs.transactBuilder(dbSchema)
.build())
.add(op.mutate(ovsTable)
.addMutation(bridges, Mutator.DELETE, Collections.singleton(testBridgeUuid))
- .where(_uuid.opEqual(parentTable))
+ .where(uuid.opEqual(parentTable))
.build())
.add(op.commit(true))
.execute();
* are verified.
*/
@Test
- public void testTypedBridgeCreate() throws IOException, InterruptedException, ExecutionException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- TestBridge rBridge = ovs.createTypedRowWrapper(TestBridge.class);
- rBridge.setName(TEST_BRIDGE_NAME);
- rBridge.setStatus(ImmutableMap.of("key","value"));
- rBridge.setFloodVlans(Collections.singleton(34));
+ public void testTypedBridgeCreate() throws IOException, InterruptedException, ExecutionException,
+ NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ TestBridge testBridge = ovs.createTypedRowWrapper(TestBridge.class);
+ testBridge.setName(TEST_BRIDGE_NAME);
+ testBridge.setStatus(ImmutableMap.of("key","value"));
+ testBridge.setFloodVlans(Collections.singleton(34));
GenericTableSchema ovsTable = dbSchema.table("Open_vSwitch", GenericTableSchema.class);
ColumnSchema<GenericTableSchema, Set<UUID>> bridges = ovsTable.multiValuedColumn("bridges", UUID.class);
String namedUuid = "br_test";
- int insertOperationIndex = 0;
TransactionBuilder transactionBuilder = ovs.transactBuilder(dbSchema)
- .add(op.insert(rBridge)
+ .add(op.insert(testBridge)
.withId(namedUuid))
.add(op.mutate(ovsTable)
.addMutation(bridges, Mutator.INSERT, Collections.singleton(new UUID(namedUuid))));
// Check if Results matches the number of operations in transaction
assertEquals(transactionBuilder.getOperations().size(), operationResults.size());
LOG.info("Insert & Update operation results = {}", operationResults);
+
+ int insertOperationIndex = 0;
testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
}
List<String> dbNames = databases.get();
assertNotNull(dbNames);
boolean hasOpenVswitchSchema = false;
- for(String dbName : dbNames) {
- if (dbName.equals(LibraryIntegrationTestUtils.OPEN_VSWITCH)) {
+ for (String dbName : dbNames) {
+ if (dbName.equals(LibraryIntegrationTestUtils.OPEN_VSWITCH)) {
hasOpenVswitchSchema = true;
break;
- }
+ }
}
assertTrue(LibraryIntegrationTestUtils.OPEN_VSWITCH
+ " schema is not supported by the switch", hasOpenVswitchSchema);
}
+ @Override
@Before
public void setup() throws Exception {
schema = LibraryIntegrationTestUtils.OPEN_VSWITCH;
* Interface name was set to TestBridge on purpose to test the @TypeTable annotation
* functionality of TyperHelper.java
*/
-@TypedTable(name="Bridge", database="Open_vSwitch")
+@TypedTable(name = "Bridge", database = "Open_vSwitch")
public interface TestBridge extends TypedBaseTable {
/*
* Its a good practice to set the @TypedColumn to these Statically typed Tables & Columns.
* The following "name" column is decorated with both GETDATA and GETCOLUMN and the corresponding test
* will test both the options.
*/
- @TypedColumn(name="name", method=MethodType.GETDATA)
+ @TypedColumn(name = "name", method = MethodType.GETDATA)
String getName();
- @TypedColumn(name="name", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "name", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, String> getNameColumn();
- @TypedColumn(name="name", method=MethodType.SETDATA)
+ @TypedColumn(name = "name", method = MethodType.SETDATA)
void setName(String name);
/*
* Annotations are NOT added to the Status column on purpose to test the backup
* functionality on getter, setter, column name derivation etc. TyperHelper.java.
*/
- Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+ Column<GenericTableSchema, Map<String, String>> getStatusColumn();
+
void setStatus(Map<String, String> status);
/*
* The method name and TypedColumn name was kept different on purpose to test the name
* resolution priority of TyperHelper.java
*/
- @TypedColumn(name="flood_vlans", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "flood_vlans", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<Integer>> getFloodVlansColumn();
- @TypedColumn(name="flood_vlans", method=MethodType.SETDATA)
+ @TypedColumn(name = "flood_vlans", method = MethodType.SETDATA)
void setFloodVlans(Set<Integer> vlans);
-
- @TypedColumn(name="ports", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "ports", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<UUID>> getPortsColumn();
- @TypedColumn(name="ports", method=MethodType.SETDATA)
+ @TypedColumn(name = "ports", method = MethodType.SETDATA)
void setPorts(Set<UUID> ports);
-
- @TypedColumn(name="mirrors", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "mirrors", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<UUID>> getMirrorsColumn();
- @TypedColumn(name="mirrors", method=MethodType.SETDATA)
+ @TypedColumn(name = "mirrors", method = MethodType.SETDATA)
void setMirrors(Set<UUID> mirrors);
-
- @TypedColumn(name="controller", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "controller", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<UUID>> getControllerColumn();
- @TypedColumn(name="controller", method=MethodType.SETDATA)
+ @TypedColumn(name = "controller", method = MethodType.SETDATA)
void setController(Set<UUID> controller);
-
- @TypedColumn(name="datapath_id", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "datapath_id", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<String>> getDatapathIdColumn();
- @TypedColumn(name="datapath_id", method=MethodType.SETDATA)
+ @TypedColumn(name = "datapath_id", method = MethodType.SETDATA)
void setDatapathId(Set<String> datapathId);
-
- @TypedColumn(name="datapath_type", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "datapath_type", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, String> getDatapathTypeColumn();
- @TypedColumn(name="datapath_type", method=MethodType.SETDATA)
+ @TypedColumn(name = "datapath_type", method = MethodType.SETDATA)
void setDatapathType(String datapathType);
-
- @TypedColumn(name="fail_mode", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "fail_mode", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<String>> getFailModeColumn();
- @TypedColumn(name="fail_mode", method=MethodType.SETDATA)
+ @TypedColumn(name = "fail_mode", method = MethodType.SETDATA)
void setFailMode(Set<String> failMode);
-
- @TypedColumn(name="sflow", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "sflow", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<UUID>> getSflowColumn();
- @TypedColumn(name="sflow", method=MethodType.SETDATA)
+ @TypedColumn(name = "sflow", method = MethodType.SETDATA)
void setSflow(Set<UUID> sflow);
-
- @TypedColumn(name="netflow", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "netflow", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<UUID>> getNetflowColumn();
- @TypedColumn(name="netflow", method=MethodType.SETDATA)
+ @TypedColumn(name = "netflow", method = MethodType.SETDATA)
void setNetflow(Set<UUID> netflow);
-
- @TypedColumn(name="flow_tables", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "flow_tables", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Map<Integer, UUID>> getFlowTablesColumn();
- @TypedColumn(name="flow_tables", method=MethodType.SETDATA)
+ @TypedColumn(name = "flow_tables", method = MethodType.SETDATA)
void setFlowTables(Map<Integer, UUID> flowTables);
-
- @TypedColumn(name="stp_enable", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "stp_enable", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Boolean> getStpEnableColumn();
- @TypedColumn(name="stp_enable", method=MethodType.SETDATA)
+ @TypedColumn(name = "stp_enable", method = MethodType.SETDATA)
+ @SuppressWarnings("checkstyle:ParameterName")
void setStpEnable(Boolean stp_enable);
-
- @TypedColumn(name="protocols", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "protocols", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<String>> getProtocolsColumn();
- @TypedColumn(name="protocols", method=MethodType.SETDATA)
+ @TypedColumn(name = "protocols", method = MethodType.SETDATA)
void setProtocols(Set<String> protocols);
-
- @TypedColumn(name="other_config", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "other_config", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Map<String, String>> getOtherConfigColumn();
- @TypedColumn(name="other_config", method=MethodType.SETDATA)
+ @TypedColumn(name = "other_config", method = MethodType.SETDATA)
+ @SuppressWarnings("checkstyle:ParameterName")
void setOtherConfig(Map<String, String> other_config);
-
- @TypedColumn(name="external_ids", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "external_ids", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Map<String, String>> getExternalIdsColumn();
- @TypedColumn(name="external_ids", method=MethodType.SETDATA)
+ @TypedColumn(name = "external_ids", method = MethodType.SETDATA)
void setExternalIds(Map<String, String> externalIds);
-
- @TypedColumn(name="ipfix", method=MethodType.GETCOLUMN)
+ @TypedColumn(name = "ipfix", method = MethodType.GETCOLUMN)
Column<GenericTableSchema, Set<UUID>> getIpfixColumn();
- @TypedColumn(name="ipfix", method=MethodType.SETDATA)
+ @TypedColumn(name = "ipfix", method = MethodType.SETDATA)
void setIpfix(Set<UUID> ipfix);
}
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
-public class HardwareVTEPIT extends LibraryIntegrationTestBase {
+@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
+public class HardwareVTEPIT extends LibraryIntegrationTestBase {
private static final Logger LOG = LoggerFactory.getLogger(HardwareVTEPIT.class);
private UUID testManagerUuid = null;
+ @Override
@Before
public void setup() throws Exception {
schema = LibraryIntegrationTestUtils.HARDWARE_VTEP;
/**
* Create a new manager string in addition to whatever is already there
- * Will modify the Global table to include the UUID to the new Manager row
+ * Will modify the Global table to include the UUID to the new Manager row.
*/
@SuppressWarnings("unchecked")
- public void managerInsert () throws ExecutionException, InterruptedException {
+ public void managerInsert() throws ExecutionException, InterruptedException {
//Ensure test only proceeds if HW VTEP is supported
assumeTrue(isSchemaSupported(getClient(), LibraryIntegrationTestUtils.HARDWARE_VTEP));
assertNotNull(getGlobalTableUuid(getClient(), getTableCache()));
}
- public void managerDelete () throws ExecutionException, InterruptedException {
+ public void managerDelete() throws ExecutionException, InterruptedException {
assumeTrue(isSchemaSupported(getClient(), LibraryIntegrationTestUtils.HARDWARE_VTEP));
Manager manager = getClient().getTypedRowWrapper(Manager.class, null);
}
@Test
- public void testManager () throws ExecutionException, InterruptedException {
+ public void testManager() throws ExecutionException, InterruptedException {
managerInsert();
managerDelete();
}
import org.opendaylight.ovsdb.schema.openvswitch.Controller;
import org.opendaylight.ovsdb.schema.openvswitch.FlowSampleCollectorSet;
import org.opendaylight.ovsdb.schema.openvswitch.FlowTable;
-import org.opendaylight.ovsdb.schema.openvswitch.Interface;
import org.opendaylight.ovsdb.schema.openvswitch.IPFIX;
+import org.opendaylight.ovsdb.schema.openvswitch.Interface;
import org.opendaylight.ovsdb.schema.openvswitch.Manager;
import org.opendaylight.ovsdb.schema.openvswitch.Mirror;
import org.opendaylight.ovsdb.schema.openvswitch.NetFlow;
private UUID testSFlowUuid = null;
private UUID testSslUuid = null;
private UUID testAutoattachUuid = null;
- private Version flowSampleCollectorSetFromVersion = Version.fromString("7.1.0");
- private Version flowTableFromVersion = Version.fromString("6.5.0");
- private Version prefixesAddedVersion = Version.fromString("7.4.0");
- private Version externalIdAddedVerson = Version.fromString("7.5.0");
- private Version ipfixFromVersion = Version.fromString("7.1.0");
- private Version ipfixCacheFromVersion = Version.fromString("7.3.0");
- private Version autoAttachFromVersion = Version.fromString("7.11.2");
-
+ private final Version flowSampleCollectorSetFromVersion = Version.fromString("7.1.0");
+ private final Version flowTableFromVersion = Version.fromString("6.5.0");
+ private final Version prefixesAddedVersion = Version.fromString("7.4.0");
+ private final Version externalIdAddedVerson = Version.fromString("7.5.0");
+ private final Version ipfixFromVersion = Version.fromString("7.1.0");
+ private final Version ipfixCacheFromVersion = Version.fromString("7.3.0");
+ private final Version autoAttachFromVersion = Version.fromString("7.11.2");
+
+ @Override
@Before
public void setup() throws Exception {
schema = LibraryIntegrationTestUtils.OPEN_VSWITCH;
super.setup();
}
- public UUID getOpenVSwitchTableUuid (OvsdbClient ovs, Map<String, Map<UUID, Row>> tableCache) {
+ public UUID getOpenVSwitchTableUuid(OvsdbClient ovs, Map<String, Map<UUID, Row>> tableCache) {
OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
Map<UUID, Row> ovsTable = tableCache.get(openVSwitch.getSchema().getName());
if (ovsTable != null) {
return null;
}
- public UUID bridgeInsert () throws ExecutionException, InterruptedException {
+ public UUID bridgeInsert() throws ExecutionException, InterruptedException {
Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
bridge.setName(TEST_BRIDGE_NAME);
bridge.setStatus(ImmutableMap.of("key", "value"));
return bridgeUuid;
}
- public void bridgeDelete (UUID bridgeUuid) throws ExecutionException, InterruptedException {
+ public void bridgeDelete(UUID bridgeUuid) throws ExecutionException, InterruptedException {
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
@Test
@SuppressWarnings("unchecked")
- public void testBridge () throws ExecutionException, InterruptedException {
+ public void testBridge() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
// Verify that the local cache was updated with the remote changes
}
@SuppressWarnings("unchecked")
- private void controllerInsert () throws ExecutionException, InterruptedException {
+ private void controllerInsert() throws ExecutionException, InterruptedException {
String controllerUuidStr = "controller";
Controller controller1 = getClient().createTypedRowWrapper(Controller.class);
controller1.setTarget("tcp:1.1.1.1:6640");
assertEquals(2, monitoredBridge.getControllerColumn().getData().size());
}
- private void controllerDelete () throws ExecutionException, InterruptedException {
+ private void controllerDelete() throws ExecutionException, InterruptedException {
Controller controller = getClient().getTypedRowWrapper(Controller.class, null);
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get();
}
@Test
- public void testController () throws ExecutionException, InterruptedException {
+ public void testController() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
controllerInsert();
controllerDelete();
}
@Test(expected = SchemaVersionMismatchException.class)
- public void testFlowSampleCollectorSetTableNotSupported () {
+ public void testFlowSampleCollectorSetTableNotSupported() {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) < 0);
}
@SuppressWarnings("unchecked")
- public void flowSampleCollectorSetInsert () throws ExecutionException, InterruptedException {
+ public void flowSampleCollectorSetInsert() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0);
monitoredflowSampleCollectorSet.getIdColumn().getData());
}
- public void flowSampleCollectorSetDelete () throws ExecutionException, InterruptedException {
+ public void flowSampleCollectorSetDelete() throws ExecutionException, InterruptedException {
assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0);
- FlowSampleCollectorSet flowSampleCollectorSet = getClient().getTypedRowWrapper(FlowSampleCollectorSet.class, null);
+ FlowSampleCollectorSet flowSampleCollectorSet =
+ getClient().getTypedRowWrapper(FlowSampleCollectorSet.class, null);
TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
.add(op.delete(flowSampleCollectorSet.getSchema())
- .where(flowSampleCollectorSet.getUuidColumn().getSchema().opEqual(testFlowSampleCollectorSetUuid))
- .build())
+ .where(flowSampleCollectorSet.getUuidColumn().getSchema().opEqual(testFlowSampleCollectorSetUuid))
+ .build())
.add(op.comment("FlowSampleCollectorSet: Deleting " + testFlowSampleCollectorSetUuid))
.add(op.commit(true));
}
@Test
- public void testFlowSampleCollectorSet () throws ExecutionException, InterruptedException {
+ public void testFlowSampleCollectorSet() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(flowSampleCollectorSetFromVersion) >= 0);
}
@Test(expected = SchemaVersionMismatchException.class)
- public void testFlowTableTableNotSupported () {
+ public void testFlowTableTableNotSupported() {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(flowTableFromVersion) < 0);
}
@SuppressWarnings("unchecked")
- public void flowTableInsert () throws ExecutionException, InterruptedException {
+ public void flowTableInsert() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(flowTableFromVersion) >= 0);
String flowTableUuidStr = "testFlowTable";
String tableName = "flow_table_row_name";
String overflowPolicy = "evict";
- String groups = "group name";
String prefixes = "wildcarding prefixes";
- Long flowLimit = 50000L;
Map<Long, UUID> flowTableBrRef = new HashMap<>();
flowTableBrRef.put(1L, new UUID(flowTableUuidStr));
FlowTable flowTable = getClient().createTypedRowWrapper(FlowTable.class);
flowTable.setName(ImmutableSet.of(tableName));
flowTable.setOverflowPolicy(ImmutableSet.of(overflowPolicy));
- flowTable.setGroups(ImmutableSet.of(groups));
+ flowTable.setGroups(ImmutableSet.of("group name"));
if (schemaVersion.compareTo(prefixesAddedVersion) >= 0) {
flowTable.setPrefixes(ImmutableSet.of(prefixes));
}
if (schemaVersion.compareTo(externalIdAddedVerson) >= 0) {
flowTable.setExternalIds(ImmutableMap.of("I <3", "OVS"));
}
+ Long flowLimit = 50000L;
flowTable.setFlowLimit(ImmutableSet.of(flowLimit));
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
assertEquals(flowTable.getNameColumn().getData(), monitoredFlowTable.getNameColumn().getData());
}
- public void flowTableDelete () throws ExecutionException, InterruptedException {
+ public void flowTableDelete() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(flowTableFromVersion) >= 0);
}
@Test
- public void setTestFlowTableSet () throws ExecutionException, InterruptedException {
+ public void setTestFlowTableSet() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(flowTableFromVersion) >= 0);
- UUID testBridgeUuid = bridgeInsert();
+ UUID bridgeUuid = bridgeInsert();
flowTableInsert();
flowTableDelete();
- bridgeDelete(testBridgeUuid);
+ bridgeDelete(bridgeUuid);
}
@Test(expected = SchemaVersionMismatchException.class)
- public void testIpfixTableNotSupported () {
+ public void testIpfixTableNotSupported() {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(ipfixFromVersion) < 0);
}
@SuppressWarnings("unchecked")
- public void ipfixInsert () throws ExecutionException, InterruptedException {
+ public void ipfixInsert() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(ipfixFromVersion) >= 0);
- String ipfixUuidStr = "testIpfix";
String ipfixTarget = "172.16.20.1:4739";
Long obsDomainId = 112L;
Long obsPointId = 358L;
Long cacheMax = 132L;
Long cacheTimeout = 134L;
- Long sampling = 558L;
IPFIX ipfix = getClient().createTypedRowWrapper(IPFIX.class);
ipfix.setTargets(ImmutableSet.of(ipfixTarget));
ipfix.setCacheMaxFlows(ImmutableSet.of(cacheMax));
ipfix.setCacheActiveTimeout(ImmutableSet.of(cacheTimeout));
}
+
+ Long sampling = 558L;
ipfix.setSampling(ImmutableSet.of(sampling));
ipfix.setExternalIds(ImmutableMap.of("I <3", "ovs"));
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
+ String ipfixUuidStr = "testIpfix";
TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
.add(op.insert(ipfix)
.withId(ipfixUuidStr))
// Verify that the local cache was updated with the remote changes
Row ipfixRow = getTableCache().get(ipfix.getSchema().getName()).get(testIpfixUuid);
- IPFIX monitoredIPFIX = getClient().getTypedRowWrapper(IPFIX.class, ipfixRow);
- assertEquals(testIpfixUuid, monitoredIPFIX.getUuidColumn().getData());
+ IPFIX monitoredIPFix = getClient().getTypedRowWrapper(IPFIX.class, ipfixRow);
+ assertEquals(testIpfixUuid, monitoredIPFix.getUuidColumn().getData());
}
- public void ipfixDelete () throws ExecutionException, InterruptedException {
+ public void ipfixDelete() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(ipfixFromVersion) >= 0);
}
@Test
- public void testIpfix () throws ExecutionException, InterruptedException {
+ public void testIpfix() throws ExecutionException, InterruptedException {
// Don't run this test if the table is not supported
assumeTrue(schemaVersion.compareTo(ipfixFromVersion) >= 0);
assertEquals(externalIds, monitoredManager.getExternalIdsColumn().getData());
}
- public void managerDelete () throws ExecutionException, InterruptedException {
+ public void managerDelete() throws ExecutionException, InterruptedException {
Manager manager = getClient().getTypedRowWrapper(Manager.class, null);
OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
}
@Test
- public void testManager () throws ExecutionException, InterruptedException {
+ public void testManager() throws ExecutionException, InterruptedException {
managerInsert();
managerDelete();
}
@SuppressWarnings("unchecked")
- public void mirrorInsert () throws ExecutionException, InterruptedException {
+ public void mirrorInsert() throws ExecutionException, InterruptedException {
String mirrorUuidStr = "testMirror";
String mirrorName = "my_name_is_mirror";
Long outputVid = 1024L;
assertEquals(mirror.getExternalIdsColumn().getData(), monitoredMirror.getExternalIdsColumn().getData());
}
- private void mirrorDelete () throws ExecutionException, InterruptedException {
+ private void mirrorDelete() throws ExecutionException, InterruptedException {
Mirror mirror = getClient().getTypedRowWrapper(Mirror.class, null);
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get();
}
@Test
- public void testMirror () throws ExecutionException, InterruptedException {
+ public void testMirror() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
mirrorInsert();
mirrorDelete();
}
@SuppressWarnings("unchecked")
- public void netFlowInsert () throws ExecutionException, InterruptedException {
+ public void netFlowInsert() throws ExecutionException, InterruptedException {
String netFlowUuidStr = "testNetFlow";
String netFlowTargets = "172.16.20.200:6343";
Long engineType = 128L;
assertEquals(netFlow.getExternalIdsColumn().getData(), monitoredNetFlow.getExternalIdsColumn().getData());
}
- private void netFlowDelete () throws ExecutionException, InterruptedException {
+ private void netFlowDelete() throws ExecutionException, InterruptedException {
NetFlow netFlow = getClient().getTypedRowWrapper(NetFlow.class, null);
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get();
}
@Test
- public void testNetFlow () throws ExecutionException, InterruptedException {
+ public void testNetFlow() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
netFlowInsert();
netFlowDelete();
}
@SuppressWarnings("unchecked")
- public void portAndInterfaceInsert () throws ExecutionException, InterruptedException {
- String portUuidStr = "testPort";
+ public void portAndInterfaceInsert() throws ExecutionException, InterruptedException {
String intfUuidStr = "testIntf";
- String tunnelEncap = "vxlan";
Port port = getClient().createTypedRowWrapper(Port.class);
port.setName("testPort");
port.setTag(ImmutableSet.of(1L));
Interface intf = getClient().createTypedRowWrapper(Interface.class);
intf.setName(port.getNameColumn().getData());
- intf.setType(tunnelEncap);
+ intf.setType("vxlan");
intf.setExternalIds(ImmutableMap.of("vm-id", "12345abcedf78910"));
// For per Flow TEPs use remote_ip=flow
// For per Port TEPs use remote_ip=x.x.x.x (ipv4)
"key", "flow",
"dst_port", "8472"));
+ String portUuidStr = "testPort";
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
.add(op.insert(port.getSchema())
.build())
.add(op.comment("Interface: Updating " + intfUuidStr))
.add(op.mutate(bridge.getSchema())
- .addMutation(bridge.getPortsColumn().getSchema(), Mutator.INSERT, Collections.singleton(new UUID(portUuidStr)))
+ .addMutation(bridge.getPortsColumn().getSchema(), Mutator.INSERT,
+ Collections.singleton(new UUID(portUuidStr)))
.where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
.build())
.add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
assertEquals(intf.getNameColumn().getData(), monitoredInterface.getNameColumn().getData());
}
- private void portAndInterfaceDelete () throws ExecutionException, InterruptedException {
+ private void portAndInterfaceDelete() throws ExecutionException, InterruptedException {
Port port = getClient().getTypedRowWrapper(Port.class, null);
Interface intf = getClient().getTypedRowWrapper(Interface.class, null);
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
}
@Test
- public void testPortAndInterface () throws ExecutionException, InterruptedException {
+ public void testPortAndInterface() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
portAndInterfaceInsert();
portAndInterfaceDelete();
@SuppressWarnings("unchecked")
public void qosInsert() throws ExecutionException, InterruptedException {
- String portUuidStr = "testQosPortUuid";
String intfUuidStr = "testQosIntfUuid";
String qosUuidStr = "testQosUuid";
String qosPort = "testQosPort";
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
+ String portUuidStr = "testQosPortUuid";
TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
.add(op.insert(port.getSchema())
.withId(portUuidStr)
int insertPortOperationIndex = 0;
int insertInterfaceOperationIndex = 2;
- int insertQosOperationIndex = 4;
List<OperationResult> operationResults = executeTransaction(transactionBuilder,
"Insert and Mutate operation results for Port and Interface");
testPortUuid = operationResults.get(insertPortOperationIndex).getUuid();
assertNotNull(ASSERT_TRANS_UUID, testPortUuid);
testInterfaceUuid = operationResults.get(insertInterfaceOperationIndex).getUuid();
assertNotNull(ASSERT_TRANS_UUID, testInterfaceUuid);
+ int insertQosOperationIndex = 4;
testQosUuid = operationResults.get(insertQosOperationIndex).getUuid();
assertNotNull(ASSERT_TRANS_UUID, testQosUuid);
assertEquals(qos.getTypeColumn().getData(), monitoredQos.getTypeColumn().getData());
}
- private void qosDelete () throws ExecutionException, InterruptedException {
+ private void qosDelete() throws ExecutionException, InterruptedException {
Port port = getClient().getTypedRowWrapper(Port.class, null);
Interface intf = getClient().getTypedRowWrapper(Interface.class, null);
Qos qos = getClient().getTypedRowWrapper(Qos.class, null);
}
@Test
- public void testQos () throws ExecutionException, InterruptedException {
+ public void testQos() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
qosInsert();
qosDelete();
assertEquals(queue.getExternalIdsColumn().getData(), monitoredQueue.getExternalIdsColumn().getData());
}
- private void queueDelete () throws ExecutionException, InterruptedException {
+ private void queueDelete() throws ExecutionException, InterruptedException {
Queue queue = getClient().getTypedRowWrapper(Queue.class, null);
Qos qos = getClient().getTypedRowWrapper(Qos.class, null);
DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get();
}
@Test
- public void testQueue () throws ExecutionException, InterruptedException {
+ public void testQueue() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
qosInsert();
queueInsert();
}
@SuppressWarnings("unchecked")
- public void sFlowInsert () throws ExecutionException, InterruptedException {
- String sFlowUuidStr = "testSFlow";
- String sFlowTarget = "172.16.20.200:6343";
+ public void sFlowInsert() throws ExecutionException, InterruptedException {
Long header = 128L;
Long obsPointId = 358L;
- Long polling =10L;
+ Long polling = 10L;
String agent = "172.16.20.210";
Long sampling = 64L;
- SFlow sFlow = getClient().createTypedRowWrapper(SFlow.class);
- sFlow.setTargets(ImmutableSet.of(sFlowTarget));
- sFlow.setHeader(ImmutableSet.of(header));
- sFlow.setPolling(ImmutableSet.of(obsPointId));
- sFlow.setPolling(ImmutableSet.of(polling));
- sFlow.setAgent(ImmutableSet.of(agent));
- sFlow.setSampling(ImmutableSet.of(sampling));
- sFlow.setExternalIds(ImmutableMap.of("kit", "tah"));
+ SFlow sflow = getClient().createTypedRowWrapper(SFlow.class);
+ sflow.setTargets(ImmutableSet.of("172.16.20.200:6343"));
+ sflow.setHeader(ImmutableSet.of(header));
+ sflow.setPolling(ImmutableSet.of(obsPointId));
+ sflow.setPolling(ImmutableSet.of(polling));
+ sflow.setAgent(ImmutableSet.of(agent));
+ sflow.setSampling(ImmutableSet.of(sampling));
+ sflow.setExternalIds(ImmutableMap.of("kit", "tah"));
+
+ String sflowUuidStr = "testSFlow";
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
TransactionBuilder transactionBuilder = getClient().transactBuilder(getDbSchema())
- .add(op.insert(sFlow.getSchema())
- .withId(sFlowUuidStr)
- .value(sFlow.getTargetsColumn())
- .value(sFlow.getHeaderColumn())
- .value(sFlow.getPollingColumn())
- .value(sFlow.getAgentColumn())
- .value(sFlow.getSamplingColumn())
- .value(sFlow.getExternalIdsColumn()))
- .add(op.comment("sFlow: Inserting " + sFlowUuidStr))
+ .add(op.insert(sflow.getSchema())
+ .withId(sflowUuidStr)
+ .value(sflow.getTargetsColumn())
+ .value(sflow.getHeaderColumn())
+ .value(sflow.getPollingColumn())
+ .value(sflow.getAgentColumn())
+ .value(sflow.getSamplingColumn())
+ .value(sflow.getExternalIdsColumn()))
+ .add(op.comment("sFlow: Inserting " + sflowUuidStr))
.add(op.mutate(bridge.getSchema())
.addMutation(bridge.getSflowColumn().getSchema(), Mutator.INSERT,
- Collections.singleton(new UUID(sFlowUuidStr)))
+ Collections.singleton(new UUID(sflowUuidStr)))
.where(bridge.getNameColumn().getSchema().opEqual(TEST_BRIDGE_NAME))
.build())
.add(op.comment("Bridge: Mutating " + TEST_BRIDGE_NAME));
assertNotNull(ASSERT_TRANS_UUID, testSFlowUuid);
// Verify that the local cache was updated with the remote changes
- Row sFlowRow = getTableCache().get(sFlow.getSchema().getName()).get(testSFlowUuid);
- Queue monitoredSFlow = getClient().getTypedRowWrapper(Queue.class, sFlowRow);
- assertEquals(sFlow.getExternalIdsColumn().getData(), monitoredSFlow.getExternalIdsColumn().getData());
+ Row sflowRow = getTableCache().get(sflow.getSchema().getName()).get(testSFlowUuid);
+ Queue monitoredSFlow = getClient().getTypedRowWrapper(Queue.class, sflowRow);
+ assertEquals(sflow.getExternalIdsColumn().getData(), monitoredSFlow.getExternalIdsColumn().getData());
}
- private void sFlowDelete () throws ExecutionException, InterruptedException {
- SFlow sFlow = getClient().getTypedRowWrapper(SFlow.class, null);
+ private void sFlowDelete() throws ExecutionException, InterruptedException {
+ SFlow sflow = getClient().getTypedRowWrapper(SFlow.class, null);
Bridge bridge = getClient().getTypedRowWrapper(Bridge.class, null);
DatabaseSchema dbSchema = getClient().getSchema(LibraryIntegrationTestUtils.OPEN_VSWITCH).get();
TransactionBuilder transactionBuilder = getClient().transactBuilder(dbSchema)
- .add(op.delete(sFlow.getSchema())
- .where(sFlow.getUuidColumn().getSchema().opEqual(testSFlowUuid))
+ .add(op.delete(sflow.getSchema())
+ .where(sflow.getUuidColumn().getSchema().opEqual(testSFlowUuid))
.build())
.add(op.comment("SFlow: Deleting " + testSFlowUuid))
.add(op.mutate(bridge.getSchema()) // Delete an sflow column in the Bridge table
}
@Test
- public void testSFlow () throws ExecutionException, InterruptedException {
+ public void testSFlow() throws ExecutionException, InterruptedException {
testBridgeUuid = bridgeInsert();
sFlowInsert();
sFlowDelete();
}
@SuppressWarnings("unchecked")
- public void sslInsert () throws ExecutionException, InterruptedException {
+ public void sslInsert() throws ExecutionException, InterruptedException {
String sslUuidStr = "sslUuidName";
String caCert = "PARC";
assertEquals(ssl.getExternalIdsColumn().getData(), monitoredSsl.getExternalIdsColumn().getData());
}
- public void sslDelete () throws ExecutionException, InterruptedException {
+ public void sslDelete() throws ExecutionException, InterruptedException {
SSL ssl = getClient().getTypedRowWrapper(SSL.class, null);
OpenVSwitch openVSwitch = getClient().getTypedRowWrapper(OpenVSwitch.class, null);
}
@Test
- public void testSsl () throws ExecutionException, InterruptedException {
+ public void testSsl() throws ExecutionException, InterruptedException {
sslInsert();
sslDelete();
}
@Test
- public void testTyperUtilsSpecialMethodsToString () {
+ public void testTyperUtilsSpecialMethodsToString() {
Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
assertNotNull(bridge);
bridge.setName(TEST_BRIDGE_NAME);
}
@Test
- public void testTyperUtilsSpecialMethodsEquals () {
+ public void testTyperUtilsSpecialMethodsEquals() {
Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
assertNotNull(bridge);
bridge.setName(TEST_BRIDGE_NAME);
}
@Test
- public void testTyperUtilsSpecialMethodsHashCode () {
+ public void testTyperUtilsSpecialMethodsHashCode() {
Bridge bridge = getClient().createTypedRowWrapper(Bridge.class);
assertNotNull(bridge);
import static org.junit.Assert.assertNull;
import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.ListenableFuture;
-
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class LibraryIT extends LibraryIntegrationTestBase {
private static final String TEST_BRIDGE_NAME = "br_test";
private static UUID testBridgeUuid = null;
+ @Override
@Before
public void setup() throws Exception {
schema = LibraryIntegrationTestUtils.OPEN_VSWITCH;
OpenVSwitch openVSwitch = ovsdbClient.createTypedRowWrapper(OpenVSwitch.class);
openVSwitch.setBridges(Collections.singleton(new UUID(TEST_BRIDGE_NAME)));
- int insertOperationIndex = 0;
-
TransactionBuilder transactionBuilder = ovsdbClient.transactBuilder(dbSchema)
.add(op.insert(bridge.getSchema())
.withId(TEST_BRIDGE_NAME)
for (OperationResult result : operationResults) {
assertNull(result.getError());
}
+
+ int insertOperationIndex = 0;
testBridgeUuid = operationResults.get(insertOperationIndex).getUuid();
assertNotNull(testBridgeUuid);
}
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.assumeTrue;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
protected static final String ASSERT_TRANS_OPERATION_COUNT = "Transaction should match number of operations";
protected static final String ASSERT_TRANS_UUID = "Transaction UUID should not be null";
protected static Version schemaVersion;
+ protected static DatabaseSchema dbSchema;
private static boolean schemaSupported = false;
+ private static AtomicBoolean setup = new AtomicBoolean(false);
protected static OvsdbClient ovsdbClient;
private static Map<String, Map<UUID, Row>> tableCache = new HashMap<>();
private static boolean monitorReady = false;
return tableCache;
}
- protected OvsdbClient getClient () {
+ protected OvsdbClient getClient() {
return ovsdbClient;
}
- protected static DatabaseSchema dbSchema;
- protected DatabaseSchema getDbSchema () {
+ protected DatabaseSchema getDbSchema() {
return dbSchema;
}
- private static AtomicBoolean setup = new AtomicBoolean(false);
protected static boolean getSetup() {
return setup.get();
}
protected BindingAwareBroker.ProviderContext getProviderContext() {
BindingAwareBroker.ProviderContext providerContext = null;
- for (int i=0; i < 60; i++) {
+ for (int i = 0; i < 60; i++) {
LOG.info("Looking for ProviderContext, try {}", i);
providerContext = getSession();
if (providerContext != null) {
return providerContext;
}
- public boolean checkSchema (String schema) {
+ public boolean checkSchema(String schemaStr)
+ throws IOException, InterruptedException, ExecutionException, TimeoutException {
if (schemaSupported) {
- LOG.info("Schema ({}) is supported", schema);
+ LOG.info("Schema ({}) is supported", schemaStr);
return true;
}
- try {
- ovsdbClient = LibraryIntegrationTestUtils.getTestConnection(this);
- assertNotNull("Invalid Client. Check connection params", ovsdbClient);
- if (isSchemaSupported(ovsdbClient, schema)) {
- dbSchema = ovsdbClient.getSchema(schema).get();
- assertNotNull(dbSchema);
- LOG.info("{} schema in {} with tables: {}",
- schema, ovsdbClient.getConnectionInfo(), dbSchema.getTables());
- schemaSupported = true;
- return true;
- }
- } catch (Exception e) {
- fail("Exception: " + e);
+
+ ovsdbClient = LibraryIntegrationTestUtils.getTestConnection(this);
+ assertNotNull("Invalid Client. Check connection params", ovsdbClient);
+ if (isSchemaSupported(ovsdbClient, schemaStr)) {
+ dbSchema = ovsdbClient.getSchema(schemaStr).get();
+ assertNotNull(dbSchema);
+ LOG.info("{} schema in {} with tables: {}",
+ schemaStr, ovsdbClient.getConnectionInfo(), dbSchema.getTables());
+ schemaSupported = true;
+ return true;
}
- LOG.info("Schema ({}) is not supported", schema);
+ LOG.info("Schema ({}) is not supported", schemaStr);
return false;
}
- public boolean isSchemaSupported (String schema) throws ExecutionException,
+ public boolean isSchemaSupported(String schemaStr) throws ExecutionException,
InterruptedException {
- return isSchemaSupported(ovsdbClient, schema);
+ return isSchemaSupported(ovsdbClient, schemaStr);
}
- public boolean isSchemaSupported (OvsdbClient client, String schema) throws ExecutionException, InterruptedException {
+ public boolean isSchemaSupported(OvsdbClient client, String schemaStr)
+ throws ExecutionException, InterruptedException {
ListenableFuture<List<String>> databases = client.getDatabases();
List<String> dbNames = databases.get();
assertNotNull(dbNames);
- return dbNames.contains(schema);
+ return dbNames.contains(schemaStr);
}
/**
- * As per RFC 7047, section 4.1.5, if a Monitor request is sent without any columns, the update response will not include
- * the _uuid column.
- * ----------------------------------------------------------------------------------------------------------------------------------
- * Each <monitor-request> specifies one or more columns and the manner in which the columns (or the entire table) are to be monitored.
- * The "columns" member specifies the columns whose values are monitored. It MUST NOT contain duplicates.
- * If "columns" is omitted, all columns in the table, except for "_uuid", are monitored.
- * ----------------------------------------------------------------------------------------------------------------------------------
+ * As per RFC 7047, section 4.1.5, if a Monitor request is sent without any columns, the update response will
+ * not include the _uuid column.
+ * ---------------------------------------------------------------------------------------------------------------
+ * Each <monitor-request> specifies one or more columns and the manner in which the columns (or the entire
+ * table) are to be monitored. The "columns" member specifies the columns whose values are monitored. It MUST NOT
+ * contain duplicates. If "columns" is omitted, all columns in the table, except for "_uuid", are monitored.
+ * ---------------------------------------------------------------------------------------------------------------
* In order to overcome this limitation, this method
*
* @return MonitorRequest that includes all the Bridge Columns including _uuid
*/
- public <T extends TypedBaseTable<GenericTableSchema>> MonitorRequest getAllColumnsMonitorRequest (Class <T> klazz) {
+ public <T extends TypedBaseTable<GenericTableSchema>> MonitorRequest getAllColumnsMonitorRequest(Class<T> klazz) {
TypedBaseTable<GenericTableSchema> table = getClient().createTypedRowWrapper(klazz);
GenericTableSchema tableSchema = table.getSchema();
Set<String> columns = tableSchema.getColumns();
return bridgeBuilder.with(new MonitorSelect(true, true, true, true)).build();
}
- public <T extends TableSchema<T>> MonitorRequest getAllColumnsMonitorRequest (T tableSchema) {
+ public <T extends TableSchema<T>> MonitorRequest getAllColumnsMonitorRequest(T tableSchema) {
Set<String> columns = tableSchema.getColumns();
MonitorRequestBuilder<T> monitorBuilder = new MonitorRequestBuilder<>(tableSchema);
for (String column : columns) {
return monitorBuilder.with(new MonitorSelect(true, true, true, true)).build();
}
- public boolean monitorTables () throws ExecutionException, InterruptedException, IOException {
+ public boolean monitorTables() throws ExecutionException, InterruptedException, IOException {
if (monitorReady) {
LOG.info("Monitoring is already initialized.");
return monitorReady;
@SuppressWarnings("unchecked")
protected void updateTableCache(TableUpdates updates) {
for (String tableName : updates.getUpdates().keySet()) {
- Map<UUID, Row> tUpdate = getTableCache().get(tableName);
+ Map<UUID, Row> rowUpdates = getTableCache().get(tableName);
TableUpdate update = updates.getUpdates().get(tableName);
for (UUID uuid : (Set<UUID>)update.getRows().keySet()) {
if (update.getNew(uuid) != null) {
- if (tUpdate == null) {
- tUpdate = new HashMap<>();
- getTableCache().put(tableName, tUpdate);
+ if (rowUpdates == null) {
+ rowUpdates = new HashMap<>();
+ getTableCache().put(tableName, rowUpdates);
}
- tUpdate.put(uuid, update.getNew(uuid));
+ rowUpdates.put(uuid, update.getNew(uuid));
} else {
- tUpdate.remove(uuid);
+ rowUpdates.remove(uuid);
}
}
}
}
- public List<OperationResult> executeTransaction (TransactionBuilder transactionBuilder, String text)
+ public List<OperationResult> executeTransaction(TransactionBuilder transactionBuilder, String text)
throws ExecutionException, InterruptedException {
ListenableFuture<List<OperationResult>> results = transactionBuilder.execute();
List<OperationResult> operationResults = results.get();
return operationResults;
}
+ @Override
public void setup() throws Exception {
if (getSetup()) {
LOG.info("Skipping setUp, already initialized");
return;
}
- try {
- super.setup();
- } catch (Exception e) {
- LOG.warn("Failed to setup test", e);
- fail("Failed to setup test: " + e);
- }
+ super.setup();
assertNotNull("ProviderContext was not found", getProviderContext());
if (schema.equals(LibraryIntegrationTestUtils.OPEN_VSWITCH)) {
return;
}
- try {
- super.setup();
- } catch (Exception e) {
- LOG.warn("Failed to setup test", e);
- fail("Failed to setup test: " + e);
- }
+ super.setup();
assertNotNull("ProviderContext was not found", getProviderContext());
setSetup(true);
private class UpdateMonitor implements MonitorCallBack {
@Override
- public void update(TableUpdates result, DatabaseSchema dbSchema) {
+ public void update(TableUpdates result, DatabaseSchema unused) {
updateTableCache(result);
}
@Override
- public void exception(Throwable t) {
- LOG.error("Exception t = " + t);
+ public void exception(Throwable ex) {
+ LOG.error("Exception t = " + ex);
}
}
}
import java.io.IOException;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
public static final String SERVER_PORT = "ovsdbserver.port";
public static final String CONNECTION_TYPE = "ovsdbserver.connection";
- public final static String OPEN_VSWITCH = "Open_vSwitch";
- public final static String HARDWARE_VTEP = "hardware_vtep";
+ public static final String OPEN_VSWITCH = "Open_vSwitch";
+ public static final String HARDWARE_VTEP = "hardware_vtep";
private static final String CONNECTION_TYPE_ACTIVE = "active";
private static final String CONNECTION_TYPE_PASSIVE = "passive";
private static final String DEFAULT_SERVER_PORT = "6640";
InetAddress address;
try {
address = InetAddress.getByName(addressStr);
- } catch (Exception e) {
+ } catch (UnknownHostException e) {
LOG.warn("Unable to resolve {}", addressStr, e);
return null;
}
private static class PassiveListener implements Callable<OvsdbClient>, OvsdbConnectionListener {
OvsdbClient client = null;
+
@Override
public OvsdbClient call() throws Exception {
OvsdbConnection connection = (OvsdbConnection)ServiceHelper.getGlobalInstance(OvsdbConnection.class, this);
}
@Override
- public void connected(OvsdbClient client) {
- this.client = client;
+ public void connected(OvsdbClient newClient) {
+ this.client = newClient;
}
@Override
- public void disconnected(OvsdbClient client) {
- if (!Objects.equals(this.client.getConnectionInfo(), client.getConnectionInfo())) {
+ public void disconnected(OvsdbClient newClient) {
+ if (!Objects.equals(this.client.getConnectionInfo(), newClient.getConnectionInfo())) {
throw new IllegalStateException("disconnected unexpected client");
}
this.client = null;
import org.slf4j.LoggerFactory;
/**
- * Integration tests for southbound-impl
+ * Integration tests for southbound-impl.
*
* @author Sam Hague (shague@redhat.com)
*/
private static Node ovsdbNode;
private static int testMethodsRemaining;
private static Version schemaVersion;
- @Inject @Filter(timeout=60000)
+ @Inject @Filter(timeout = 60000)
private static DataBroker dataBroker = null;
@Inject
new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL);
- private static class NotifyingDataChangeListener implements DataTreeChangeListener<DataObject> {
+ private static final class NotifyingDataChangeListener implements DataTreeChangeListener<DataObject> {
+ private static final int RETRY_WAIT = 100;
+
private final LogicalDatastoreType type;
private final Set<InstanceIdentifier<?>> createdIids = new HashSet<>();
private final Set<InstanceIdentifier<?>> removedIids = new HashSet<>();
private final Set<InstanceIdentifier<?>> updatedIids = new HashSet<>();
private final InstanceIdentifier<?> iid;
- private final int RETRY_WAIT = 100;
private NotifyingDataChangeListener(LogicalDatastoreType type) {
this.type = type;
}
}
- synchronized(this) {
+ synchronized (this) {
notifyAll();
}
}
- public boolean isCreated(InstanceIdentifier<?> iid) {
- return createdIids.remove(iid);
+ public boolean isCreated(InstanceIdentifier<?> path) {
+ return createdIids.remove(path);
}
- public boolean isRemoved(InstanceIdentifier<?> iid) {
- return removedIids.remove(iid);
+ public boolean isRemoved(InstanceIdentifier<?> path) {
+ return removedIids.remove(path);
}
- public boolean isUpdated(InstanceIdentifier<?> iid) {
- return updatedIids.remove(iid);
+ public boolean isUpdated(InstanceIdentifier<?> path) {
+ return updatedIids.remove(path);
}
public void clear() {
public void waitForCreation(long timeout) throws InterruptedException {
synchronized (this) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
public void waitForDeletion(long timeout) throws InterruptedException {
synchronized (this) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
public void waitForUpdate(long timeout) throws InterruptedException {
synchronized (this) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
}
private Option[] getPropertiesOptions() {
Properties props = new Properties(System.getProperties());
- String addressStr = props.getProperty(SouthboundITConstants.SERVER_IPADDRESS,
+ String ipAddressStr = props.getProperty(SouthboundITConstants.SERVER_IPADDRESS,
SouthboundITConstants.DEFAULT_SERVER_IPADDRESS);
String portStr = props.getProperty(SouthboundITConstants.SERVER_PORT,
SouthboundITConstants.DEFAULT_SERVER_PORT);
- String connectionType = props.getProperty(SouthboundITConstants.CONNECTION_TYPE,
+ String connectionTypeStr = props.getProperty(SouthboundITConstants.CONNECTION_TYPE,
SouthboundITConstants.CONNECTION_TYPE_ACTIVE);
LOG.info("getPropertiesOptions: Using the following properties: mode= {}, ip:port= {}:{}",
- connectionType, addressStr, portStr);
+ connectionTypeStr, ipAddressStr, portStr);
return new Option[] {
propagateSystemProperties(
SouthboundITConstants.SERVER_PORT,
SouthboundITConstants.CONNECTION_TYPE),
editConfigurationFilePut(SouthboundITConstants.CUSTOM_PROPERTIES,
- SouthboundITConstants.SERVER_IPADDRESS, addressStr),
+ SouthboundITConstants.SERVER_IPADDRESS, ipAddressStr),
editConfigurationFilePut(SouthboundITConstants.CUSTOM_PROPERTIES,
SouthboundITConstants.SERVER_PORT, portStr),
editConfigurationFilePut(SouthboundITConstants.CUSTOM_PROPERTIES,
- SouthboundITConstants.CONNECTION_TYPE, connectionType),
+ SouthboundITConstants.CONNECTION_TYPE, connectionTypeStr),
};
}
@Before
@Override
- public void setup() throws InterruptedException {
+ public void setup() throws Exception {
if (setup) {
LOG.info("Skipping setup, already initialized");
return;
}
- try {
- super.setup();
- } catch (Exception e) {
- LOG.warn("Failed to setup test", e);
- }
+ super.setup();
Assert.assertNotNull("db should not be null", dataBroker);
LOG.info("sleeping for 10s to let the features finish installing");
/**
* Test passive connection mode. The southbound starts in a listening mode waiting for connections on port
* 6640. This test will wait for incoming connections for {@link SouthboundITConstants#CONNECTION_INIT_TIMEOUT} ms.
- *
- * @throws InterruptedException
*/
@Test
public void testPassiveNode() throws InterruptedException {
}
}
- private static ConnectionInfo getConnectionInfo(final String addressStr, final int portNumber) {
+ private static ConnectionInfo getConnectionInfo(final String ipAddressStr, final int portNum) {
InetAddress inetAddress = null;
try {
- inetAddress = InetAddress.getByName(addressStr);
+ inetAddress = InetAddress.getByName(ipAddressStr);
} catch (UnknownHostException e) {
- fail("Could not resolve " + addressStr + ": " + e);
+ fail("Could not resolve " + ipAddressStr + ": " + e);
}
IpAddress address = SouthboundMapper.createIpAddress(inetAddress);
- PortNumber port = new PortNumber(portNumber);
+ PortNumber port = new PortNumber(portNum);
final ConnectionInfo connectionInfo = new ConnectionInfoBuilder()
.setRemoteIp(address)
private void waitForOperationalCreation(InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
private static void waitForOperationalDeletion(InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
private void waitForOperationalUpdate(InstanceIdentifier<Node> iid) throws InterruptedException {
synchronized (OPERATIONAL_LISTENER) {
- long _start = System.currentTimeMillis();
+ 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);
}
}
//dpdkTypes.add("dpdkvhost");
for (String dpdkType : dpdkTypes) {
- String testPortname = "test"+dpdkType+"port";
+ 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);
// Verify that each termination point has the specific DPDK ifType
for (String dpdkType : dpdkTypes) {
- String testPortname = "test"+dpdkType+"port";
+ String testPortname = "test" + dpdkType + "port";
Class<? extends InterfaceTypeBase> dpdkIfType = SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP
.get(dpdkType);
List<TerminationPoint> terminationPoints = terminationPointNode.getTerminationPoint();
* @param externalIds The external identifiers if any.
* @param otherConfigs The other configuration items if any.
*/
- public TestBridge(final ConnectionInfo connectionInfo, @Nullable InstanceIdentifier<Node> bridgeIid,
+ TestBridge(final ConnectionInfo connectionInfo, @Nullable InstanceIdentifier<Node> bridgeIid,
final String bridgeName, NodeId bridgeNodeId, final boolean setProtocolEntries,
final Class<? extends OvsdbFailModeBase> failMode, final boolean setManagedBy,
@Nullable final Class<? extends DatapathTypeBase> dpType,
}
}
- public TestBridge(final ConnectionInfo connectionInfo, final String bridgeName) {
+ TestBridge(final ConnectionInfo connectionInfo, final String bridgeName) {
this(connectionInfo, null, bridgeName, null, true,
SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null, null, null);
}
private final Uri autoattachId;
private final Uri bridgeId;
- public TestAutoAttach (final ConnectionInfo connectionInfo,
+ TestAutoAttach(final ConnectionInfo connectionInfo,
final Uri autoattachId,
final Uri bridgeId,
@Nullable final String systemName,
LOG.warn("Sleep interrupted while waiting for queue {}", iid, e);
}
}
+
@Override
public void close() {
final InstanceIdentifier<Autoattach> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
String bridgeId = nodeId.getValue();
- try(TestAutoAttach testAutoattach = new TestAutoAttach(connectionInfo, new Uri(testAutoattachId),
+ try (TestAutoAttach testAutoattach = new TestAutoAttach(connectionInfo, new Uri(testAutoattachId),
new Uri(bridgeId), testSystemName, testSystemDescription, null, null)) {
// READ: Read md-sal operational datastore to see if the AutoAttach table was created
// and if Bridge table was updated with AutoAttach Uuid
Assert.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());
+ List<Mappings> mappings = ImmutableList.of(new MappingsBuilder().setMappingsKey(100L)
+ .setMappingsValue(200).build());
Autoattach updatedAa = new AutoattachBuilder()
.setAutoattachId(new Uri(testAutoattachId))
.setMappings(mappings)
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());
+ Assert.assertEquals(mappings.get(operMappingsList.indexOf(operMappings))
+ .getMappingsKey(), operMappings.getMappingsKey());
+ Assert.assertEquals(mappings.get(operMappingsList.indexOf(operMappings))
+ .getMappingsValue(), operMappings.getMappingsValue());
}
List<AutoattachExternalIds> operExternalIds = operAa.getAutoattachExternalIds();
externalIds.add(new AutoattachExternalIdsBuilder()
.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());
+ Assert.assertEquals(externalIds.get(operExternalIds.indexOf(operExternalId))
+ .getAutoattachExternalIdKey(), operExternalId.getAutoattachExternalIdKey());
+ Assert.assertEquals(externalIds.get(operExternalIds.indexOf(operExternalId))
+ .getAutoattachExternalIdValue(), operExternalId.getAutoattachExternalIdValue());
}
// DELETE: Delete AutoAttach table
Assert.assertNull(operAa);
} catch (AssumptionViolatedException e) {
LOG.warn("Skipped test for Autoattach due to unsupported schema", e);
- } catch (Exception e) {
- fail("Unexpected exception in CRUD test for Autoattach table for schema:" + schemaVersion.toString() +". " + e);
}
}
}
* @param externalIds The external identifiers if any.
* @param otherConfigs The other configuration items if any.
*/
- public TestQos(final ConnectionInfo connectionInfo,
+ TestQos(final ConnectionInfo connectionInfo,
final Uri qosId,
final Class<? extends QosTypeBase> qosType,
@Nullable final List<QosExternalIds> externalIds,
private static class TestQueue implements AutoCloseable {
private final ConnectionInfo connectionInfo;
private final Uri queueId;
- private final InstanceIdentifier<Queues> qIid;
+ private final InstanceIdentifier<Queues> queueIid;
/**
* Creates a test queue entry which can be automatically removed when no longer necessary.
* @param externalIds The external identifiers if any.
* @param otherConfigs The other configuration items if any.
*/
- public TestQueue(final ConnectionInfo connectionInfo,
+ TestQueue(final ConnectionInfo connectionInfo,
final Uri queueId,
final Short queueDscp,
@Nullable final List<QueuesExternalIds> externalIds,
.setQueuesExternalIds(externalIds)
.setQueuesOtherConfig(otherConfigs)
.build();
- qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
+ queueIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
.augmentation(OvsdbNodeAugmentation.class)
.child(Queues.class, queue.getKey());
final NotifyingDataChangeListener queueOperationalListener =
- new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, qIid);
+ new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, queueIid);
queueOperationalListener.registerDataChangeListener();
Assert.assertTrue(
mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION,
- qIid, queue));
+ queueIid, queue));
try {
queueOperationalListener.waitForCreation(OVSDB_ROUNDTRIP_TIMEOUT);
}
public InstanceIdentifier<Queues> getInstanceIdentifier() {
- return qIid;
+ return queueIid;
}
+
@Override
public void close() {
- InstanceIdentifier<Queues> qIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
+ InstanceIdentifier<Queues> queuesIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
.augmentation(OvsdbNodeAugmentation.class)
.child(Queues.class, new QueuesKey(this.queueId));
final NotifyingDataChangeListener queueOperationalListener =
- new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, qIid);
+ new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, queuesIid);
queueOperationalListener.registerDataChangeListener();
- Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, qIid));
+ Assert.assertTrue(mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, queuesIid));
try {
queueOperationalListener.waitForDeletion(OVSDB_ROUNDTRIP_TIMEOUT);
} catch (InterruptedException e) {
/**
* extract the <code>LogicalDataStoreType.OPERATIONAL</code> type data store contents for the particular bridge
- * identified by <code>bridgeName</code>
+ * identified by <code>bridgeName</code>.
*
* @param connectionInfo the connection information
* @param bridgeName the bridge name
/**
* Extract the node contents from <code>store</code> type data store for the
- * bridge identified by <code>bridgeName</code>
+ * bridge identified by <code>bridgeName</code>.
*
* @param connectionInfo the connection information
* @param bridgeName the bridge name
/**
* Extract the node contents from <code>LogicalDataStoreType.OPERATIONAL</code> data store for the
- * bridge identified by <code>bridgeName</code>
+ * bridge identified by <code>bridgeName</code>.
*
* @param connectionInfo the connection information
* @param bridgeName the bridge name
/**
* Extracts the <code>TerminationPointAugmentation</code> for the <code>index</code> <code>TerminationPoint</code>
- * on <code>bridgeName</code>
+ * on <code>bridgeName</code>.
*
* @param connectionInfo the connection information
* @param bridgeName the bridge name
@Test
public void testCRDTerminationPointOfPort() throws InterruptedException {
- final Long OFPORT_EXPECTED = 45002L;
+ final Long ofportExpected = 45002L;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
String portName = "testOfPort";
ovsdbTerminationBuilder.setName(portName);
- ovsdbTerminationBuilder.setOfport(OFPORT_EXPECTED);
+ ovsdbTerminationBuilder.setOfport(ofportExpected);
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
Long ofPort = ovsdbTerminationPointAugmentation.getOfport();
// if ephemeral port 45002 is in use, ofPort is set to 1
- Assert.assertTrue(ofPort.equals(OFPORT_EXPECTED) || ofPort.equals(1L));
+ Assert.assertTrue(ofPort.equals(ofportExpected) || ofPort.equals(1L));
LOG.info("ofPort: {}", ofPort);
}
}
// UPDATE- Not Applicable. From the OpenVSwitch Documentation:
- // "A client should ideally set this column’s value in the same database transaction that it uses to create
- // the interface."
+ // "A client should ideally set this column’s value in the same database transaction that it uses to
+ // create the interface."
// DELETE handled by TestBridge
}
@Test
public void testCRDTerminationPointOfPortRequest() throws InterruptedException {
- final Long OFPORT_EXPECTED = 45008L;
- final Long OFPORT_INPUT = 45008L;
+ final Long ofportExpected = 45008L;
+ final Long ofportInput = 45008L;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
try (TestBridge testBridge = new TestBridge(connectionInfo, SouthboundITConstants.BRIDGE_NAME)) {
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
Assert.assertNotNull(bridge);
- NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
+ final NodeId nodeId = SouthboundUtils.createManagedNodeId(SouthboundUtils.createInstanceIdentifier(
connectionInfo, bridge.getBridgeName()));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationBuilder =
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testOfPortRequest";
ovsdbTerminationBuilder.setName(portName);
- Integer ofPortRequestExpected = OFPORT_EXPECTED.intValue();
- ovsdbTerminationBuilder.setOfport(OFPORT_INPUT);
+ Integer ofPortRequestExpected = ofportExpected.intValue();
+ ovsdbTerminationBuilder.setOfport(ofportInput);
ovsdbTerminationBuilder.setOfportRequest(ofPortRequestExpected);
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
Long ofPort = ovsdbTerminationPointAugmentation.getOfport();
// if ephemeral port 45008 is in use, ofPort is set to 1
- Assert.assertTrue(ofPort.equals(OFPORT_EXPECTED) || ofPort.equals(1L));
+ Assert.assertTrue(ofPort.equals(ofportExpected) || ofPort.equals(1L));
LOG.info("ofPort: {}", ofPort);
Integer ofPortRequest = ovsdbTerminationPointAugmentation.getOfportRequest();
private interface SouthboundTerminationPointHelper<T> {
void writeValues(OvsdbTerminationPointAugmentationBuilder builder, List<T> values);
+
List<T> readValues(OvsdbTerminationPointAugmentation augmentation);
}
private <T> void testCRUDTerminationPoint(
KeyValueBuilder<T> builder, String prefix, SouthboundTerminationPointHelper<T> helper)
throws InterruptedException {
- final int TERMINATION_POINT_TEST_INDEX = 0;
+ final int terminationPointTestIndex = 0;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
// then repeat for OPERATIONAL data store
OvsdbTerminationPointAugmentation updateFromConfigurationTerminationPointAugmentation =
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ LogicalDatastoreType.CONFIGURATION, terminationPointTestIndex);
if (updateFromConfigurationTerminationPointAugmentation != null) {
List<T> updateFromConfigurationValues =
helper.readValues(updateFromConfigurationTerminationPointAugmentation);
}
OvsdbTerminationPointAugmentation updateFromOperationalTerminationPointAugmentation =
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ LogicalDatastoreType.OPERATIONAL, terminationPointTestIndex);
if (updateFromOperationalTerminationPointAugmentation != null) {
List<T> updateFromOperationalValues =
helper.readValues(updateFromOperationalTerminationPointAugmentation);
// then repeat for OPERATIONAL data store
OvsdbTerminationPointAugmentation updateToConfigurationTerminationPointAugmentation =
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
- LogicalDatastoreType.CONFIGURATION, TERMINATION_POINT_TEST_INDEX);
+ LogicalDatastoreType.CONFIGURATION, terminationPointTestIndex);
if (updateToConfigurationTerminationPointAugmentation != null) {
List<T> updateToConfigurationValues =
helper.readValues(updateToConfigurationTerminationPointAugmentation);
}
OvsdbTerminationPointAugmentation updateToOperationalTerminationPointAugmentation =
getOvsdbTerminationPointAugmentation(connectionInfo, testBridgeAndPortName,
- LogicalDatastoreType.OPERATIONAL, TERMINATION_POINT_TEST_INDEX);
+ LogicalDatastoreType.OPERATIONAL, terminationPointTestIndex);
if (updateToOperationalTerminationPointAugmentation != null) {
List<T> updateToOperationalValues =
helper.readValues(updateToOperationalTerminationPointAugmentation);
@Test
public void testCRUDTerminationPointVlan() throws InterruptedException {
- final Integer CREATED_VLAN_ID = 4000;
- final Integer UPDATED_VLAN_ID = 4001;
+ final Integer createdVlanId = 4000;
+ final Integer updatedVlanId = 4001;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
createGenericOvsdbTerminationPointAugmentationBuilder();
String portName = "testTerminationPointVlanId";
ovsdbTerminationBuilder.setName(portName);
- ovsdbTerminationBuilder.setVlanTag(new VlanId(CREATED_VLAN_ID));
+ ovsdbTerminationBuilder.setVlanTag(new VlanId(createdVlanId));
Assert.assertTrue(addTerminationPoint(nodeId, portName, ovsdbTerminationBuilder));
InstanceIdentifier<Node> terminationPointIid = getTpIid(connectionInfo, bridge);
Node terminationPointNode = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, terminationPointIid);
VlanId actualVlanId = ovsdbTerminationPointAugmentation.getVlanTag();
Assert.assertNotNull(actualVlanId);
Integer actualVlanIdInt = actualVlanId.getValue();
- Assert.assertEquals(CREATED_VLAN_ID, actualVlanIdInt);
+ Assert.assertEquals(createdVlanId, actualVlanIdInt);
}
}
NodeId testBridgeNodeId = getBridgeNode(connectionInfo, SouthboundITConstants.BRIDGE_NAME).getNodeId();
OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
new OvsdbTerminationPointAugmentationBuilder();
- tpUpdateAugmentationBuilder.setVlanTag(new VlanId(UPDATED_VLAN_ID));
+ tpUpdateAugmentationBuilder.setVlanTag(new VlanId(updatedVlanId));
InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
NodeId portUpdateNodeId = SouthboundUtils.createManagedNodeId(portIid);
VlanId actualVlanId = ovsdbTerminationPointAugmentation.getVlanTag();
Assert.assertNotNull(actualVlanId);
Integer actualVlanIdInt = actualVlanId.getValue();
- Assert.assertEquals(UPDATED_VLAN_ID, actualVlanIdInt);
+ Assert.assertEquals(updatedVlanId, actualVlanIdInt);
}
}
@Test
public void testCRUDTerminationPointVlanModes() throws InterruptedException {
- final VlanMode UPDATED_VLAN_MODE = VlanMode.Access;
+ final VlanMode updatedVlanMode = VlanMode.Access;
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
VlanMode []vlanModes = VlanMode.values();
for (VlanMode vlanMode : vlanModes) {
NodeId testBridgeNodeId = getBridgeNode(connectionInfo, SouthboundITConstants.BRIDGE_NAME).getNodeId();
OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
new OvsdbTerminationPointAugmentationBuilder();
- tpUpdateAugmentationBuilder.setVlanMode(UPDATED_VLAN_MODE);
+ tpUpdateAugmentationBuilder.setVlanMode(updatedVlanMode);
InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
NodeId portUpdateNodeId = SouthboundUtils.createManagedNodeId(portIid);
terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
//test
- Assert.assertEquals(UPDATED_VLAN_MODE, ovsdbTerminationPointAugmentation.getVlanMode());
+ Assert.assertEquals(updatedVlanMode, ovsdbTerminationPointAugmentation.getVlanMode());
}
}
}
}
- @SuppressWarnings("unchecked")
private List<Set<Integer>> generateVlanSets() {
int min = 0;
int max = 4095;
@Test
public void testCRUDTerminationPointVlanTrunks() throws InterruptedException {
- final List<Trunks> UPDATED_TRUNKS = buildTrunkList(Collections.singleton(2011));
+ final List<Trunks> updatedTrunks = buildTrunkList(Collections.singleton(2011));
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
Iterable<Set<Integer>> vlanSets = generateVlanSets();
int testCase = 0;
NodeId testBridgeNodeId = getBridgeNode(connectionInfo, SouthboundITConstants.BRIDGE_NAME).getNodeId();
OvsdbTerminationPointAugmentationBuilder tpUpdateAugmentationBuilder =
new OvsdbTerminationPointAugmentationBuilder();
- tpUpdateAugmentationBuilder.setTrunks(UPDATED_TRUNKS);
+ tpUpdateAugmentationBuilder.setTrunks(updatedTrunks);
InstanceIdentifier<Node> portIid = SouthboundMapper.createInstanceIdentifier(testBridgeNodeId);
NodeBuilder portUpdateNodeBuilder = new NodeBuilder();
NodeId portUpdateNodeId = SouthboundUtils.createManagedNodeId(portIid);
terminationPoint.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTerminationPointAugmentation.getName().equals(portName)) {
//test
- Assert.assertEquals(UPDATED_TRUNKS, ovsdbTerminationPointAugmentation.getTrunks());
+ Assert.assertEquals(updatedTrunks, ovsdbTerminationPointAugmentation.getTrunks());
}
}
LogicalDatastoreType.OPERATIONAL);
QosEntries operQos = getQos(new Uri(testQosId), ovsdbNodeAugmentation);
Assert.assertNotNull(operQos);
- Uuid qosUuid = new Uuid(operQos.getQosUuid().getValue());
-
OvsdbBridgeAugmentation bridge = getBridge(connectionInfo);
Assert.assertNotNull(bridge);
NodeId nodeId = SouthboundUtils.createManagedNodeId(connectionInfo, bridge.getBridgeName());
private interface SouthboundBridgeHelper<T> {
void writeValues(OvsdbBridgeAugmentationBuilder builder, List<T> values);
+
List<T> readValues(OvsdbBridgeAugmentation augmentation);
}
typeList.add(SouthboundConstants.QOS_LINUX_HFSC);
for (String qosType : typeList) {
- try (TestQos testQos = new TestQos(connectionInfo, qosUri, SouthboundMapper.createQosType(qosType), null, null)) {
+ try (TestQos testQos = new TestQos(connectionInfo, qosUri, SouthboundMapper.createQosType(qosType),
+ null, null)) {
ovsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.OPERATIONAL);
QosEntries operQosHtb = getQos(qosUri, ovsdbNodeAugmentation);
private interface SouthboundQueueHelper<T> {
void writeValues(QueuesBuilder builder, List<T> values);
+
List<T> readValues(Queues queue);
}
private interface SouthboundQosHelper<T> {
void writeValues(QosEntriesBuilder builder, List<T> values);
+
List<T> readValues(QosEntries qos);
}
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)) {
+ try (TestQueue testQueue = new TestQueue(connectionInfo, new Uri(testQueueId),
+ new Short("45"), null, null)) {
QueuesBuilder queuesBuilder = new QueuesBuilder();
queuesBuilder.setQueueId(new Uri(testQueueId));
InstanceIdentifier<Queues> queueIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
// then repeat for OPERATIONAL data store
OvsdbNodeAugmentation updateFromConfigurationOvsdbNodeAugmentation = getOvsdbNode(connectionInfo,
LogicalDatastoreType.CONFIGURATION);
- Queues queueFromConfig = getQueue(new Uri(testQueueId), updateFromConfigurationOvsdbNodeAugmentation);
+ Queues queueFromConfig =
+ getQueue(new Uri(testQueueId), updateFromConfigurationOvsdbNodeAugmentation);
if (queueFromConfig != null) {
List<T> updateFromConfigurationValues =
helper.readValues(queueFromConfig);
String testQosId = String.format("%s_%s", prefix, updateToTestCase.name);
// CREATE: and update the test qos with starting values.
- try (TestQos testQos = new TestQos(connectionInfo, new Uri(testQosId), SouthboundMapper.createQosType(SouthboundConstants.QOS_LINUX_HTB), null, null)) {
+ try (TestQos testQos = new TestQos(connectionInfo, new Uri(testQosId),
+ SouthboundMapper.createQosType(SouthboundConstants.QOS_LINUX_HTB), null, null)) {
QosEntriesBuilder qosBuilder = new QosEntriesBuilder();
qosBuilder.setQosId(new Uri(testQosId));
InstanceIdentifier<QosEntries> qosIid = SouthboundUtils.createInstanceIdentifier(connectionInfo)
testCRUDQos(new SouthboundQosOtherConfigBuilder(), "QosOtherConfig",
new SouthboundQosOtherConfigHelper());
}
+
@Test
public void testCRUDQosQueues() throws InterruptedException {
ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portNumber);
private Boolean isQueueInList(List<QueueList> queueList, QueueList queue) {
for (QueueList queueEntry : queueList) {
- if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())&& queueEntry.getQueueRef().equals(queue.getQueueRef())) {
+ if (queueEntry.getQueueNumber().equals(queue.getQueueNumber())
+ && queueEntry.getQueueRef().equals(queue.getQueueRef())) {
return true;
}
}
* @param inputValues The input values (provided as input to the underlying augmentation builder).
* @param expectedValues The expected values (checked against the output of the underlying augmentation).
*/
- public SouthboundTestCase(
- final String name, final List<T> inputValues, final List<T> expectedValues) {
+ SouthboundTestCase(final String name, final List<T> inputValues, final List<T> expectedValues) {
this.name = name;
this.inputValues = inputValues;
this.expectedValues = expectedValues;
* Creates a builder. Builders may be reused, the generated immutable instances are independent of the
* builders. There are no default values.
*/
- public SouthboundTestCaseBuilder() {
+ SouthboundTestCaseBuilder() {
// Nothing to do
}
/**
* Sets the test case's name.
*
- * @param name The test case's name.
+ * @param value The test case's name.
* @return The builder.
*/
- public SouthboundTestCaseBuilder<T> name(final String name) {
- this.name = name;
+ public SouthboundTestCaseBuilder<T> name(final String value) {
+ this.name = value;
return this;
}
/**
* Sets the input values.
*
- * @param inputValues The input values.
+ * @param values The input values.
* @return The builder.
*/
@SafeVarargs
- public final SouthboundTestCaseBuilder<T> input(final T... inputValues) {
- this.inputValues = Lists.newArrayList(inputValues);
+ public final SouthboundTestCaseBuilder<T> input(final T... values) {
+ this.inputValues = Lists.newArrayList(values);
return this;
}
*
* @return The test case.
*/
- @SuppressWarnings("unchecked")
public SouthboundTestCase<T> build() {
return new SouthboundTestCase<>(name, inputValues, expectedValues);
}
KeyValueBuilder<T> builder, String testName) {
List<SouthboundTestCase<T>> testCases = new ArrayList<>();
- final String GOOD_KEY = "GoodKey";
- final String GOOD_VALUE = "GoodValue";
- final String NO_VALUE_FOR_KEY = "NoValueForKey";
+ final String goodKey = "GoodKey";
+ final String goodValue = "GoodValue";
+ final String noValueForKey = "NoValueForKey";
final String idKey = testName + "Key";
final String idValue = testName + "Value";
testCases.add(new SouthboundTestCaseBuilder<T>()
.name(testOneGoodOneMalformedValueName)
.input(
- builder.build(testOneGoodOneMalformedValueName, GOOD_KEY, GOOD_VALUE),
- builder.build(testOneGoodOneMalformedValueName, NO_VALUE_FOR_KEY, null))
+ builder.build(testOneGoodOneMalformedValueName, goodKey, goodValue),
+ builder.build(testOneGoodOneMalformedValueName, noValueForKey, null))
.expectNoOutput()
.build());
builder.reset();
}
}
- private static class InterfaceLldpSouthboundHelper implements
- SouthboundTerminationPointHelper<InterfaceLldp> {
+ private static class InterfaceLldpSouthboundHelper implements SouthboundTerminationPointHelper<InterfaceLldp> {
@Override
public void writeValues(
OvsdbTerminationPointAugmentationBuilder builder, List<InterfaceLldp> values) {
package org.opendaylight.ovsdb.southbound.it;
/**
- * Constants for SouthboundIT
+ * Constants for SouthboundIT.
*/
-public final class SouthboundITConstants {
- private SouthboundITConstants() {
- throw new AssertionError("This class should not be instantiated.");
- }
-
- public static final String ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg";
- public static final String CUSTOM_PROPERTIES = "etc/custom.properties";
- public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
- public static final String SERVER_PORT = "ovsdbserver.port";
- public static final String CONNECTION_TYPE = "ovsdbserver.connection";
- public static final String CONNECTION_TYPE_ACTIVE = "active";
- public static final String CONNECTION_TYPE_PASSIVE = "passive";
- public static final int CONNECTION_INIT_TIMEOUT = 10000;
- public static final String DEFAULT_SERVER_IPADDRESS = "127.0.0.1";
- public static final String DEFAULT_SERVER_PORT = "6640";
- public static final String DEFAULT_OPENFLOW_PORT = "6653";
- public static final String BRIDGE_NAME = "brtest";
- public static final String OPENFLOW_CONNECTION_PROTOCOL = "tcp";
+public interface SouthboundITConstants {
+ String ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg";
+ String CUSTOM_PROPERTIES = "etc/custom.properties";
+ String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
+ String SERVER_PORT = "ovsdbserver.port";
+ String CONNECTION_TYPE = "ovsdbserver.connection";
+ String CONNECTION_TYPE_ACTIVE = "active";
+ String CONNECTION_TYPE_PASSIVE = "passive";
+ int CONNECTION_INIT_TIMEOUT = 10000;
+ String DEFAULT_SERVER_IPADDRESS = "127.0.0.1";
+ String DEFAULT_SERVER_PORT = "6640";
+ String DEFAULT_OPENFLOW_PORT = "6653";
+ String BRIDGE_NAME = "brtest";
+ String OPENFLOW_CONNECTION_PROTOCOL = "tcp";
}