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")));
}
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);
}
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);
}
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);
}
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);
}
Aggregations