Search in sources :

Example 16 with Node

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());
    }
}
Also used : Node(org.openkilda.pce.model.Node) Edge(org.openkilda.pce.model.Edge) Test(org.junit.Test)

Example 17 with Node

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());
}
Also used : Node(org.openkilda.pce.model.Node) Edge(org.openkilda.pce.model.Edge) Test(org.junit.Test)

Example 18 with Node

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());
}
Also used : Node(org.openkilda.pce.model.Node) Edge(org.openkilda.pce.model.Edge) Test(org.junit.Test)

Example 19 with Node

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());
}
Also used : Node(org.openkilda.pce.model.Node) Edge(org.openkilda.pce.model.Edge) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 20 with Node

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());
}
Also used : Node(org.openkilda.pce.model.Node) Edge(org.openkilda.pce.model.Edge) Test(org.junit.Test)

Aggregations

Node (org.openkilda.pce.model.Node)20 Edge (org.openkilda.pce.model.Edge)15 Test (org.junit.Test)8 SwitchId (org.openkilda.model.SwitchId)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)3 ArrayList (java.util.ArrayList)2 Collections.emptyList (java.util.Collections.emptyList)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Flow (org.openkilda.model.Flow)2 PathSegment (org.openkilda.model.PathSegment)2 FindOneDirectionPathResult (org.openkilda.pce.model.FindOneDirectionPathResult)2 PathWeight (org.openkilda.pce.model.PathWeight)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1