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