use of org.openkilda.pce.model.Edge in project open-kilda by telstra.
the class AvailableNetworkTest method shouldProcessAbsentDiversitySegment.
@Test
public void shouldProcessAbsentDiversitySegment() {
AvailableNetwork network = new AvailableNetwork();
addLink(network, SRC_SWITCH, DST_SWITCH, 7, 60, 10, 3);
network.processDiversitySegments(singletonList(buildPathSegment(SRC_SWITCH, DST_SWITCH, 1, 2, 0)), DUMMY_FLOW);
Node srcSwitch = network.getSwitch(SRC_SWITCH);
Edge edge = srcSwitch.getOutgoingLinks().iterator().next();
assertEquals(0, edge.getDiversityGroupUseCounter());
// as switches are in AvailableNetwork
assertEquals(1, edge.getDestSwitch().getDiversityGroupUseCounter());
assertEquals(1, edge.getSrcSwitch().getDiversityGroupUseCounter());
}
use of org.openkilda.pce.model.Edge 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.Edge in project open-kilda by telstra.
the class AvailableNetworkTest method shouldNotUpdateWeightsWhenTransitSegmentsNotInPop.
@Test
public void shouldNotUpdateWeightsWhenTransitSegmentsNotInPop() {
int cost = 700;
final WeightFunction weightFunction = WEIGHT_FUNCTION;
AvailableNetwork network = new AvailableNetwork();
addLink(network, SWITCH_1, SWITCH_2, 1, 2, cost, 5, POP_1, POP_2);
addLink(network, SWITCH_1, SWITCH_3, 2, 1, cost, 5, POP_1, null);
addLink(network, SWITCH_1, SWITCH_4, 3, 1, cost, 5, POP_1, POP_4);
addLink(network, SWITCH_5, SWITCH_4, 1, 2, cost, 5, POP_3, POP_4);
addLink(network, SWITCH_5, SWITCH_3, 2, 2, cost, 5, POP_3, null);
addLink(network, SWITCH_5, SWITCH_2, 3, 2, cost, 5, POP_3, POP_2);
network.processDiversitySegmentsWithPop(asList(buildPathWithSegment(SWITCH_1, SWITCH_3, 2, 1, POP_1, null, 0), buildPathWithSegment(SWITCH_3, SWITCH_5, 2, 2, null, POP_3, 1)));
for (Edge edge : network.edges) {
long currentWeight = weightFunction.apply(edge).toLong();
assertEquals(cost, currentWeight);
}
}
use of org.openkilda.pce.model.Edge 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.Edge 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());
}
Aggregations