Search in sources :

Example 41 with FlowPayload

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());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Test(org.junit.Test)

Example 42 with FlowPayload

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);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) FlowEndpointPayload(org.openkilda.messaging.payload.flow.FlowEndpointPayload) When(cucumber.api.java.en.When)

Example 43 with FlowPayload

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);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) FlowEndpointPayload(org.openkilda.messaging.payload.flow.FlowEndpointPayload) When(cucumber.api.java.en.When)

Example 44 with FlowPayload

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);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) DefaultParameters.trafficEndpoint(org.openkilda.DefaultParameters.trafficEndpoint) DefaultParameters.mininetEndpoint(org.openkilda.DefaultParameters.mininetEndpoint) Then(cucumber.api.java.en.Then)

Example 45 with FlowPayload

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());
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Then(cucumber.api.java.en.Then)

Aggregations

FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)48 Test (org.junit.Test)14 FlowEndpointPayload (org.openkilda.messaging.payload.flow.FlowEndpointPayload)9 Then (cucumber.api.java.en.Then)7 When (cucumber.api.java.en.When)7 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 DefaultParameters.northboundEndpoint (org.openkilda.DefaultParameters.northboundEndpoint)6 DefaultParameters.topologyEndpoint (org.openkilda.DefaultParameters.topologyEndpoint)6 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)6 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)6 HttpHeaders (org.springframework.http.HttpHeaders)6 ResponseEntity (org.springframework.http.ResponseEntity)6 WithMockUser (org.springframework.security.test.context.support.WithMockUser)6 MvcResult (org.springframework.test.web.servlet.MvcResult)6 And (cucumber.api.java.en.And)5 Client (javax.ws.rs.client.Client)5 Response (javax.ws.rs.core.Response)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3