Search in sources :

Example 6 with PathNodePayload

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

the class FlowSteps method getAvailableBandwidthAndSpeed.

@And("^get available bandwidth and maximum speed for flow (.*) and alias them as '(.*)' " + "and '(.*)' respectively$")
public void getAvailableBandwidthAndSpeed(String flowAlias, String bwAlias, String speedAlias) {
    FlowPayload flow = topologyUnderTest.getAliasedObject(flowAlias);
    List<PathNodePayload> flowPath = northboundService.getFlowPath(flow.getId()).getForwardPath();
    List<IslInfoData> allLinks = northboundService.getAllLinks();
    long minBw = Long.MAX_VALUE;
    long minSpeed = Long.MAX_VALUE;
    /*
        Take flow path and all links. Now for every pair in flow path find a link.
        Take minimum available bandwidth and minimum available speed from those links
        (flow's speed and left bandwidth depends on the weakest isl)
        */
    for (int i = 1; i < flowPath.size(); i++) {
        PathNodePayload from = flowPath.get(i - 1);
        PathNodePayload to = flowPath.get(i);
        IslInfoData isl = allLinks.stream().filter(link -> link.getSource().getSwitchId().equals(from.getSwitchId()) && link.getDestination().getSwitchId().equals(to.getSwitchId())).findFirst().orElseThrow(() -> new IllegalStateException(format("Isl from %s to %s not found.", from.getSwitchId(), to.getSwitchId())));
        minBw = Math.min(isl.getAvailableBandwidth(), minBw);
        minSpeed = Math.min(isl.getSpeed(), minSpeed);
    }
    topologyUnderTest.addAlias(bwAlias, minBw);
    topologyUnderTest.addAlias(speedAlias, minSpeed);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) PathNodePayload(org.openkilda.messaging.payload.flow.PathNodePayload) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) And(cucumber.api.java.en.And)

Example 7 with PathNodePayload

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

the class FlowCacheServiceTest method shouldChangeFlowPathInCache.

@Test
public void shouldChangeFlowPathInCache() {
    Flow flow = createFlow();
    when(clock.instant()).thenReturn(Instant.now());
    service = new FlowCacheService(persistenceManager, clock, FLOW_RTT_STATS_EXPIRATION_TIME, carrier);
    Long maxLatency = 100L;
    Long maxLatencyTier2 = 200L;
    UpdateFlowCommand updateFlowCommand = new UpdateFlowCommand(flow.getFlowId(), FlowPathDto.builder().id(flow.getFlowId()).forwardPath(Arrays.asList(new PathNodePayload(SRC_SWITCH, IN_PORT, ISL_SRC_PORT_2), new PathNodePayload(DST_SWITCH, ISL_DST_PORT_2, OUT_PORT))).reversePath(Arrays.asList(new PathNodePayload(DST_SWITCH, OUT_PORT, ISL_DST_PORT_2), new PathNodePayload(SRC_SWITCH, ISL_SRC_PORT_2, IN_PORT))).build(), maxLatency, maxLatencyTier2);
    service.updateFlowInfo(updateFlowCommand);
    service.processFlowLatencyCheck(flow.getFlowId());
    List<Link> expectedForwardPath = getLinks(SRC_SWITCH, ISL_SRC_PORT_2, DST_SWITCH, ISL_DST_PORT_2);
    verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.FORWARD, expectedForwardPath);
    List<Link> expectedReversePath = reverse(expectedForwardPath);
    verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.REVERSE, expectedReversePath);
    verifyNoMoreInteractions(carrier);
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) PathNodePayload(org.openkilda.messaging.payload.flow.PathNodePayload) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

PathNodePayload (org.openkilda.messaging.payload.flow.PathNodePayload)7 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)2 UpdateFlowCommand (org.openkilda.messaging.info.flow.UpdateFlowCommand)2 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)2 Flow (org.openkilda.model.Flow)2 FlowEndpoint (org.openkilda.model.FlowEndpoint)2 PathSegment (org.openkilda.model.PathSegment)2 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)2 And (cucumber.api.java.en.And)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 FlowSet (org.openkilda.atdd.staging.helpers.FlowSet)1 FlowBuilder (org.openkilda.atdd.staging.helpers.FlowSet.FlowBuilder)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)1 FlowPathDto (org.openkilda.messaging.model.FlowPathDto)1 Path (org.openkilda.pce.Path)1 Segment (org.openkilda.pce.Path.Segment)1