Search in sources :

Example 1 with PathResources

use of org.openkilda.wfm.share.flow.resources.FlowResources.PathResources in project open-kilda by telstra.

the class FlowPathBuilderTest method shouldBuildFlowPathFor3SwitchPath.

@Test
public void shouldBuildFlowPathFor3SwitchPath() {
    SwitchId switchId1 = new SwitchId(1);
    SwitchId switchId2 = new SwitchId(2);
    SwitchId switchId3 = new SwitchId(3);
    Path path = Path.builder().srcSwitchId(switchId1).destSwitchId(switchId2).segments(asList(Segment.builder().srcSwitchId(switchId1).srcPort(1).destSwitchId(switchId3).destPort(2).build(), Segment.builder().srcSwitchId(switchId3).srcPort(1).destSwitchId(switchId2).destPort(2).build())).build();
    Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(switchId1).build()).destSwitch(Switch.builder().switchId(switchId2).build()).build();
    PathId pathId = new PathId("test_path_id");
    MeterId meterId = new MeterId(MeterId.MIN_FLOW_METER_ID);
    PathResources pathResources = PathResources.builder().pathId(pathId).meterId(meterId).build();
    FlowSegmentCookie cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1);
    FlowPath flowPath = builder.buildFlowPath(flow, pathResources, path, cookie, false, flow.getFlowId());
    assertEquals(switchId1, flowPath.getSrcSwitchId());
    assertEquals(switchId2, flowPath.getDestSwitchId());
    assertEquals(pathId, flowPath.getPathId());
    assertEquals(meterId, flowPath.getMeterId());
    assertEquals(cookie, flowPath.getCookie());
    assertThat(flowPath.getSegments(), hasSize(2));
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathResources(org.openkilda.wfm.share.flow.resources.FlowResources.PathResources) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 2 with PathResources

use of org.openkilda.wfm.share.flow.resources.FlowResources.PathResources in project open-kilda by telstra.

the class FlowPathBuilderTest method shouldBuildFlowPathFor1SwitchPath.

@Test
public void shouldBuildFlowPathFor1SwitchPath() {
    SwitchId switchId = new SwitchId(1);
    Path path = Path.builder().srcSwitchId(switchId).destSwitchId(switchId).segments(Collections.emptyList()).build();
    Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(switchId).build()).destSwitch(Switch.builder().switchId(switchId).build()).build();
    PathId pathId = new PathId("test_path_id");
    MeterId meterId = new MeterId(MeterId.MIN_FLOW_METER_ID);
    PathResources pathResources = PathResources.builder().pathId(pathId).meterId(meterId).build();
    FlowSegmentCookie cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1);
    FlowPath flowPath = builder.buildFlowPath(flow, pathResources, path, cookie, false, flow.getFlowId());
    assertEquals(pathId, flowPath.getPathId());
    assertEquals(meterId, flowPath.getMeterId());
    assertEquals(cookie, flowPath.getCookie());
    assertThat(flowPath.getSegments(), empty());
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathResources(org.openkilda.wfm.share.flow.resources.FlowResources.PathResources) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 3 with PathResources

use of org.openkilda.wfm.share.flow.resources.FlowResources.PathResources in project open-kilda by telstra.

the class FlowPathBuilderTest method shouldBuildFlowPathFor2SwitchPath.

@Test
public void shouldBuildFlowPathFor2SwitchPath() {
    SwitchId switchId1 = new SwitchId(1);
    SwitchId switchId2 = new SwitchId(2);
    Path path = Path.builder().srcSwitchId(switchId1).destSwitchId(switchId2).segments(Collections.singletonList(Segment.builder().srcSwitchId(switchId1).srcPort(1).destSwitchId(switchId2).destPort(2).build())).build();
    Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(switchId1).build()).destSwitch(Switch.builder().switchId(switchId2).build()).build();
    PathId pathId = new PathId("test_path_id");
    MeterId meterId = new MeterId(MeterId.MIN_FLOW_METER_ID);
    PathResources pathResources = PathResources.builder().pathId(pathId).meterId(meterId).build();
    FlowSegmentCookie cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1);
    FlowPath flowPath = builder.buildFlowPath(flow, pathResources, path, cookie, false, flow.getFlowId());
    assertEquals(switchId1, flowPath.getSrcSwitchId());
    assertEquals(switchId2, flowPath.getDestSwitchId());
    assertEquals(pathId, flowPath.getPathId());
    assertEquals(meterId, flowPath.getMeterId());
    assertEquals(cookie, flowPath.getCookie());
    assertThat(flowPath.getSegments(), hasSize(1));
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathResources(org.openkilda.wfm.share.flow.resources.FlowResources.PathResources) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Flow (org.openkilda.model.Flow)3 FlowPath (org.openkilda.model.FlowPath)3 MeterId (org.openkilda.model.MeterId)3 PathId (org.openkilda.model.PathId)3 SwitchId (org.openkilda.model.SwitchId)3 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)3 Path (org.openkilda.pce.Path)3 PathResources (org.openkilda.wfm.share.flow.resources.FlowResources.PathResources)3