Search in sources :

Example 1 with BfdSession

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

the class FermaBfdSessionRepositoryTest method getDiscriminator.

private int getDiscriminator(SwitchId switchId, int port, int randomDiscriminator) throws ConstraintViolationException {
    Optional<BfdSession> foundPort = repository.findBySwitchIdAndPort(switchId, port);
    if (foundPort.isPresent()) {
        return foundPort.get().getDiscriminator();
    }
    BfdSession bfdSession = createBfdSession();
    bfdSession.setDiscriminator(randomDiscriminator);
    return bfdSession.getDiscriminator();
}
Also used : BfdSession(org.openkilda.model.BfdSession)

Example 2 with BfdSession

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

the class FermaBfdSessionRepositoryTest method discriminatorConflict.

@Ignore("Need to fix: in-memory persistence doesn't impose constraints")
@Test(expected = ConstraintViolationException.class)
public void discriminatorConflict() {
    createBfdSession();
    BfdSession bfdSession2 = createBfdSession();
    bfdSession2.setPort(TEST_PORT + 1);
}
Also used : BfdSession(org.openkilda.model.BfdSession) Ignore(org.junit.Ignore) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 3 with BfdSession

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

the class FermaBfdSessionRepositoryTest method createBfdSession.

private BfdSession createBfdSession() {
    BfdSession bfdSession = BfdSession.builder().switchId(TEST_SWITCH_ID).port(TEST_PORT).physicalPort(PHYSICAL_PORT).discriminator(TEST_DISCRIMINATOR).build();
    repository.add(bfdSession);
    return bfdSession;
}
Also used : BfdSession(org.openkilda.model.BfdSession)

Example 4 with BfdSession

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

the class BfdSessionFsm method saveEffectivePropertiesTransaction.

private void saveEffectivePropertiesTransaction() {
    Optional<BfdSession> session = loadBfdSession();
    if (session.isPresent()) {
        BfdSession dbView = session.get();
        logInfo("save effective session properties {}", properties);
        dbView.setInterval(properties.getInterval());
        dbView.setMultiplier(properties.getMultiplier());
    } else {
        logError("DB session is missing, unable to save effective properties values");
    }
}
Also used : BfdSession(org.openkilda.model.BfdSession) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession)

Example 5 with BfdSession

use of org.openkilda.model.BfdSession 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)

Aggregations

BfdSession (org.openkilda.model.BfdSession)11 Test (org.junit.Test)8 NoviBfdSession (org.openkilda.messaging.model.NoviBfdSession)6 BfdSessionResponse (org.openkilda.messaging.floodlight.response.BfdSessionResponse)4 BfdSessionData (org.openkilda.wfm.topology.network.model.BfdSessionData)4 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 Ignore (org.junit.Ignore)1 BfdProperties (org.openkilda.model.BfdProperties)1