Search in sources :

Example 21 with IslInfoData

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());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Test(org.junit.Test)

Example 22 with IslInfoData

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));
}
Also used : IslInfoData(org.openkilda.messaging.info.event.IslInfoData)

Example 23 with IslInfoData

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);
    }
}
Also used : Response(javax.ws.rs.core.Response) TopologyProcessingException(org.openkilda.topo.exceptions.TopologyProcessingException) List(java.util.List) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IOException(java.io.IOException) Client(javax.ws.rs.client.Client) ClientConfig(org.glassfish.jersey.client.ClientConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 24 with IslInfoData

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));
}
Also used : IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Then(cucumber.api.java.en.Then)

Example 25 with IslInfoData

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);
    }
}
Also used : IslInfoData(org.openkilda.messaging.info.event.IslInfoData) When(cucumber.api.java.en.When)

Aggregations

IslInfoData (org.openkilda.messaging.info.event.IslInfoData)29 PathNode (org.openkilda.messaging.info.event.PathNode)16 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 When (cucumber.api.java.en.When)5 IOException (java.io.IOException)5 CommandMessage (org.openkilda.messaging.command.CommandMessage)5 InfoData (org.openkilda.messaging.info.InfoData)5 Then (cucumber.api.java.en.Then)4 List (java.util.List)4 Message (org.openkilda.messaging.Message)4 Comparator (java.util.Comparator)3 Collectors (java.util.stream.Collectors)3 CacheException (org.openkilda.messaging.error.CacheException)3 Isl (org.openkilda.topology.domain.Isl)3 PendingException (cucumber.api.PendingException)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2