use of org.openkilda.messaging.info.event.PathNode in project open-kilda by telstra.
the class AbstractSerializerTest method eventIslInfoTest.
@Test
public void eventIslInfoTest() throws IOException, ClassNotFoundException {
PathNode payload = new PathNode(SWITCH_ID, INPUT_PORT, 0);
IslInfoData data = new IslInfoData(0L, Collections.singletonList(payload), 1000000L, IslChangeType.DISCOVERED, 900000L);
assertEquals(SWITCH_ID + "_" + String.valueOf(INPUT_PORT), data.getId());
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() instanceof IslInfoData);
IslInfoData resultData = (IslInfoData) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(payload.hashCode(), resultData.getPath().get(0).hashCode());
}
use of org.openkilda.messaging.info.event.PathNode in project open-kilda by telstra.
the class FlowCacheTest method getPath.
@Test
public void getPath() throws Exception {
ImmutablePair<PathInfoData, PathInfoData> path = computer.getPath(makeFlow("generic", NetworkTopologyConstants.sw1, NetworkTopologyConstants.sw3, 0), defaultStrategy);
System.out.println(path.toString());
PathNode node;
List<PathNode> direct = new ArrayList<>();
node = new PathNode(NetworkTopologyConstants.isl12.getPath().get(0));
node.setSeqId(0);
direct.add(node);
node = new PathNode(NetworkTopologyConstants.isl12.getPath().get(1));
node.setSeqId(1);
direct.add(node);
node = new PathNode(NetworkTopologyConstants.isl25.getPath().get(0));
node.setSeqId(2);
direct.add(node);
node = new PathNode(NetworkTopologyConstants.isl25.getPath().get(1));
node.setSeqId(3);
direct.add(node);
node = new PathNode(NetworkTopologyConstants.isl53.getPath().get(0));
node.setSeqId(4);
direct.add(node);
node = new PathNode(NetworkTopologyConstants.isl53.getPath().get(1));
node.setSeqId(5);
direct.add(node);
PathInfoData expectedDirect = new PathInfoData(NetworkTopologyConstants.isl12.getLatency() + NetworkTopologyConstants.isl25.getLatency() + NetworkTopologyConstants.isl53.getLatency(), direct);
assertEquals(expectedDirect, path.getLeft());
List<PathNode> reverse = new ArrayList<>();
node = new PathNode(NetworkTopologyConstants.isl35.getPath().get(0));
node.setSeqId(0);
reverse.add(node);
node = new PathNode(NetworkTopologyConstants.isl35.getPath().get(1));
node.setSeqId(1);
reverse.add(node);
node = new PathNode(NetworkTopologyConstants.isl52.getPath().get(0));
node.setSeqId(2);
reverse.add(node);
node = new PathNode(NetworkTopologyConstants.isl52.getPath().get(1));
node.setSeqId(3);
reverse.add(node);
node = new PathNode(NetworkTopologyConstants.isl21.getPath().get(0));
node.setSeqId(4);
reverse.add(node);
node = new PathNode(NetworkTopologyConstants.isl21.getPath().get(1));
node.setSeqId(5);
reverse.add(node);
PathInfoData expectedReverse = new PathInfoData(NetworkTopologyConstants.isl12.getLatency() + NetworkTopologyConstants.isl25.getLatency() + NetworkTopologyConstants.isl53.getLatency(), reverse);
assertEquals(expectedReverse, path.getRight());
}
use of org.openkilda.messaging.info.event.PathNode in project open-kilda by telstra.
the class FlowCacheTest method getPathIntersection.
@Test
public void getPathIntersection() throws Exception {
networkCache.createIsl(NetworkTopologyConstants.isl14);
networkCache.createIsl(NetworkTopologyConstants.isl41);
PathNode node;
ImmutablePair<PathInfoData, PathInfoData> path43 = computer.getPath(makeFlow("collide-flow-one", NetworkTopologyConstants.sw4, NetworkTopologyConstants.sw3, 5), defaultStrategy);
System.out.println(path43);
List<PathNode> nodesForward43 = new ArrayList<>();
node = new PathNode(NetworkTopologyConstants.isl45.getPath().get(0));
node.setSeqId(0);
nodesForward43.add(node);
node = new PathNode(NetworkTopologyConstants.isl45.getPath().get(1));
node.setSeqId(1);
nodesForward43.add(node);
node = new PathNode(NetworkTopologyConstants.isl53.getPath().get(0));
node.setSeqId(2);
nodesForward43.add(node);
node = new PathNode(NetworkTopologyConstants.isl53.getPath().get(1));
node.setSeqId(3);
nodesForward43.add(node);
PathInfoData islForwardPath43 = new PathInfoData(NetworkTopologyConstants.isl45.getLatency() + NetworkTopologyConstants.isl53.getLatency(), nodesForward43);
List<PathNode> nodesReverse43 = new ArrayList<>();
node = new PathNode(NetworkTopologyConstants.isl35.getPath().get(0));
node.setSeqId(0);
nodesReverse43.add(node);
node = new PathNode(NetworkTopologyConstants.isl35.getPath().get(1));
node.setSeqId(1);
nodesReverse43.add(node);
node = new PathNode(NetworkTopologyConstants.isl54.getPath().get(0));
node.setSeqId(2);
nodesReverse43.add(node);
node = new PathNode(NetworkTopologyConstants.isl54.getPath().get(1));
node.setSeqId(3);
nodesReverse43.add(node);
PathInfoData islReversePath43 = new PathInfoData(NetworkTopologyConstants.isl35.getLatency() + NetworkTopologyConstants.isl54.getLatency(), nodesReverse43);
assertEquals(islForwardPath43, path43.left);
assertEquals(islReversePath43, path43.right);
ImmutablePair<PathInfoData, PathInfoData> path23 = computer.getPath(makeFlow("collide-flow-two", NetworkTopologyConstants.sw2, NetworkTopologyConstants.sw3, 5), defaultStrategy);
System.out.println(path23);
List<PathNode> nodesForward23 = new ArrayList<>();
node = new PathNode(NetworkTopologyConstants.isl25.getPath().get(0));
node.setSeqId(0);
nodesForward23.add(node);
node = new PathNode(NetworkTopologyConstants.isl25.getPath().get(1));
node.setSeqId(1);
nodesForward23.add(node);
PathNode node1 = new PathNode(NetworkTopologyConstants.isl53.getPath().get(0));
node1.setSeqId(2);
nodesForward23.add(node1);
PathNode node2 = new PathNode(NetworkTopologyConstants.isl53.getPath().get(1));
node2.setSeqId(3);
nodesForward23.add(node2);
PathInfoData islForwardPath23 = new PathInfoData(NetworkTopologyConstants.isl25.getLatency() + NetworkTopologyConstants.isl53.getLatency(), nodesForward23);
List<PathNode> nodesReverse23 = new ArrayList<>();
PathNode node3 = new PathNode(NetworkTopologyConstants.isl35.getPath().get(0));
node3.setSeqId(0);
nodesReverse23.add(node3);
PathNode node4 = new PathNode(NetworkTopologyConstants.isl35.getPath().get(1));
node4.setSeqId(1);
nodesReverse23.add(node4);
node = new PathNode(NetworkTopologyConstants.isl52.getPath().get(0));
node.setSeqId(2);
nodesReverse23.add(node);
node = new PathNode(NetworkTopologyConstants.isl52.getPath().get(1));
node.setSeqId(3);
nodesReverse23.add(node);
PathInfoData islReversePath23 = new PathInfoData(NetworkTopologyConstants.isl35.getLatency() + NetworkTopologyConstants.isl52.getLatency(), nodesReverse23);
assertEquals(islForwardPath23, path23.left);
assertEquals(islReversePath23, path23.right);
ImmutablePair<Set<PathNode>, Set<PathNode>> expected = new ImmutablePair<>(new HashSet<>(Arrays.asList(node1, node2)), new HashSet<>(Arrays.asList(node3, node4)));
assertEquals(expected, flowCache.getPathIntersection(path43, path23));
assertEquals(expected, flowCache.getPathIntersection(path23, path43));
}
use of org.openkilda.messaging.info.event.PathNode in project open-kilda by telstra.
the class FlowIgnoreBandwidthTest method availableISLBandwidthsBetweenSwitches.
@Then("^available ISL's bandwidths between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) and ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) is (\\d+)$")
public void availableISLBandwidthsBetweenSwitches(String source, String dest, long expected) {
List<IslInfoData> islLinks = LinksUtils.dumpLinks();
Long actual = null;
for (IslInfoData link : islLinks) {
if (link.getPath().size() != 2) {
throw new RuntimeException(String.format("ISL's link path contain %d records, expect 2", link.getPath().size()));
}
PathNode left = link.getPath().get(0);
PathNode right = link.getPath().get(1);
if (!source.equals(left.getSwitchId())) {
continue;
}
if (!dest.equals(right.getSwitchId())) {
continue;
}
actual = link.getAvailableBandwidth();
break;
}
Assert.assertNotNull(actual);
Assert.assertEquals("Actual bandwidth does not match expectations.", expected, (long) actual);
System.out.println(String.format("Available bandwidth between %s and %s is %d", source, dest, actual));
}
use of org.openkilda.messaging.info.event.PathNode in project open-kilda by telstra.
the class TopologyEventsBasicTest method a_link_is_dropped_in_the_middle.
@When("^a link is dropped in the middle$")
public void a_link_is_dropped_in_the_middle() throws Exception {
List<IslInfoData> links = LinksUtils.dumpLinks();
IslInfoData middleLink = getMiddleLink(links);
PathNode node = middleLink.getPath().get(0);
assertTrue(LinksUtils.islFail(getSwitchName(node.getSwitchId()), String.valueOf(node.getPortNo())));
}
Aggregations