Search in sources :

Example 6 with OverlappingSegmentsStats

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

the class IntersectionComputerTest method partialIntersection.

@Test
public void partialIntersection() {
    List<FlowPath> paths = getFlowPaths();
    FlowPath newPath = FlowPath.builder().pathId(NEW_PATH_ID).srcSwitch(makeSwitch(SWITCH_ID_A)).destSwitch(makeSwitch(SWITCH_ID_B)).segments(Lists.newArrayList(buildPathSegment(NEW_PATH_ID, SWITCH_ID_A, SWITCH_ID_B, 1, 1))).build();
    flow2.addPaths(newPath);
    paths.add(newPath);
    IntersectionComputer computer = new IntersectionComputer(FLOW_ID, PATH_ID, PATH_ID_REVERSE, paths);
    OverlappingSegmentsStats stats = computer.getOverlappingStats(NEW_PATH_ID, NEW_PATH_ID_REVERSE);
    assertEquals(new OverlappingSegmentsStats(1, 2, 50, 66), stats);
}
Also used : OverlappingSegmentsStats(org.openkilda.messaging.payload.flow.OverlappingSegmentsStats) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 7 with OverlappingSegmentsStats

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

the class IntersectionComputerTest method shouldNotFailIfNoIntersectionSegments.

@Test
public void shouldNotFailIfNoIntersectionSegments() {
    List<FlowPath> paths = getFlowPaths();
    IntersectionComputer computer = new IntersectionComputer(FLOW_ID, PATH_ID, PATH_ID_REVERSE, paths);
    OverlappingSegmentsStats stats = computer.getOverlappingStats(NEW_PATH_ID, NEW_PATH_ID_REVERSE);
    assertEquals(ZERO_STATS, stats);
}
Also used : OverlappingSegmentsStats(org.openkilda.messaging.payload.flow.OverlappingSegmentsStats) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 8 with OverlappingSegmentsStats

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

the class IntersectionComputerTest method shouldNoIntersections.

@Test
public void shouldNoIntersections() {
    List<FlowPath> paths = getFlowPaths();
    FlowPath path = FlowPath.builder().pathId(NEW_PATH_ID).srcSwitch(makeSwitch(SWITCH_ID_D)).destSwitch(makeSwitch(SWITCH_ID_E)).segments(Lists.newArrayList(buildPathSegment(NEW_PATH_ID, SWITCH_ID_D, SWITCH_ID_E, 10, 10))).build();
    flow.addPaths(path);
    FlowPath revPath = FlowPath.builder().pathId(NEW_PATH_ID_REVERSE).srcSwitch(makeSwitch(SWITCH_ID_E)).destSwitch(makeSwitch(SWITCH_ID_D)).segments(Lists.newArrayList(buildPathSegment(NEW_PATH_ID_REVERSE, SWITCH_ID_E, SWITCH_ID_D, 10, 10))).build();
    flow2.addPaths(revPath);
    paths.addAll(Lists.newArrayList(path, revPath));
    IntersectionComputer computer = new IntersectionComputer(FLOW_ID, PATH_ID, PATH_ID_REVERSE, paths);
    OverlappingSegmentsStats stats = computer.getOverlappingStats(NEW_PATH_ID, NEW_PATH_ID_REVERSE);
    assertEquals(ZERO_STATS, stats);
}
Also used : OverlappingSegmentsStats(org.openkilda.messaging.payload.flow.OverlappingSegmentsStats) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 9 with OverlappingSegmentsStats

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

the class IntersectionComputerTest method switchIntersectionByPathId.

@Test
public void switchIntersectionByPathId() {
    List<FlowPath> paths = getFlowPaths();
    FlowPath newPath = FlowPath.builder().pathId(NEW_PATH_ID).srcSwitch(makeSwitch(SWITCH_ID_A)).destSwitch(makeSwitch(SWITCH_ID_D)).segments(Lists.newArrayList(buildPathSegment(NEW_PATH_ID, SWITCH_ID_A, SWITCH_ID_D, 10, 10))).build();
    flow2.addPaths(newPath);
    paths.add(newPath);
    IntersectionComputer computer = new IntersectionComputer(FLOW_ID, PATH_ID, PATH_ID_REVERSE, paths);
    OverlappingSegmentsStats stats = computer.getOverlappingStats(NEW_PATH_ID, NEW_PATH_ID_REVERSE);
    assertEquals(new OverlappingSegmentsStats(0, 1, 0, 33), stats);
}
Also used : OverlappingSegmentsStats(org.openkilda.messaging.payload.flow.OverlappingSegmentsStats) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 OverlappingSegmentsStats (org.openkilda.messaging.payload.flow.OverlappingSegmentsStats)9 FlowPath (org.openkilda.model.FlowPath)8