Search in sources :

Example 76 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class NetworkSwitchServiceTest method switchFromHistoryToOffline.

@Test
public void switchFromHistoryToOffline() {
    when(switchRepository.findById(alphaDatapath)).thenReturn(Optional.of(Switch.builder().switchId(alphaDatapath).build()));
    HistoryFacts history = new HistoryFacts(alphaDatapath, SwitchStatus.INACTIVE);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islAtoB = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islAtoB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
    history.addLink(islAtoB);
    history.addLink(islAtoB2);
    NetworkSwitchService service = new NetworkSwitchService(carrier, persistenceManager, options);
    service.switchAddWithHistory(history);
    // System.out.println(mockingDetails(carrier).printInvocations());
    // System.out.println(mockingDetails(switchRepository).printInvocations());
    verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, 1), islAtoB);
    verify(carrier).setupPortHandler(Endpoint.of(alphaDatapath, 2), islAtoB2);
    verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, 1), OnlineStatus.OFFLINE);
    verify(carrier).setOnlineMode(Endpoint.of(alphaDatapath, 2), OnlineStatus.OFFLINE);
}
Also used : Isl(org.openkilda.model.Isl) Switch(org.openkilda.model.Switch) HistoryFacts(org.openkilda.wfm.topology.network.model.facts.HistoryFacts) Test(org.junit.Test)

Example 77 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class NetworkUniIslServiceTest method fromUptoBfdToUp.

@Test
public void fromUptoBfdToUp() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islA1toB1 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    service.uniIslSetup(endpoint1, islA1toB1);
    IslInfoData disco1 = IslMapper.INSTANCE.map(islA1toB1);
    service.uniIslDiscovery(endpoint1, disco1);
    resetMocks();
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.UP);
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.KILL);
    // System.out.println(mockingDetails(carrier).printInvocations());
    InOrder order = inOrder(carrier);
    order.verify(carrier).notifyBfdStatus(endpoint1, IslReference.of(islA1toB1), BfdStatusUpdate.UP);
    order.verify(carrier).notifyBfdStatus(endpoint1, IslReference.of(islA1toB1), BfdStatusUpdate.KILL);
}
Also used : Isl(org.openkilda.model.Isl) InOrder(org.mockito.InOrder) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) Test(org.junit.Test)

Example 78 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class NetworkUniIslServiceTest method fromUnknownToUpAndDiscoveryWithMove.

@Test
public void fromUnknownToUpAndDiscoveryWithMove() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islA1toB1 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islA1toB3 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(3).build();
    service.uniIslSetup(endpoint1, null);
    resetMocks();
    IslInfoData disco1 = IslMapper.INSTANCE.map(islA1toB1);
    IslInfoData disco2 = IslMapper.INSTANCE.map(islA1toB3);
    service.uniIslDiscovery(endpoint1, disco1);
    service.uniIslDiscovery(endpoint1, disco2);
    // System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).notifyIslUp(endpoint1, IslReference.of(islA1toB1), new IslDataHolder(islA1toB1));
    verify(carrier).notifyIslMove(endpoint1, IslReference.of(islA1toB1));
    verify(carrier).notifyIslUp(endpoint1, IslReference.of(islA1toB3), new IslDataHolder(islA1toB3));
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Test(org.junit.Test)

Example 79 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class NetworkUniIslServiceTest method newIslFromUnknownToDownToUp.

@Test
public void newIslFromUnknownToDownToUp() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Endpoint endpoint2 = Endpoint.of(alphaDatapath, 2);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islAtoB = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islAtoB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
    Isl islAtoB3 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(3).build();
    service.uniIslSetup(endpoint1, islAtoB);
    service.uniIslSetup(endpoint2, null);
    service.uniIslFail(endpoint1);
    service.uniIslPhysicalDown(endpoint2);
    resetMocks();
    IslInfoData disco1 = IslMapper.INSTANCE.map(islAtoB3);
    IslInfoData disco2 = IslMapper.INSTANCE.map(islAtoB2);
    service.uniIslDiscovery(endpoint1, disco1);
    service.uniIslDiscovery(endpoint2, disco2);
    System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).notifyIslMove(endpoint1, IslReference.of(islAtoB));
    verify(carrier).notifyIslUp(endpoint1, IslReference.of(islAtoB3), new IslDataHolder(islAtoB2));
    verify(carrier).notifyIslUp(endpoint2, IslReference.of(islAtoB2), new IslDataHolder(islAtoB2));
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Test(org.junit.Test)

Example 80 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class NetworkUniIslServiceTest method fromUptoBfdToDown.

@Test
public void fromUptoBfdToDown() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islA1toB1 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    service.uniIslSetup(endpoint1, islA1toB1);
    IslInfoData disco1 = IslMapper.INSTANCE.map(islA1toB1);
    service.uniIslDiscovery(endpoint1, disco1);
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.UP);
    resetMocks();
    service.uniIslPhysicalDown(endpoint1);
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.UP);
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.DOWN);
    service.uniIslBfdStatusUpdate(endpoint1, BfdStatusUpdate.UP);
    // System.out.println(mockingDetails(carrier).printInvocations());
    InOrder order = inOrder(carrier);
    IslReference reference = IslReference.of(islA1toB1);
    order.verify(carrier).notifyIslDown(endpoint1, reference, IslDownReason.PORT_DOWN);
    order.verify(carrier).notifyBfdStatus(endpoint1, reference, BfdStatusUpdate.UP);
    order.verify(carrier).notifyBfdStatus(endpoint1, reference, BfdStatusUpdate.DOWN);
    order.verify(carrier).notifyBfdStatus(endpoint1, reference, BfdStatusUpdate.UP);
}
Also used : Isl(org.openkilda.model.Isl) InOrder(org.mockito.InOrder) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslReference(org.openkilda.wfm.share.model.IslReference) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) Test(org.junit.Test)

Aggregations

Switch (org.openkilda.model.Switch)230 Test (org.junit.Test)126 Flow (org.openkilda.model.Flow)68 SwitchId (org.openkilda.model.SwitchId)67 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)46 FlowPath (org.openkilda.model.FlowPath)34 PathId (org.openkilda.model.PathId)32 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)32 PathComputer (org.openkilda.pce.PathComputer)28 GetPathsResult (org.openkilda.pce.GetPathsResult)23 List (java.util.List)22 SwitchProperties (org.openkilda.model.SwitchProperties)21 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)20 SpeakerData (org.openkilda.rulemanager.SpeakerData)19 String.format (java.lang.String.format)17 Set (java.util.Set)17 Isl (org.openkilda.model.Isl)15 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13