Search in sources :

Example 1 with BfdSessionRepository

use of org.openkilda.persistence.repositories.BfdSessionRepository in project open-kilda by telstra.

the class NetworkBfdSessionServiceTest method surviveOffline.

@Test
public void surviveOffline() {
    // offline
    switchOnlineStatusMonitor.update(alphaLogicalEndpoint.getDatapath(), false);
    doAnswer(invocation -> invocation.getArgument(0)).when(bfdSessionRepository).add(any());
    mockSwitchLookup(alphaSwitch);
    mockSwitchLookup(betaSwitch);
    mockMissingBfdSession(alphaLogicalEndpoint);
    service.enableUpdate(alphaLogicalEndpoint, alphaEndpoint.getPortNumber(), new BfdSessionData(alphaToBetaIslRef, genericBfdProperties));
    verifyNoMoreInteractions(carrier);
    // online
    switchOnlineStatusMonitor.update(alphaLogicalEndpoint.getDatapath(), true);
    // ensure we react on enable requests
    verify(carrier).sendWorkerBfdSessionCreateRequest(argThat(argument -> argument.getTarget().getDatapath().equals(alphaLogicalEndpoint.getDatapath()) && argument.getRemote().getDatapath().equals(betaEndpoint.getDatapath())));
    verifyNoMoreInteractions(carrier);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BfdProperties(org.openkilda.model.BfdProperties) TransactionManager(org.openkilda.persistence.tx.TransactionManager) BfdSessionRepository(org.openkilda.persistence.repositories.BfdSessionRepository) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) EndpointStatusMonitor(org.openkilda.wfm.topology.network.utils.EndpointStatusMonitor) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) BfdSession(org.openkilda.model.BfdSession) IslReference(org.openkilda.wfm.share.model.IslReference) InetAddress(java.net.InetAddress) ArgumentCaptor(org.mockito.ArgumentCaptor) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Duration(java.time.Duration) PersistenceManager(org.openkilda.persistence.PersistenceManager) LinkStatus(org.openkilda.wfm.topology.network.model.LinkStatus) Before(org.junit.Before) IpSocketAddress(org.openkilda.model.IpSocketAddress) Switch(org.openkilda.model.Switch) TransactionCallback(org.openkilda.persistence.tx.TransactionCallback) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) Endpoint(org.openkilda.wfm.share.model.Endpoint) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) UnknownHostException(java.net.UnknownHostException) Mockito.verify(org.mockito.Mockito.verify) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Mockito(org.mockito.Mockito) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) BfdSessionData(org.openkilda.wfm.topology.network.model.BfdSessionData) SwitchId(org.openkilda.model.SwitchId) SwitchOnlineStatusMonitor(org.openkilda.wfm.topology.network.utils.SwitchOnlineStatusMonitor) BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) Optional(java.util.Optional) TransactionCallbackWithoutResult(org.openkilda.persistence.tx.TransactionCallbackWithoutResult) Assert(org.junit.Assert) Mockito.reset(org.mockito.Mockito.reset) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) BfdSessionData(org.openkilda.wfm.topology.network.model.BfdSessionData) Test(org.junit.Test)

Aggregations

InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Duration (java.time.Duration)1 Optional (java.util.Optional)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)1 Mock (org.mockito.Mock)1 Mockito (org.mockito.Mockito)1 Mockito.atLeastOnce (org.mockito.Mockito.atLeastOnce)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 Mockito.reset (org.mockito.Mockito.reset)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.verifyNoMoreInteractions (org.mockito.Mockito.verifyNoMoreInteractions)1 Mockito.when (org.mockito.Mockito.when)1 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)1