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);
}
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);
}
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));
}
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));
}
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);
}
Aggregations