Search in sources :

Example 26 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 27 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 28 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)

Example 29 with IslInfoData

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

the class TopologyEventsBasicTest method isSwitchHasLessThanTwoLinks.

private boolean isSwitchHasLessThanTwoLinks(String switchId, List<IslInfoData> links) {
    int inputsAmount = 0;
    int outputsAmount = 0;
    for (IslInfoData isl : links) {
        for (PathNode node : isl.getPath()) {
            if (switchId.equalsIgnoreCase(node.getSwitchId())) {
                if (node.getSeqId() == 0) {
                    outputsAmount++;
                } else if (node.getSeqId() == 1) {
                    inputsAmount++;
                }
            }
        }
    }
    // check whether switch has more than one link in both direction (sequence id 0 and 1)
    return inputsAmount <= NumberUtils.INTEGER_ONE && outputsAmount <= NumberUtils.INTEGER_ONE;
}
Also used : IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode)

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