use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortCodecTest method testInstancePortDecode.
/**
* Tests the instance port decoding.
*/
@Test
public void testInstancePortDecode() throws IOException {
InstancePort port = getInstancePort("InstancePort.json");
assertThat(port.networkId(), is("net-id-1"));
assertThat(port.portId(), is("port-id-1"));
assertThat(port.deviceId(), is(DeviceId.deviceId("of:000000000000000a")));
assertThat(port.portNumber(), is(PortNumber.portNumber(1, "tap-1")));
assertThat(port.ipAddress(), is(IpAddress.valueOf("10.10.10.1")));
assertThat(port.macAddress(), is(MacAddress.valueOf("11:22:33:44:55:66")));
assertThat(port.state().name(), is("ACTIVE"));
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class DefaultInstancePortTest method testConstruction.
/**
* Test object construction.
*/
@Test
public void testConstruction() {
InstancePort instancePort = instancePort1;
assertThat(instancePort.portId(), is(PORT_ID_1));
assertThat(instancePort.networkId(), is(NETWORK_ID_1));
assertThat(instancePort.macAddress(), is(MAC_ADDRESS_1));
assertThat(instancePort.ipAddress(), is(IP_ADDRESS_1));
assertThat(instancePort.portNumber(), is(PORT_NUM_1));
assertThat(instancePort.deviceId(), is(DEV_ID_1));
assertThat(instancePort.state(), is(ACTIVE));
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortManagerTest method testCreateAndUpdateInstancePort.
/**
* Tests updating an instance port, and checks if it triggers proper events.
*/
@Test
public void testCreateAndUpdateInstancePort() {
target.createInstancePort(instancePort1);
assertEquals("Number of instance port did not match", 1, target.instancePorts().size());
assertEquals("Instance port did not match", PORT_NUM_1, target.instancePort(PORT_ID_1).portNumber());
HostLocation location = new HostLocation(DEV_ID_2, PORT_NUM_2, TIME_2);
DefaultAnnotations.Builder annotations = DefaultAnnotations.builder().set(ANNOTATION_NETWORK_ID, NETWORK_ID_2).set(ANNOTATION_PORT_ID, PORT_ID_1).set(ANNOTATION_CREATE_TIME, String.valueOf(TIME_2));
Host host = new DefaultHost(PROVIDER_ID, HOST_ID_2, MAC_ADDRESS_2, VLAN_ID, location, ImmutableSet.of(IP_ADDRESS_2), annotations.build());
final InstancePort updated = DefaultInstancePort.from(host, ACTIVE);
target.updateInstancePort(updated);
assertEquals("Number of instance port did not match", 1, target.instancePorts().size());
assertEquals("Instance port did not match", PORT_NUM_2, target.instancePort(PORT_ID_1).portNumber());
validateEvents(OPENSTACK_INSTANCE_PORT_DETECTED, OPENSTACK_INSTANCE_PORT_UPDATED);
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortManagerTest method testGetInstancePortByIpAndNetId.
/**
* Tests if getting an instance port with IP and network ID returns correct port.
*/
@Test
public void testGetInstancePortByIpAndNetId() {
createBasicInstancePorts();
InstancePort port = target.instancePort(IP_ADDRESS_1, NETWORK_ID_1);
assertEquals("Instance port did not match", port, instancePort1);
}
use of org.onosproject.openstacknetworking.api.InstancePort in project onos by opennetworkinglab.
the class InstancePortManagerTest method testTerminateInstance.
/**
* Tests if it triggers the instance termination event.
*/
@Test
public void testTerminateInstance() {
InstancePort instancePort = instancePort1;
target.createInstancePort(instancePort);
InstancePort inactiveInstancePort = instancePort.updateState(INACTIVE);
target.updateInstancePort(inactiveInstancePort);
assertEquals("Number of instance port did not match", 1, target.instancePorts().size());
assertNotNull("Instance port did not match", target.instancePort(PORT_ID_1));
validateEvents(OPENSTACK_INSTANCE_PORT_DETECTED, OPENSTACK_INSTANCE_TERMINATED);
}
Aggregations