use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowCrudStepsTest method shouldDefineFlowsOverTheSameSwitches.
@Test
public void shouldDefineFlowsOverTheSameSwitches() {
// given
when(topologyEngineService.getPaths(eq("00:00:00:00:00:01"), eq("00:00:00:00:00:01"))).thenReturn(singletonList(new PathInfoData()));
// when
flowCrudSteps.defineFlowsOverAllSwitches();
// then
assertEquals(1, flowCrudSteps.flows.size());
final FlowPayload flowPayload = flowCrudSteps.flows.get(0);
assertEquals(20, (int) flowPayload.getSource().getPortId());
assertEquals(1, (int) flowPayload.getSource().getVlanId());
assertEquals(21, (int) flowPayload.getDestination().getPortId());
assertEquals(1, (int) flowPayload.getDestination().getVlanId());
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowCrudBasicRunTest method successfulFlowCreation.
@When("^flow (.*) creation request with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) is successful$")
public void successfulFlowCreation(final String flowId, final String sourceSwitch, final int sourcePort, final int sourceVlan, final String destinationSwitch, final int destinationPort, final int destinationVlan, final int bandwidth) throws Exception {
flowPayload = new FlowPayload(FlowUtils.getFlowName(flowId), new FlowEndpointPayload(sourceSwitch, sourcePort, sourceVlan), new FlowEndpointPayload(destinationSwitch, destinationPort, destinationVlan), bandwidth, false, flowId, null);
FlowPayload response = FlowUtils.putFlow(flowPayload);
assertNotNull(response);
response.setLastUpdated(null);
assertEquals(flowPayload, response);
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowCrudBasicRunTest method failedFlowCreation.
@When("^flow (.*) creation request with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) is failed$")
public void failedFlowCreation(final String flowId, final String sourceSwitch, final int sourcePort, final int sourceVlan, final String destinationSwitch, final int destinationPort, final int destinationVlan, final int bandwidth) throws Exception {
flowPayload = new FlowPayload(FlowUtils.getFlowName(flowId), new FlowEndpointPayload(sourceSwitch, sourcePort, sourceVlan), new FlowEndpointPayload(destinationSwitch, destinationPort, destinationVlan), bandwidth, false, flowId, null);
FlowPayload response = FlowUtils.putFlow(flowPayload);
assertNull(response);
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowCrudBasicRunTest method checkFlowDeletion.
@Then("^flow (.*) with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) could be deleted$")
public void checkFlowDeletion(final String flowId, final String sourceSwitch, final int sourcePort, final int sourceVlan, final String destinationSwitch, final int destinationPort, final int destinationVlan, final int bandwidth) throws Exception {
// use -1 to communicate "I don't know what it should be")
int unknownFlowCount = -1;
int expectedFlowCount = getFlowCount(unknownFlowCount) - 2;
FlowPayload response = FlowUtils.deleteFlow(FlowUtils.getFlowName(flowId));
assertNotNull(response);
response.setLastUpdated(null);
assertEquals(flowPayload, response);
FlowPayload flow = FlowUtils.getFlow(FlowUtils.getFlowName(flowId));
if (flow != null) {
TimeUnit.SECONDS.sleep(2);
flow = FlowUtils.getFlow(FlowUtils.getFlowName(flowId));
}
assertNull(flow);
int actualFlowCount = getFlowCount(expectedFlowCount);
assertEquals(expectedFlowCount, actualFlowCount);
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowCrudBasicRunTest method checkFlowRead.
@Then("^flow (.*) with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) could be read$")
public void checkFlowRead(final String flowId, final String sourceSwitch, final int sourcePort, final int sourceVlan, final String destinationSwitch, final int destinationPort, final int destinationVlan, final int bandwidth) throws Exception {
FlowPayload flow = FlowUtils.getFlow(FlowUtils.getFlowName(flowId));
assertNotNull(flow);
System.out.println(String.format("===> Flow was created at %s\n", flow.getLastUpdated()));
assertEquals(FlowUtils.getFlowName(flowId), flow.getId());
assertEquals(sourceSwitch, flow.getSource().getSwitchId());
assertEquals(sourcePort, flow.getSource().getPortId().longValue());
assertEquals(sourceVlan, flow.getSource().getVlanId().longValue());
assertEquals(destinationSwitch, flow.getDestination().getSwitchId());
assertEquals(destinationPort, flow.getDestination().getPortId().longValue());
assertEquals(destinationVlan, flow.getDestination().getVlanId().longValue());
assertEquals(bandwidth, flow.getMaximumBandwidth());
assertNotNull(flow.getLastUpdated());
}
Aggregations