Search in sources :

Example 11 with FlowPayload

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

the class FlowCrudStepsTest method shouldSkipSwitchesIfNoVlanAvailable.

@Test
public void shouldSkipSwitchesIfNoVlanAvailable() {
    // given
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:04"), eq("00:00:00:00:00:02"))).thenReturn(singletonList(new PathInfoData()));
    when(topologyEngineService.getPaths(eq("00:00:00:00:00:04"), 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);
    assertThat(flowPayload.getSource(), hasProperty("switchId", equalTo("00:00:00:00:00:04")));
    assertThat(flowPayload.getDestination(), hasProperty("switchId", equalTo("00:00:00:00:00:01")));
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Test(org.junit.Test)

Example 12 with FlowPayload

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

the class FlowCrudBasicRunTest method checkFlowUpdate.

@Then("^flow (.*) with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) could be updated with (\\d+)$")
public void checkFlowUpdate(final String flowId, final String sourceSwitch, final int sourcePort, final int sourceVlan, final String destinationSwitch, final int destinationPort, final int destinationVlan, final int band, final int newBand) throws Exception {
    flowPayload.setMaximumBandwidth(newBand);
    FlowPayload response = FlowUtils.updateFlow(FlowUtils.getFlowName(flowId), flowPayload);
    assertNotNull(response);
    response.setLastUpdated(null);
    assertEquals(flowPayload, response);
    checkFlowCreation(flowId, sourceSwitch, sourcePort, sourceVlan, destinationSwitch, destinationPort, destinationVlan, newBand);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Then(cucumber.api.java.en.Then)

Example 13 with FlowPayload

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

the class FlowIgnoreBandwidthTest method dropCreatedEarlyFlow.

@When("^drop created flow between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) and ([0-9a-f]{2}(?::[0-9a-f]{2}){7})$")
public void dropCreatedEarlyFlow(String source, String dest) throws FlowOperationException, InterruptedException {
    String flowId = lookupCreatedFlowId(source, dest);
    System.out.println(String.format("==> Send flow DELETE request (%s <--> %s)", source, dest));
    FlowPayload response = FlowUtils.deleteFlow(flowId);
    assertNotNull(response);
    System.out.println(String.format("==> Wait till flow become \"DOWN\" (%s <--> %s)", source, dest));
    FlowUtils.waitFlowDeletion(flowId);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) When(cucumber.api.java.en.When)

Example 14 with FlowPayload

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

the class FlowIgnoreBandwidthTest method flowIgnoreBandwidthBetweenSwitchesWithBandwidthIsCreated.

@When("^flow ignore bandwidth between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) and ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) with (\\d+) bandwidth is created$")
public void flowIgnoreBandwidthBetweenSwitchesWithBandwidthIsCreated(String source, String dest, int bandwidth) throws InterruptedException {
    String flowId = FlowUtils.getFlowName("flowId");
    FlowEndpointPayload sourcePoint = new FlowEndpointPayload(source, 1, 0);
    FlowEndpointPayload destPoint = new FlowEndpointPayload(dest, 2, 0);
    FlowPayload requestPayload = new FlowPayload(flowId, sourcePoint, destPoint, bandwidth, true, "Flow that ignore ISL bandwidth", null);
    System.out.println(String.format("==> Send flow CREATE request (%s <--> %s)", source, dest));
    FlowPayload response = FlowUtils.putFlow(requestPayload);
    Assert.assertNotNull(response);
    response.setLastUpdated(null);
    System.out.println(String.format("==> Wait till flow become \"UP\" (%s <--> %s)", source, dest));
    FlowIdStatusPayload status = FlowUtils.waitFlowStatus(flowId, FlowState.UP);
    assertNotNull(status);
    assertEquals(FlowState.UP, status.getStatus());
    saveCreatedFlowId(source, dest, flowId);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowEndpointPayload(org.openkilda.messaging.payload.flow.FlowEndpointPayload) When(cucumber.api.java.en.When)

Example 15 with FlowPayload

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

the class FlowController method updateFlow.

/**
 * Updates existing flow.
 *
 * @param flow          flow
 * @param flowId        flow id
 * @param correlationId correlation ID header value
 * @return flow
 */
@ApiOperation(value = "Updates flow", response = FlowPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows/{flow-id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<FlowPayload> updateFlow(@PathVariable(name = "flow-id") String flowId, @RequestBody FlowPayload flow, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("Update flow: {}={}, {}={}, flow={}", CORRELATION_ID, correlationId, FLOW_ID, flowId, flow);
    FlowPayload response = flowService.updateFlow(flow, correlationId);
    return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

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