Search in sources :

Example 1 with BfdSessionResponse

use of org.openkilda.messaging.floodlight.response.BfdSessionResponse in project open-kilda by telstra.

the class NetworkBfdSessionServiceTest method distinguishRecoverableErrors.

@Test
public void distinguishRecoverableErrors() {
    // prepare DB record to force cleanup on start
    BfdSession initialBfdSession = makeBfdSession(1);
    NoviBfdSession removeRequestPayload = forceCleanupAfterInit(initialBfdSession);
    // push speaker error response
    when(bfdSessionRepository.findBySwitchIdAndPort(initialBfdSession.getSwitchId(), initialBfdSession.getPort())).thenReturn(Optional.of(initialBfdSession)).thenReturn(Optional.empty());
    doAnswer(invocation -> invocation.getArgument(0)).when(bfdSessionRepository).add(any());
    BfdSessionResponse removeResponse = new BfdSessionResponse(removeRequestPayload, NoviBfdSession.Errors.NOVI_BFD_DISCRIMINATOR_NOT_FOUND_ERROR);
    // complete cleanup and make session create request
    service.speakerResponse(alphaLogicalEndpoint, removeRequestKey, removeResponse);
    verify(bfdSessionRepository, atLeastOnce()).findBySwitchIdAndPort(alphaLogicalEndpoint.getDatapath(), alphaLogicalEndpoint.getPortNumber());
    verify(bfdSessionRepository).remove(initialBfdSession);
    verify(bfdSessionRepository).add(any(BfdSession.class));
    verify(carrier).sessionRotateRequest(alphaLogicalEndpoint, false);
    verify(carrier).sendWorkerBfdSessionCreateRequest(any(NoviBfdSession.class));
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(bfdSessionRepository);
}
Also used : BfdSession(org.openkilda.model.BfdSession) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) Test(org.junit.Test)

Example 2 with BfdSessionResponse

use of org.openkilda.messaging.floodlight.response.BfdSessionResponse in project open-kilda by telstra.

the class NetworkBfdSessionServiceTest method failOnCriticalErrors.

@Test
public void failOnCriticalErrors() {
    BfdSession initialBfdSession = makeBfdSession(1);
    NoviBfdSession removeRequestPayload = forceCleanupAfterInit(initialBfdSession);
    // push speaker error(critical) response
    mockBfdSessionLookup(initialBfdSession);
    BfdSessionResponse removeResponse = new BfdSessionResponse(removeRequestPayload, NoviBfdSession.Errors.SWITCH_RESPONSE_ERROR);
    service.speakerResponse(alphaLogicalEndpoint, removeRequestKey, removeResponse);
    verify(carrier).bfdFailNotification(alphaEndpoint);
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(bfdSessionRepository);
    resetCarrier();
    reset(bfdSessionRepository);
    // make one more remove attempt on next enable/update request
    service.enableUpdate(alphaLogicalEndpoint, alphaEndpoint.getPortNumber(), new BfdSessionData(alphaToBetaIslRef, genericBfdProperties));
    verify(carrier).sendWorkerBfdSessionDeleteRequest(removeRequestPayload);
    verifyNoMoreInteractions(carrier);
}
Also used : BfdSessionData(org.openkilda.wfm.topology.network.model.BfdSessionData) BfdSession(org.openkilda.model.BfdSession) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) Test(org.junit.Test)

Example 3 with BfdSessionResponse

use of org.openkilda.messaging.floodlight.response.BfdSessionResponse in project open-kilda by telstra.

the class NetworkBfdSessionServiceTest method offlineDuringCleaning.

