Search in sources :

Example 6 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowCrudSteps method eachFlowIsInUPState.

@And("^each flow is in UP state$")
public void eachFlowIsInUPState() {
    for (FlowPayload flow : flows) {
        FlowIdStatusPayload status = Failsafe.with(retryPolicy.abortIf(p -> p != null && FlowState.UP == ((FlowIdStatusPayload) p).getStatus())).get(() -> northboundService.getFlowStatus(flow.getId()));
        assertNotNull(status);
        assertThat(format("The flow status for '%s' can't be retrived.", flow.getId()), status, hasProperty("id", equalTo(flow.getId())));
        assertThat(format("The flow '%s' has wrong status.", flow.getId()), status, hasProperty("status", equalTo(FlowState.UP)));
    }
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) And(cucumber.api.java.en.And)

Example 7 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowCrudSteps method eachFlowCanNotBeReadFromNorthbound.

@And("^each flow can not be read from Northbound$")
public void eachFlowCanNotBeReadFromNorthbound() {
    for (FlowPayload flow : flows) {
        FlowPayload result = Failsafe.with(retryPolicy.abortIf(Objects::isNull)).get(() -> northboundService.getFlow(flow.getId()));
        assertNull(format("The flow '%s' exists.", flow.getId()), result);
    }
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Objects(java.util.Objects) And(cucumber.api.java.en.And)

Example 8 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowCrudSteps method eachFlowCanBeDeleted.

@Then("^each flow can be deleted$")
public void eachFlowCanBeDeleted() {
    for (FlowPayload flow : flows) {
        FlowPayload result = northboundService.deleteFlow(flow.getId());
        assertNotNull(result);
    }
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Then(cucumber.api.java.en.Then)

Example 9 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowCrudSteps method creationRequestForEachFlowIsSuccessful.

@When("^creation request for each flow is successful$")
public void creationRequestForEachFlowIsSuccessful() {
    for (FlowPayload flow : flows) {
        FlowPayload result = northboundService.addFlow(flow);
        assertThat(result, reflectEquals(flow, "lastUpdated"));
        assertThat(result, hasProperty("lastUpdated", notNullValue()));
    }
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) When(cucumber.api.java.en.When)

Example 10 with FlowPayload

use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.

the class FlowCrudStepsTest method shouldDefineFlowsOver3Switches.

@Test
public void shouldDefineFlowsOver3Switches() {
    // given
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:01"), eq("00:00:00:00:00:02"))).thenReturn(singletonList(new PathInfoData()));
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:02"), eq("00:00:00:00:00:03"))).thenReturn(singletonList(new PathInfoData()));
    // when
    flowCrudSteps.defineFlowsOverAllSwitches();
    // then
    assertEquals(2, flowCrudSteps.flows.size());
    final FlowPayload sw1sw2Flow = flowCrudSteps.flows.get(0);
    assertEquals(20, (int) sw1sw2Flow.getSource().getPortId());
    assertEquals(1, (int) sw1sw2Flow.getSource().getVlanId());
    assertEquals(20, (int) sw1sw2Flow.getDestination().getPortId());
    assertEquals(1, (int) sw1sw2Flow.getDestination().getVlanId());
    final FlowPayload sw2sw3Flow = flowCrudSteps.flows.get(1);
    assertEquals(20, (int) sw2sw3Flow.getSource().getPortId());
    assertEquals(2, (int) sw2sw3Flow.getSource().getVlanId());
    assertEquals(20, (int) sw2sw3Flow.getDestination().getPortId());
    assertEquals(2, (int) sw2sw3Flow.getDestination().getVlanId());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Test(org.junit.Test)

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