use of org.openkilda.messaging.info.event.IslInfoData 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.IslInfoData in project open-kilda by telstra.
the class FlowCacheTest method buildNetworkTopology.
private void buildNetworkTopology(NetworkCache networkCache) {
networkCache.createSwitch(NetworkTopologyConstants.sw1);
networkCache.createSwitch(NetworkTopologyConstants.sw2);
networkCache.createSwitch(NetworkTopologyConstants.sw3);
networkCache.createSwitch(NetworkTopologyConstants.sw4);
networkCache.createSwitch(NetworkTopologyConstants.sw5);
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl12));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl21));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl24));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl42));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl52));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl25));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl53));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl35));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl54));
networkCache.createOrUpdateIsl(new IslInfoData(NetworkTopologyConstants.isl45));
}
use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.
the class LinksUtils method dumpLinks.
/**
* Returns links through Topology-Engine-Rest service.
*
* @return The JSON document of all flows
*/
public static List<IslInfoData> dumpLinks() {
System.out.println("\n==> Topology-Engine Dump Links");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response response = client.target(topologyEndpoint).path("/api/v1/topology/links").request().header(HttpHeaders.AUTHORIZATION, authHeaderValue).get();
System.out.println(String.format("===> Response = %s", response.toString()));
System.out.println(String.format("===> Topology-Engine Dump Links Time: %,.3f", getTimeDuration(current)));
try {
List<IslInfoData> links = new ObjectMapper().readValue(response.readEntity(String.class), new TypeReference<List<IslInfoData>>() {
});
// LOGGER.debug(String.format("====> Data = %s", links));
return links;
} catch (IOException ex) {
throw new TopologyProcessingException(format("Unable to parse the links '%s'.", response.toString()), ex);
}
}
use of org.openkilda.messaging.info.event.IslInfoData 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.IslInfoData in project open-kilda by telstra.
the class FlowPathTest method checkAvailableBandwidth.
@When("^all links have available bandwidth (\\d+)$")
public void checkAvailableBandwidth(int expectedAvailableBandwidth) throws InterruptedException {
List<IslInfoData> links = LinksUtils.dumpLinks();
for (IslInfoData link : links) {
int actualBandwidth = getBandwidth(expectedAvailableBandwidth, link.getPath().get(0).getSwitchId(), String.valueOf(link.getPath().get(0).getPortNo()));
assertEquals(expectedAvailableBandwidth, actualBandwidth);
}
}
Aggregations