@Override
public NeutronPort getPort(String uuid) {
if (uuid.equals("C387EB44-7832-49F4-B9F0-D30D27770883")) {
+ //Setting all IDs(TenantID, SwitchID, PortID) to NULL
NeutronPort neutron = new NeutronPort();
return neutron;
+ } else if (uuid.equals("D387EB44-7832-49F4-B9F0-D30D27770884")) {
+ //Setting SwitchID and PortID to NULL
+ NeutronPort neutron = new NeutronPort();
+ neutron.setTenantID("D387EB44-7832-49F4-B9F0-D30D27770885");
+ return neutron;
+ } else if (uuid.equals("4790F3C1-AB34-4ABC-B7A5-C1B5C7202389")) {
+ //Setting PortID to NULL
+ NeutronPort neutron = new NeutronPort();
+ neutron.setTenantID("E6E005D3A24542FCB03897730A5150E2");
+ neutron.setNetworkUUID("5e7e0900-f215-11e3-aa76-0002a5d5c51b");
+ return neutron;
} else if (uuid.equals("4790F3C1-AB34-4ABC-B7A5-C1B5C7202389")) {
NeutronPort neutron = new NeutronPort();
neutron.setTenantID("E6E005D3A24542FCB03897730A5150E2");
bridge.setName("invalid Bridge name");
boolean isValidPeNodeIdOf5 = false;
- if ((String.valueOf(node.getID()).length() == UUID_LEN)
- && (NODE_ID_2.equalsIgnoreCase(String.valueOf(Long.parseLong(String.valueOf(node.getID()).substring(UUID_POSITION_IN_NODE), HEX_RADIX))))) {
+ if (NODE_ID_2.equalsIgnoreCase(node.getID().toString())) {
isValidPeNodeIdOf5 = true;
}
- if ((NODE_ID_1.equalsIgnoreCase(String.valueOf(node.getID())))
- || (isValidPeNodeIdOf5)) {
- bridge.setName("br-int");
- }
+ try {
+ if ((isValidPeNodeIdOf5)
+ || (NODE_ID_1.equalsIgnoreCase(Long.toHexString(Long.parseLong(node.getID().toString()))))) {
+ bridge.setName("br-int");
+ }
+ } catch (Exception e) { }
return (T)bridge;
}
if (OPENFLOW.equalsIgnoreCase(createNetwork[NODE_ADD_NODE_TYPE])) {
// String strObj = String.valueOf(Long.parseLong(CREATE_NETWORK[NODE_ADD_NODE_ID]));
- Node nodeObj = new Node(createNetwork[NODE_ADD_NODE_TYPE], Long.parseLong(createNetwork[NODE_ADD_NODE_ID]));
+ Node nodeObj = new Node(createNetwork[NODE_ADD_NODE_TYPE], Long.parseLong(createNetwork[NODE_ADD_NODE_ID], HEX_RADIX));
// ovsdb.prepareInternalNetwork(nodeObj);
ovsdb.nodeAdded(nodeObj, null, 0);
-
} else if ((ONEPK.equalsIgnoreCase(createNetwork[NODE_ADD_NODE_TYPE])) ||
(PRODUCTION.equalsIgnoreCase(createNetwork[NODE_ADD_NODE_TYPE]))) {
// String strNode = String.valueOf(Long.parseLong(CREATE_NETWORK[NODE_ADD_NODE_ID], 16));
Node nodeObj = new Node(createNetwork[NODE_ADD_NODE_TYPE], createNetwork[NODE_ADD_NODE_ID]);
ovsdb.nodeAdded(nodeObj, null, 0);
} else if (PCEP.equalsIgnoreCase(createNetwork[NODE_ADD_NODE_TYPE])) {
- UUID idOne = new UUID(new Long(0), new Long(createNetwork[NODE_ADD_NODE_ID]));
- Node nodeObj = new Node(createNetwork[NODE_ADD_NODE_TYPE], idOne);
+ Node nodeObj = new Node(createNetwork[NODE_ADD_NODE_TYPE], UUID.fromString(createNetwork[NODE_ADD_NODE_ID]));
ovsdb.nodeAdded(nodeObj, null, 0);
}
Interface interfaceBridge = new InterfaceStub();
interfaceBridge.setName(rowUpdate[ROW_UPDATE_NODE_OBJECT_NAME]);
+ if (SET_NULL_TO_NODE.equalsIgnoreCase(rowUpdate[ROW_UPDATE_PARENT_UUID])) {
+ nodeObj = null;
+ }
+
if (rowUpdate[ROW_UPDATE_OLD_ROW].equalsIgnoreCase("null")
&& rowUpdate[ROW_UPDATE_NEW_ROW].equalsIgnoreCase("null")) {
ovsdb.rowUpdated(nodeObj, rowUpdate[ROW_UPDATE_ACTUAL_TABLE_NAME], rowUpdate[ROW_UPDATE_PARENT_UUID], null, null);
OpenVSwitch oldOpenVSwitch = new OpenVSwitchStub();
ovsdb.rowUpdated(nodeObj, isUpdateOfInterest[ROW_UPDATE_ACTUAL_TABLE_NAME], isUpdateOfInterest[ROW_UPDATE_PARENT_UUID], oldOpenVSwitch.getRow(), newOpenVSwitch.getRow());
+ } else if (isUpdateOfInterest[ROW_UPDATE_ACTUAL_TABLE_NAME].equalsIgnoreCase("Bridge")) {
+ Bridge newBridge = new BridgeStub();
+ newBridge.setName(isUpdateOfInterest[ROW_UPDATE_NODE_OBJECT_NAME]);
+
+ Bridge oldBridge = new BridgeStub();
+ oldBridge.setName(isUpdateOfInterest[ROW_UPDATE_NODE_OBJECT_NAME]);
+
+ ovsdb.rowUpdated(nodeObj, isUpdateOfInterest[ROW_UPDATE_ACTUAL_TABLE_NAME], isUpdateOfInterest[ROW_UPDATE_PARENT_UUID], oldBridge.getRow(), newBridge.getRow());
}
ovsdb.unsetOVSDBConfigService(ovsdbConfig);
PortHandler ph = new PortHandler();
ph.setVTNManager(new VTNManagerStub());
- // In the cases that the method returns HTTP_BAD_REQUEST by setting NULL to NeutronPort object.
+ // Failure Case - Method returns HTTP_BAD_REQUEST by setting NULL to NeutronPort object.
NeutronPort port = null;
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canCreatePort(port));
- // In the cases that the method returns HTTP_NOT_FOUND by setting wrong TenantID.
+ // Failure Case - Method returns HTTP_NOT_FOUND by setting wrong TenantID.
port = new NeutronPort();
port.setTenantID(TENANT_ID_ARRAY[0]);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
ph.canCreatePort(port));
- // In the cases that the method returns HTTP_NOT_FOUND by setting wrong NetworkID.
+ // Failure Case - Method returns HTTP_NOT_FOUND by setting wrong NetworkID.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
ph.canCreatePort(port));
- // In the cases that the method returns HTTP_CONFLICT.
+ // Failure Case - Method returns HTTP_CONFLICT by setting existing UUID to Port UUID
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
assertEquals(HttpURLConnection.HTTP_CONFLICT,
ph.canCreatePort(port));
- // In the cases that the method returns HTTP_CREATED.
+ // Failure Case - Method returns HTTP_BAD_REQUEST by setting wrong UUID to Port UUID.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
- port.setPortUUID(NEUTRON_UUID_ARRAY[1]);
+ port.setPortUUID(VTNManagerStub.VBR_IF_3_UUID);
port.setMacAddress(MAC_ADDR_ARRAY[0]);
port.setFixedIPs(new ArrayList<Neutron_IPs>(0));
- assertEquals(HttpURLConnection.HTTP_CREATED,
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canCreatePort(port));
- // In the cases that the method returns HTTP_CREATED.
+ // Success Case - Method returns HTTP_CREATED.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
assertEquals(HttpURLConnection.HTTP_CREATED,
ph.canCreatePort(port));
- // In the cases that the method returns HTTP_CREATED.
+ // Success Case - Method returns HTTP_CREATED.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
ph.setVTNManager(new VTNManagerStub());
NeutronPort port = null;
- // Case - Failure case by setting NULL to NeutronPort object
+ // Failure Case - By setting NULL to NeutronPort object
port = null;
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canCreatePort(port));
- // Case - Failure case by setting NULL to TennantID
+ // Failure Case - By setting NULL to TennantID
port = new NeutronPort();
port.setTenantID(null);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canCreatePort(port));
- // Case - Failure case by setting invalid UUID to TennantID
+ // Failure Case - By setting NULL to NetworkID
+ port = new NeutronPort();
+ port.setTenantID(NEUTRON_UUID_ARRAY[0]);
+ port.setNetworkUUID(null);
+ port.setPortUUID(NEUTRON_UUID_ARRAY[1]);
+ port.setMacAddress(MAC_ADDR_ARRAY[0]);
+ port.setFixedIPs(new ArrayList<Neutron_IPs>(0));
+
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ ph.canCreatePort(port));
+
+ // Failure Case - By setting NULL to PortID
+ port = new NeutronPort();
+ port.setTenantID(NEUTRON_UUID_ARRAY[0]);
+ port.setNetworkUUID(NEUTRON_UUID_ARRAY[1]);
+ port.setPortUUID(null);
+ port.setMacAddress(MAC_ADDR_ARRAY[0]);
+ port.setFixedIPs(new ArrayList<Neutron_IPs>(0));
+
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ ph.canCreatePort(port));
+ // Failure Case - By setting invalid UUID to TennantID
port = new NeutronPort();
port.setTenantID(VTNManagerStub.INVALID_UUID);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canCreatePort(port));
- // Case - Failure case by setting invalid UUID to NetworkID
+ // Failure Case - By setting invalid UUID to NetworkID
port = new NeutronPort();
port.setTenantID(TENANT_ID_ARRAY[0]);
port.setNetworkUUID(VTNManagerStub.INVALID_UUID);
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canCreatePort(port));
- // Case - Failure case by setting invalid UUID to PortID
+ // Failure Case - By setting invalid UUID to PortID
port = new NeutronPort();
port.setTenantID(TENANT_ID_ARRAY[0]);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canCreatePort(port));
- // Case - Success
+ // Success Case - Only for Method(getVTNIdentifiers)
port = new NeutronPort();
port.setTenantID(TENANT_ID_ARRAY[0]);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
PortHandler ph = new PortHandler();
ph.setVTNManager(new VTNManagerStub());
- // In the cases that the method returns HTTP_CONFLICT and failed to create New NeutronPort.
+ // Failure Case - Method returns HTTP_CONFLICT and failed to create New NeutronPort.
NeutronPort port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
ph.neutronPortCreated(port);
- // In the cases that the method returns HTTP_CONFLICT and failed to create New NeutronPort.
+ // Failure Case - Method returns HTTP_CONFLICT and failed to create New NeutronPort.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
ph.neutronPortCreated(port);
- // In the cases that the method successfully executes.
+ // Failure Case - Method returns HTTP_CONFLICT and failed to create Bridge Interface.
+ port = new NeutronPort();
+ port.setTenantID(VTNManagerStub.TENANT_1_UUID);
+ port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
+ port.setPortUUID(VTNManagerStub.VBR_IF_4_UUID);
+ port.setMacAddress(MAC_ADDR_ARRAY[0]);
+ port.setFixedIPs(new ArrayList<Neutron_IPs>(0));
+
+ ph.neutronPortCreated(port);
+
+ // Success Case - Method successfully executes.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
PortHandler ph = new PortHandler();
ph.setVTNManager(new VTNManagerStub());
- // In the cases that the method returns HTTP_BAD_REQUEST by setting NULL to both NeutronPort object.
+ // Failure Case - Method returns HTTP_BAD_REQUEST by setting NULL to both NeutronPort object.
NeutronPort portDelta = null;
NeutronPort portOriginal = null;
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canUpdatePort(portDelta, portOriginal));
+ // Failure Case - Method returns HTTP_BAD_REQUEST by setting NULL to portOriginal object.
portDelta = new NeutronPort();
- // In the cases that the method returns HTTP_BAD_REQUEST by setting NULL to TenantID.
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ ph.canUpdatePort(portDelta, portOriginal));
+
+ // Failure Case - Method returns HTTP_BAD_REQUEST by setting NULL to TenantID.
portOriginal = new NeutronPort();
portOriginal.setTenantID(null);
portOriginal.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canUpdatePort(portDelta, portOriginal));
- // Cases - returns HTTP_NOT_FOUND(Interface does not exist) by setting wrong PortUUID.
+ // Failure Case - Method returns HTTP_NOT_FOUND(Interface does not exist) by setting wrong PortUUID.
portOriginal = new NeutronPort();
portOriginal.setTenantID(VTNManagerStub.TENANT_1_UUID);
portOriginal.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
ph.canUpdatePort(portDelta, portOriginal));
- // In the cases that the method returns HTTP_OK.
+ // Success Case - Method returns HTTP_OK.
portOriginal = new NeutronPort();
portOriginal.setTenantID(VTNManagerStub.TENANT_1_UUID);
portOriginal.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
PortHandler ph = new PortHandler();
ph.setVTNManager(new VTNManagerStub());
- // Case - returns HTTP_BAD_REQUEST by setting NULL to TenantID.
+ // Failure Case - Method returns HTTP_BAD_REQUEST by setting NULL to TenantID.
NeutronPort port = new NeutronPort();
port.setTenantID(null);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
ph.neutronPortUpdated(port);
- // Case - returns HTTP_NOT_FOUND(Interface does not exist for tenant-id) by setting wrong PortUUID.
+ // Failure Case - Method returns HTTP_NOT_FOUND(Interface does not exist for tenant-id) by setting wrong PortUUID.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
ph.neutronPortUpdated(port);
- // Case - returns HTTP_CONFLICT(Modifying bridge interface failed) by setting Port-AdminStateUp to null
+ // Failure Case - Method(getBridgeInterface) returns NULL(throws VTNException) by setting Wrong Port UUID
+ port = new NeutronPort();
+ port.setTenantID(VTNManagerStub.TENANT_1_UUID);
+ port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
+ port.setPortUUID(VTNManagerStub.VBR_IF_3_UUID);
+ port.setMacAddress(MAC_ADDR_ARRAY[0]);
+ port.setFixedIPs(new ArrayList<Neutron_IPs>(0));
+
+ VTNManagerStub.isReturnValidVInterface = true;
+ try {
+ ph.neutronPortUpdated(port);
+ } catch (NullPointerException exception) {
+ assertEquals(exception.getMessage(), exception.toString(), new NullPointerException().toString());
+ }
+
+ // Failure Case - Method(canModifyInterface returns false) by setting Port-AdminStateUp to null
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
ph.neutronPortUpdated(port);
- // Case - Modifying bridge interface failed
+ // Failure Case - Modifying bridge interface failed
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
ph.neutronPortUpdated(port);
- // Case - Success
+ // Success Case
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
ph.neutronPortUpdated(port);
+ // Case - returns True by setting Port-AdminStateUp to False and valid name to NeutronPort
+ port = new NeutronPort();
+ port.setTenantID(VTNManagerStub.TENANT_1_UUID);
+ port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
+ port.setPortUUID(VTNManagerStub.VBR_IF_1_UUID);
+ port.setMacAddress(MAC_ADDR_ARRAY[0]);
+ port.setFixedIPs(new ArrayList<Neutron_IPs>(0));
+ port.setAdminStateUp(Boolean.FALSE);
+ port.setName("Neutron-port");
+
+ ph.neutronPortUpdated(port);
+
// Case - returns True by setting Port-AdminStateUp to True and valid Description to VBridgeIfConfig
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setName("Neutron-port");
ph.neutronPortUpdated(port);
+
+ // Case - returns True by setting Port-AdminStateUp to True, valid Description to VBridgeIfConfig and same name of port object to VInterfaceConfig
+ port = new NeutronPort();
+ port.setTenantID(VTNManagerStub.TENANT_1_UUID);
+ port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
+ port.setPortUUID(VTNManagerStub.VBR_IF_2_UUID);
+ port.setMacAddress(MAC_ADDR_ARRAY[0]);
+ port.setFixedIPs(new ArrayList<Neutron_IPs>(0));
+ port.setAdminStateUp(Boolean.TRUE);
+ port.setName("br-int config");
+
+ ph.neutronPortUpdated(port);
}
/**
PortHandler ph = new PortHandler();
ph.setVTNManager(new VTNManagerStub());
- // In the cases that the method returns HTTP_BAD_REQUEST by setting NULL to TenantID.
+ // Case - Method returns HTTP_BAD_REQUEST by setting NULL to TenantID.
NeutronPort port = new NeutronPort();
port.setTenantID(null);
port.setNetworkUUID(NEUTRON_UUID_ARRAY[0]);
assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
ph.canDeletePort(port));
- // Cases - returns HTTP_NOT_FOUND(Interface does not exist) by setting wrong PortUUID.
+ // Case - returns HTTP_NOT_FOUND(Interface does not exist) by setting wrong PortUUID.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
ph.canDeletePort(port));
- // In the cases that the method returns HTTP_OK.
+ // Case - Method returns HTTP_OK.
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
* Test method for
* {@link PortHandler#neutronPortDeleted(NeutronPort)}.
*/
- public void testNeutronPortDeleted(NeutronPort port) {
+ @Test
+ public void testNeutronPortDeleted() {
PortHandler ph = new PortHandler();
ph.setVTNManager(new VTNManagerStub());
// Case - returns HTTP_NOT_FOUND(Interface does not exist) by setting wrong PortUUID.
- port = new NeutronPort();
+ NeutronPort port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
port.setPortUUID(NEUTRON_UUID_ARRAY[1]);
ph.neutronPortDeleted(port);
- // Case - Success.
+ // Success Case
port = new NeutronPort();
port.setTenantID(VTNManagerStub.TENANT_1_UUID);
port.setNetworkUUID(VTNManagerStub.BRIDGE_1_UUID);
import java.io.File;
import org.junit.Assert;
+import java.util.UUID;
/**
* Abstract base class for JUnit tests.
/**
* String Declaration for identifying the Bridge with below NodeID.
*/
- protected static final String NODE_ID_2 = "D30D27770885";
+ protected static final String NODE_ID_2 = UUID.randomUUID().toString();
/**
* String Declaration for identifying the Interface with below Parent_UUID.
*/
public static final String CONFLICTED_NETWORK_UUID = "5e7e0900f2151e3aa760002a5d5c51c";
+ /*
+ * String declaration for setting Node to NULL for the below UUID
+ */
+ public static final String SET_NULL_TO_NODE = "5e7e0900f2151e3aa760002a5d5c51d";
+
/**
* String Declaration for setting the OFPortArray to NULL.
*/
"9b2b6560-f21e-11e3-a6a2-0002a5d5c51b", "not_null", "not_null",
"", "null_msg", "iface-id", "C387EB44-7832-49F4-B9F0-D30D27770881"},
- // Fail case for No switch is associated with interface, Node or interface Uuid is Null by setting UUID to null
+ // Fail case for No switch is associated with interface, Node or interface Uuid is Null by setting Node to null
+ // At present case, the below case failes
+ {"PE", "bridge-int", "br-int", "Interface", "",
+ SET_NULL_TO_NODE, "null", "null",
+ "", "null_msg", "iface-id", "C387EB44-7832-49F4-B9F0-D30D27770883"},
+
+ // Fail case for No switch is associated with interface, Node or interface Uuid is Null by setting UUID to null
{"PE", "bridge-int", "br-int", "Interface", "",
null, "null", "null",
"", "null_msg", "iface-id", "C387EB44-7832-49F4-B9F0-D30D27770883"},
// OpenVSwitch
{"PE", "intf-neutron", "interface1", "OpenVSwitch", "",
"9b2b6560-f21e-11e3-a6a2-0002a5d5c51f", "not_null", "not_null",
- "", "no_ex_msg", "iface-id", "0D2206F8-B700-4F78-913D-9CE7A2D78473"}};
+ "", "no_ex_msg", "iface-id", "0D2206F8-B700-4F78-913D-9CE7A2D78473"},
+
+ // Bridge
+ {"PE", "intf-neutron", "interface1", "Bridge", "",
+ "", "not_null", "not_null",
+ "", "no_ex_msg", "", ""}};
/**
* Exception message to be checked.
protected static final String EXCEPTION_MSG =
"org.opendaylight.ovsdb.lib.table.Bridge cannot be cast to org.opendaylight.ovsdb.lib.table.Interface";
- /**
- * An array of elements to update row with type OF.
- */
- protected static final String[][] RW_UPDT_INP_OF_ARY = {
- {"Set_OF_neutron", "0", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "9b2b6560-f21e-11e3-a6a2-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "12344321", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "9b2b6560-f21e-11e3-a6a2-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "12344321", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", null,
- "9b2b6560-f21e-11e3-a6a2-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "12344321", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Bridge",
- "9b2b6560-f21e-11e3-a6a2-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "12345678", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "9b2b6560-f21e-11e3-a6a2-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "12345678", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "", "0", "0", "no_ex_msg", "1", "0" } ,
-
- {"Set_OF_neutron", "23456789", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "85c27f20-f218-11e3-a7b6-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "23456789", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "c09b7fc0-f218-11e3-bf2f-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "23456789", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- null,
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_neutron", "98765432", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "85c27f20-f218-11e3-a7b6-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" },
-
- {"Set_OF_Null", "12345678", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "0d0ff2a0-f219-11e3-a482-0002a5d5c51b",
- "1", "0", "null_msg", "0", "0" },
-
- {"Set_OF_Bridge", "98765432", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "85c27f20-f218-11e3-a7b6-0002a5d5c51b",
- "1", "0", "ex_msg", "0", "0" },
-
- {"Set_OF_Bridge_intf", "98765432", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "85c27f20-f218-11e3-a7b6-0002a5d5c51b",
- "1", "0", "ex_msg", "0", "0" },
-
- {"Set_OF_neutron", "12345678", "interface1", "iface-id",
- "C387EB44-7832-49F4-B9F0-D30D27770883", "Interface",
- "85c27f20-f218-11e3-a7b6-0002a5d5c51b",
- "0", "0", "no_ex_msg", "1", "0" } };
-
/**
* An array of elements to create network.
*/
// Update case in Node added method
{"PE", NODE_ID_2, "0", "" },
// New NODE added case - Successful
- {"PE", "D30D27770883", "0", "" }
+ {"PE", UUID.randomUUID().toString(), "0", "" }
};
/**
{"22222224", "Interface", "0D2206F8-B700-4F78-913D-9CE7A2D78483", "0"},
// Fail case(processRowUpdated getVTNIdentifiers failed) - by setting NodeID and return HTTP_BAD_REQUEST in Method-deletePortMapForInterface()
{"22222225", "Interface", "C387EB44-7832-49F4-B9F0-D30D27770883", "0"},
- // Fail case(neutron identifiers not specified) - by setting invalid NodeID and return HTTP_BAD_REQUEST in Method-getVTNIdentifiers()
+ // Fail case(neutron identifiers not specified) - by setting invalid TennantID, SwitchID, PortID and return HTTP_BAD_REQUEST in Method-getVTNIdentifiers()
+ {"22222226", "Interface", "D387EB44-7832-49F4-B9F0-D30D27770884", "0"},
+ // Fail case(neutron identifiers not specified) - by setting invalid SwitchID, PortID and return HTTP_BAD_REQUEST in Method-getVTNIdentifiers()
+ {"22222226", "Interface", "D387EB44-7832-49F4-B9F0-D30D27770885", "0"},
+ // Fail case(neutron identifiers not specified) - by setting invalid PortID and return HTTP_BAD_REQUEST in Method-getVTNIdentifiers()
{"22222226", "Interface", "C387EB44-7832-49F4-B9F0-D30D27770883", "0"},
// Fail case(Invalid tenant identifier) - by setting invalid TennantID and return HTTP_BAD_REQUEST in Method-getVTNIdentifiers()
{"22222227", "Interface", "0D2206F8-B700-4F78-913D-9CE7A2D78475", "0"},
{"22222231", "Interface", "0D2206F8-B700-4F78-913D-9CE7A2D78473", "0"},
};
- /**
- * An array of elements to update row.
- */
- protected static final String[][] ROW_UPDATE_PORT_ARRAY = {
- {"OF", "56456644", "interface1", "C387EB44-7832-49F4-B9F0-D30D27770883", "set_port", "", "0" },
- {"OF", "56456644", "interface1", "C387EB44-7832-49F4-B9F0-D30D27770883", "set_null_port", "", "0" },
- {"OF", "56456644", "interface1", "C387EB44-7832-49F4-B9F0-D30D27770883", "set_empty_port", "", "0" },
- {"OF", "12345678", "interface1", "C387EB44-7832-49F4-B9F0-D30D27770883", "without_port", "65534", "0" },
- {"OF", "56456644", "interface1", "4790F3C1-AB34-4ABC-B7A5-C1B5C7202389", "", "65534", "0" },
- {"OF", "56456644", "interface1", "52B1482F-A41E-409F-AC68-B04ACFD07779", "", "65534", "0" },
- {"OF", "56456644", "interface1", "8c781fc0-f215-11e3-aac3-0002a5d5c51b", "", "65534", "0" },
- {"OF", "56456644", "interface1", "0D2206F8-B700-4F78-913D-9CE7A2D78473", "", "65534", "0" },
- };
-
/**
* Delete the specified directory recursively.
*
* org.opendaylight.vtn.manager package.
*/
public class VTNManagerStub implements IVTNManager {
+ // Boolean identifier for returning valid VInterface on setting this boolean variable
+ static boolean isReturnValidVInterface = false;
+
// An invalid UUID
static final String INVALID_UUID = "F6197D54-97A1-44D2-ABFB-6DFED030C30F-";
static final String VBR_IF_1_NAME = "F6197D5497A14D2ABFB6DFED030C30F";
static final String VBR_IF_2_UUID = "F6197D54-97A1-44D2-ABFB-6DFED030C300";
static final String VBR_IF_2_NAME = "F6197D5497A14D2ABFB6DFED030C300";
+ static final String VBR_IF_3_UUID = "F6197D54-97A1-44D2-ABFB-6DFED030C301";
+ static final String VBR_IF_3_NAME = "F6197D5497A14D2ABFB6DFED030C301";
+ static final String VBR_IF_4_UUID = "F6197D54-97A1-44D2-ABFB-6DFED030C302";
+ static final String VBR_IF_4_NAME = "F6197D5497A14D2ABFB6DFED030C302";
// Following methods are used in UnitTest.
@Override
}
VTenantPath tenant1 = new VTenantPath(TENANT_1_NAME);
+ VTenantPath tenant2 = new VTenantPath(TENANT_1_UUID);
if (path.equals(tenant1)) {
VTenantConfig conf = new VTenantConfig(null);
VTenant tenant = new VTenant(TENANT_1_NAME, conf);
return tenant;
+ } else if (path.equals(tenant2)) {
+ Status status = new Status(StatusCode.BADREQUEST);
+ throw new VTNException(status);
}
return null;
VBridgePath bridge1 = new VBridgePath(TENANT_1_NAME,
BRIDGE_1_NAME);
+
+ VBridgePath bridge2 = new VBridgePath(TENANT_1_UUID,
+ BRIDGE_1_NAME);
+
if (path.equals(bridge1)) {
VBridgeConfig bconf = new VBridgeConfig(null);
VBridge bridge = new VBridge(BRIDGE_1_NAME,
0,
bconf);
return bridge;
+ } else if (path.equals(bridge2)) {
+ Status status = new Status(StatusCode.BADREQUEST);
+ throw new VTNException(status);
}
return null;
VBridgeIfPath if2 = new VBridgeIfPath(TENANT_1_NAME,
BRIDGE_1_NAME,
VBR_IF_2_NAME);
+
+ VBridgeIfPath if3 = new VBridgeIfPath(TENANT_1_NAME,
+ BRIDGE_1_NAME,
+ VBR_IF_3_NAME);
if (path.equals(if1)) {
VInterfaceConfig iconf = new VInterfaceConfig(null, true);
VInterface vif = new VInterface(VBR_IF_1_NAME,
VNodeState.UNKNOWN,
iconf);
return vif;
+ } else if (path.equals(if3)) {
+ if (isReturnValidVInterface) {
+ isReturnValidVInterface = false;
+
+ VInterfaceConfig iconf = new VInterfaceConfig(null, true);
+ VInterface vif = new VInterface(VBR_IF_3_NAME,
+ VNodeState.UNKNOWN,
+ VNodeState.UNKNOWN,
+ iconf);
+ return vif;
+ }
+ Status status = new Status(StatusCode.BADREQUEST);
+ throw new VTNException(status);
}
return null;
VBridgeIfPath bif1 = new VBridgeIfPath(TENANT_1_NAME,
BRIDGE_1_NAME,
VBR_IF_2_NAME);
- if (path.equals(bif1)) {
+
+ VBridgeIfPath bif2 = new VBridgeIfPath(TENANT_1_NAME,
+ BRIDGE_1_NAME,
+ VBR_IF_4_NAME);
+
+ if ((path.equals(bif1)) || (path.equals(bif2))) {
return new Status(StatusCode.CONFLICT);
}
IVTNManager mgr = new VTNManagerStub();
utils.setVTNManager(mgr);
- assertSame(mgr, utils.getVTNManager());
+ assertEquals(mgr, utils.getVTNManager());
+
+ utils.unsetVTNManager(null);
+ assertEquals(mgr, utils.getVTNManager());
utils.unsetVTNManager(mgr);
assertNull(utils.getVTNManager());
invalidId = "550e8400-e29b41d4a716446655440000";
assertFalse(VTNNeutronUtils.isValidNeutronID(invalidId));
+ // The length is 36 but invalid UUID format for IllegalArgumentException.
+ invalidId = "550e8400-e29b-41d4--716-446655440000";
+ assertFalse(VTNNeutronUtils.isValidNeutronID(invalidId));
+
for (String neutronId: NEUTRON_UUID_ARRAY) {
assertTrue(VTNNeutronUtils.isValidNeutronID(neutronId));
}
invalidId = "550e8400-e29b41d4a716446655440000";
assertNull(VTNNeutronUtils.convertNeutronIDToVTNKey(invalidId));
+ // The length is 32 but invalid UUID format for IllegalArgumentException.
+ invalidId = "550e8400e29b-1d4a716446655440000";
+ assertNull(VTNNeutronUtils.convertNeutronIDToVTNKey(invalidId));
+
String validId = "550e8400-e29b-41d4-a716-446655440000";
assertEquals("550e8400e29b1d4a716446655440000",
VTNNeutronUtils.convertNeutronIDToVTNKey(validId));
utils.isTenantExist(tenantID));
tenantID = VTNManagerStub.TENANT_1_UUID;
- assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
utils.isTenantExist(tenantID));
tenantID = VTNManagerStub.TENANT_1_NAME;
String tenantID = "a";
String bridgeID = "a";
+
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ utils.isBridgeExist(tenantID, null));
+
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
utils.isBridgeExist(tenantID, bridgeID));
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
utils.isBridgeExist(tenantID, bridgeID));
+ tenantID = VTNManagerStub.TENANT_1_UUID;
+ bridgeID = VTNManagerStub.BRIDGE_1_NAME;
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ utils.isBridgeExist(tenantID, bridgeID));
+
tenantID = VTNManagerStub.TENANT_1_NAME;
bridgeID = VTNManagerStub.BRIDGE_1_NAME;
assertEquals(HttpURLConnection.HTTP_OK,
String tenantID = "a";
String bridgeID = "a";
String portID = "a";
+
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ utils.isBridgeInterfaceExist(tenantID, null, null));
+
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ utils.isBridgeInterfaceExist(tenantID, bridgeID, null));
+
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
utils.isBridgeInterfaceExist(tenantID, bridgeID, portID));
assertEquals(HttpURLConnection.HTTP_NOT_FOUND,
utils.isBridgeInterfaceExist(tenantID, bridgeID, portID));
+ tenantID = VTNManagerStub.TENANT_1_NAME;
+ bridgeID = VTNManagerStub.BRIDGE_1_NAME;
+ portID = VTNManagerStub.VBR_IF_3_NAME;
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST,
+ utils.isBridgeInterfaceExist(tenantID, bridgeID, portID));
+
tenantID = VTNManagerStub.TENANT_1_NAME;
bridgeID = VTNManagerStub.BRIDGE_1_NAME;
portID = VTNManagerStub.VBR_IF_1_NAME;