use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class AvailableNetworkTest method shouldFillAffinityWeights.
@Test
public void shouldFillAffinityWeights() {
AvailableNetwork network = new AvailableNetwork();
addLink(network, SRC_SWITCH, DST_SWITCH, 7, 60, 10, 3);
addLink(network, SRC_SWITCH, DST_SWITCH, 8, 61, 10, 3);
addLink(network, SRC_SWITCH, DST_SWITCH, 9, 62, 10, 3);
network.processAffinitySegments(singletonList(buildPathSegment(SRC_SWITCH, DST_SWITCH, 7, 60, 0)));
Node srcSwitch = network.getSwitch(SRC_SWITCH);
for (Edge edge : srcSwitch.getOutgoingLinks()) {
if (edge.getSrcPort() == 7) {
assertEquals(0, edge.getAffinityGroupUseCounter());
continue;
}
assertEquals(1, edge.getAffinityGroupUseCounter());
}
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class AvailableNetworkTest method shouldFillDiversityWeightsIngress.
@Test
public void shouldFillDiversityWeightsIngress() {
AvailableNetwork network = new AvailableNetwork();
addLink(network, SRC_SWITCH, DST_SWITCH, 7, 60, 10, 3);
network.processDiversitySegments(singletonList(buildPathSegment(SRC_SWITCH, DST_SWITCH, 7, 60, 0)), DUMMY_FLOW);
Node srcSwitch = network.getSwitch(SRC_SWITCH);
Edge edge = srcSwitch.getOutgoingLinks().iterator().next();
assertEquals(1, edge.getDiversityGroupUseCounter());
assertEquals(1, edge.getDestSwitch().getDiversityGroupUseCounter());
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class AvailableNetworkTest method shouldSetEqualCostForPairedLinks.
@Test
public void shouldSetEqualCostForPairedLinks() {
AvailableNetwork network = new AvailableNetwork();
addLink(network, SRC_SWITCH, DST_SWITCH, 7, 60, 10, 3);
addLink(network, DST_SWITCH, SRC_SWITCH, 60, 7, 20, 3);
Node srcSwitch = network.getSwitch(SRC_SWITCH);
Node dstSwitch = network.getSwitch(DST_SWITCH);
Set<Edge> outgoingLinks = srcSwitch.getOutgoingLinks();
assertThat(outgoingLinks, Matchers.hasSize(1));
Edge outgoingIsl = outgoingLinks.iterator().next();
assertEquals(outgoingIsl.getDestSwitch(), dstSwitch);
assertEquals(10, outgoingIsl.getCost());
Set<Edge> incomingLinks = srcSwitch.getIncomingLinks();
assertThat(incomingLinks, Matchers.hasSize(1));
Edge incomingIsl = incomingLinks.iterator().next();
assertEquals(incomingIsl.getSrcSwitch(), dstSwitch);
assertEquals(20, incomingIsl.getCost());
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class AvailableNetworkTest method shouldFillEmptyDiversityWeightsForTerminatingSwitch.
@Test
public void shouldFillEmptyDiversityWeightsForTerminatingSwitch() {
AvailableNetwork network = new AvailableNetwork();
addLink(network, SRC_SWITCH, DST_SWITCH, 7, 60, 10, 3);
Flow flow = Flow.builder().flowId("flow-id").srcSwitch(Switch.builder().switchId(SRC_SWITCH).build()).destSwitch(Switch.builder().switchId(DST_SWITCH).build()).build();
network.processDiversitySegments(singletonList(buildPathSegment(SRC_SWITCH, DST_SWITCH, 7, 60, 0)), flow);
Node srcSwitch = network.getSwitch(SRC_SWITCH);
Edge edge = srcSwitch.getOutgoingLinks().iterator().next();
assertEquals(1, edge.getDiversityGroupUseCounter());
assertEquals(0, edge.getDestSwitch().getDiversityGroupUseCounter());
assertEquals(0, edge.getSrcSwitch().getDiversityGroupUseCounter());
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class AvailableNetworkTest method shouldFillDiversityWeightsTransit.
@Test
public void shouldFillDiversityWeightsTransit() {
AvailableNetwork network = new AvailableNetwork();
addLink(network, SRC_SWITCH, DST_SWITCH, 7, 60, 10, 3);
network.processDiversitySegments(singletonList(buildPathSegment(SRC_SWITCH, DST_SWITCH, 7, 60, 1)), DUMMY_FLOW);
Node srcSwitch = network.getSwitch(SRC_SWITCH);
Edge edge = srcSwitch.getOutgoingLinks().iterator().next();
assertEquals(1, edge.getDiversityGroupUseCounter());
assertEquals(1, edge.getDestSwitch().getDiversityGroupUseCounter());
}
Aggregations