@Test
public void offlineDuringCleaning() {
    createOperationalSession();
    String requestKey = "request-key-#";
    // disable
    when(carrier.sendWorkerBfdSessionDeleteRequest(any(NoviBfdSession.class))).thenReturn(requestKey + "1");
    service.disable(alphaEndpoint);
    ArgumentCaptor<NoviBfdSession> removeBfdSessionArgument = ArgumentCaptor.forClass(NoviBfdSession.class);
    verify(carrier).sendWorkerBfdSessionDeleteRequest(removeBfdSessionArgument.capture());
    resetCarrier();
    // offline
    switchOnlineStatusMonitor.update(alphaLogicalEndpoint.getDatapath(), false);
    verifyNoMoreInteractions(carrier);
    resetCarrier();
    // online
    when(carrier.sendWorkerBfdSessionDeleteRequest(any(NoviBfdSession.class))).thenReturn(requestKey + "2");
    switchOnlineStatusMonitor.update(alphaLogicalEndpoint.getDatapath(), true);
    endpointStatusMonitor.update(alphaLogicalEndpoint, LinkStatus.DOWN);
    verify(carrier).sendWorkerBfdSessionDeleteRequest(removeBfdSessionArgument.getValue());
    verifyNoMoreInteractions(carrier);
    // ignore outdated timeout
    service.speakerTimeout(alphaLogicalEndpoint, requestKey + "1");
    verifyNoMoreInteractions(carrier);
    service.speakerResponse(alphaLogicalEndpoint, requestKey + "2", new BfdSessionResponse(removeBfdSessionArgument.getValue(), NoviBfdSession.Errors.NOVI_BFD_DISCRIMINATOR_NOT_FOUND_ERROR));
    verify(carrier).sessionRotateRequest(alphaLogicalEndpoint, false);
    verify(carrier).sessionCompleteNotification(alphaEndpoint);
    verifyNoMoreInteractions(carrier);
}
Also used : BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) Test(org.junit.Test)

Example 4 with BfdSessionResponse

use of org.openkilda.messaging.floodlight.response.BfdSessionResponse in project open-kilda by telstra.

the class BfdSessionActionTest method mustFilterResponsesByRequestKey.

@Test
public void mustFilterResponsesByRequestKey() {
    String requestKey = "request-key";
    BfdSessionAction action = new BfdSessionActionImpl(requestKey, false);
    // invalid
    BfdSessionResponse response = new BfdSessionResponse(payload, null);
    Assert.assertFalse(action.consumeSpeakerResponse(requestKey + "+invalid", response).isPresent());
    // valid
    ActionResult result = action.consumeSpeakerResponse(requestKey, new BfdSessionResponse(payload, null)).orElseThrow(() -> new AssertionError("Action must produce result"));
    Assert.assertTrue(result.isSuccess());
    // extra result
    ActionResult result2 = action.consumeSpeakerResponse(requestKey, new BfdSessionResponse(payload, Errors.NOVI_BFD_UNKNOWN_ERROR)).orElseThrow(() -> new AssertionError("Action must produce result"));
    // because extra result was ignored
    Assert.assertTrue(result2.isSuccess());
}
Also used : ActionResult(org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult) BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) Test(org.junit.Test)

Example 5 with BfdSessionResponse

use of org.openkilda.messaging.floodlight.response.BfdSessionResponse in project open-kilda by telstra.

the class AbstractBfdSessionActionTest method completeOnSpeakerError.

@Test
public void completeOnSpeakerError() {
    String requestKey = "BFD-session-setup-key";
    BfdSessionAction action = makeAction(requestKey);
    BfdSessionResponse response = new BfdSessionResponse(payload, NoviBfdSession.Errors.SWITCH_RESPONSE_ERROR);
    BfdSessionAction.ActionResult result = action.consumeSpeakerResponse(requestKey, response).orElseThrow(expectResultError);
    Assert.assertFalse(result.isSuccess());
    Assert.assertEquals(NoviBfdSession.Errors.SWITCH_RESPONSE_ERROR, result.getErrorCode());
}
Also used : BfdSessionResponse(org.openkilda.messaging.floodlight.response.BfdSessionResponse) Test(org.junit.Test)

Aggregations

BfdSessionResponse (org.openkilda.messaging.floodlight.response.BfdSessionResponse)10 Test (org.junit.Test)9 NoviBfdSession (org.openkilda.messaging.model.NoviBfdSession)6 BfdSession (org.openkilda.model.BfdSession)5 BfdSessionData (org.openkilda.wfm.topology.network.model.BfdSessionData)4 ActionResult (org.openkilda.wfm.topology.network.controller.bfd.BfdSessionAction.ActionResult)3 BfdProperties (org.openkilda.model.BfdProperties)1