Search in sources :

Example 31 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkUniIslServiceTest method verifyIslCanBeDiscovered.

private void verifyIslCanBeDiscovered(NetworkUniIslService service, Isl link) {
    Endpoint endpointA = Endpoint.of(link.getSrcSwitchId(), link.getSrcPort());
    Endpoint endpointZ = Endpoint.of(link.getDestSwitchId(), link.getDestPort());
    service.uniIslDiscovery(endpointA, IslMapper.INSTANCE.map(link));
    verify(carrier).notifyIslUp(endpointA, new IslReference(endpointA, endpointZ), new IslDataHolder(link));
    verify(carrier).exhaustedPollModeUpdateRequest(endpointA, false);
    verifyNoMoreInteractions(carrier);
    reset(carrier);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) IslReference(org.openkilda.wfm.share.model.IslReference) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder)

Example 32 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkUniIslServiceTest method newIslWithHistory.

@Test
public void newIslWithHistory() {
    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();
    service.uniIslSetup(endpoint1, islAtoB);
    service.uniIslSetup(endpoint2, islAtoB2);
    // System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).setupIslFromHistory(endpoint1, IslReference.of(islAtoB), islAtoB);
    verify(carrier).setupIslFromHistory(endpoint2, IslReference.of(islAtoB2), islAtoB2);
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) Test(org.junit.Test)

Example 33 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkUniIslServiceTest method fromUpToDown.

@Test
public void fromUpToDown() {
    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 islA1toB1 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islA2toB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
    service.uniIslSetup(endpoint1, islA1toB1);
    service.uniIslSetup(endpoint2, islA2toB2);
    IslInfoData disco1 = IslMapper.INSTANCE.map(islA1toB1);
    IslInfoData disco2 = IslMapper.INSTANCE.map(islA2toB2);
    service.uniIslDiscovery(endpoint1, disco1);
    service.uniIslDiscovery(endpoint2, disco2);
    resetMocks();
    service.uniIslFail(endpoint1);
    service.uniIslPhysicalDown(endpoint2);
    // System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).notifyIslDown(endpoint1, IslReference.of(islA1toB1), IslDownReason.POLL_TIMEOUT);
    verify(carrier).notifyIslDown(endpoint2, IslReference.of(islA2toB2), IslDownReason.PORT_DOWN);
}
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) Test(org.junit.Test)

Example 34 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class NetworkWatcherServiceTest method discoveryBeforeConfirmation.

@Test
public void discoveryBeforeConfirmation() {
    final int awaitTime = 10;
    PathNode source = new PathNode(new SwitchId(1), 1, 0);
    PathNode destination = new PathNode(new SwitchId(2), 1, 0);
    NetworkWatcherService w = makeService(awaitTime);
    w.addWatch(Endpoint.of(source.getSwitchId(), source.getPortNo()), 1);
    verify(carrier, times(1)).sendDiscovery(any(DiscoverIslCommandData.class));
    IslInfoData islAlphaBeta = IslInfoData.builder().source(source).destination(destination).packetId(0L).build();
    w.discovery(islAlphaBeta);
    w.confirmation(new Endpoint(source), 0);
    w.tick(awaitTime + 1);
    verify(carrier).oneWayDiscoveryReceived(eq(new Endpoint(source)), eq(0L), eq(islAlphaBeta), anyLong());
    verify(carrier, never()).discoveryFailed(eq(new Endpoint(source)), anyLong(), anyLong());
    assertThat(w.getConfirmedPackets().size(), is(0));
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) Endpoint(org.openkilda.wfm.share.model.Endpoint) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test)

Example 35 with Endpoint

use of org.openkilda.wfm.share.model.Endpoint in project open-kilda by telstra.

the class SwitchHandler method makePortTuple.

private Values makePortTuple(PortCommand command) {
    Endpoint endpoint = command.getEndpoint();
    CommandContext context = forkContext(endpoint.toString());
    return new Values(endpoint.getDatapath(), endpoint.getPortNumber(), command, context);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values)

Aggregations

Endpoint (org.openkilda.wfm.share.model.Endpoint)72 Test (org.junit.Test)33 Isl (org.openkilda.model.Isl)17 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)13 SwitchId (org.openkilda.model.SwitchId)10 Switch (org.openkilda.model.Switch)8 IslReference (org.openkilda.wfm.share.model.IslReference)8 PathNode (org.openkilda.messaging.info.event.PathNode)7 Instant (java.time.Instant)6 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 DiscoverIslCommandData (org.openkilda.messaging.command.discovery.DiscoverIslCommandData)4 IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)4 Values (org.apache.storm.tuple.Values)3 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)3 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 CommandContext (org.openkilda.wfm.CommandContext)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashMap (java.util.HashMap)2