Search in sources :

Example 46 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 47 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)

Example 48 with IslInfoData

use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.

the class TopologyEventsBasicTest method a_link_is_added_in_the_middle.

@When("^a link is added in the middle$")
public void a_link_is_added_in_the_middle() throws Exception {
    List<IslInfoData> links = LinksUtils.dumpLinks();
    IslInfoData middleLink = getMiddleLink(links);
    String srcSwitch = getSwitchName(middleLink.getPath().get(0).getSwitchId());
    String dstSwitch = getSwitchName(middleLink.getPath().get(1).getSwitchId());
    assertTrue("Link is not added", LinksUtils.addLink(srcSwitch, dstSwitch));
    TimeUnit.SECONDS.sleep(2);
}
Also used : IslInfoData(org.openkilda.messaging.info.event.IslInfoData) When(cucumber.api.java.en.When)

Example 49 with IslInfoData

use of org.openkilda.messaging.info.event.IslInfoData in project open-kilda by telstra.

the class TopologyEventsBasicTest method the_links_disappear_from_the_topology_engine.

@Then("^the links disappear from the topology engine\\.$")
public void the_links_disappear_from_the_topology_engine() throws Exception {
    // todo check whether we need to wait until links will disappear or we might delete them instantly when switch goes down
    TimeUnit.SECONDS.sleep(15);
    final SwitchInfoData middleSwitch = getMiddleSwitch(SwitchesUtils.dumpSwitches());
    final List<IslInfoData> links = LinksUtils.dumpLinks();
    List<IslInfoData> switchLinks = links.stream().filter(isl -> isLinkBelongToSwitch(middleSwitch.getSwitchId(), isl)).filter(isl -> isl.getState() == IslChangeType.DISCOVERED).collect(Collectors.toList());
    assertTrue("Switch shouldn't have any active links", switchLinks.isEmpty());
}
Also used : IntStream(java.util.stream.IntStream) StringUtils(org.apache.commons.lang.StringUtils) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) SwitchState(org.openkilda.messaging.info.event.SwitchState) LinksUtils(org.openkilda.LinksUtils) Assert.assertTrue(org.junit.Assert.assertTrue) IslChangeType(org.openkilda.messaging.info.event.IslChangeType) PathNode(org.openkilda.messaging.info.event.PathNode) Collectors(java.util.stream.Collectors) TestTopologyBuilder(org.openkilda.topo.builders.TestTopologyBuilder) NumberUtils(org.apache.commons.lang.math.NumberUtils) Assert.assertThat(org.junit.Assert.assertThat) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.is(org.hamcrest.Matchers.is) SwitchesUtils(org.openkilda.SwitchesUtils) PendingException(cucumber.api.PendingException) Comparator(java.util.Comparator) Then(cucumber.api.java.en.Then) When(cucumber.api.java.en.When) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Then(cucumber.api.java.en.Then)

Example 50 with IslInfoData

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

Aggregations

IslInfoData (org.openkilda.messaging.info.event.IslInfoData)51 PathNode (org.openkilda.messaging.info.event.PathNode)29 Test (org.junit.Test)25 Endpoint (org.openkilda.wfm.share.model.Endpoint)12 SwitchId (org.openkilda.model.SwitchId)10 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)9 Isl (org.openkilda.model.Isl)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)8 ArrayList (java.util.ArrayList)6 When (cucumber.api.java.en.When)5 IOException (java.io.IOException)5 InfoData (org.openkilda.messaging.info.InfoData)5 Switch (org.openkilda.model.Switch)5 Then (cucumber.api.java.en.Then)4 List (java.util.List)4 CommandMessage (org.openkilda.messaging.command.CommandMessage)4 Comparator (java.util.Comparator)3 Collectors (java.util.stream.Collectors)3 Message (org.openkilda.messaging.Message)3 CacheException (org.openkilda.messaging.error.CacheException)3