use of org.openkilda.model.BfdSession 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);
}
use of org.openkilda.model.BfdSession in project open-kilda by telstra.
the class FermaBfdSessionRepositoryTest method shouldDeleteBfdPort.
@Test
public void shouldDeleteBfdPort() {
BfdSession bfdSession = createBfdSession();
assertEquals(1, repository.findAll().size());
transactionManager.doInTransaction(() -> repository.remove(bfdSession));
assertEquals(0, repository.findAll().size());
}
use of org.openkilda.model.BfdSession in project open-kilda by telstra.
the class FermaBfdSessionRepositoryTest method shouldFindBySwitchIdAndPort.
@Test
public void shouldFindBySwitchIdAndPort() {
BfdSession bfdSession = createBfdSession();
BfdSession foundPort = repository.findBySwitchIdAndPort(TEST_SWITCH_ID, TEST_PORT).get();
assertEquals(bfdSession.getDiscriminator(), foundPort.getDiscriminator());
}
use of org.openkilda.model.BfdSession in project open-kilda by telstra.
the class NetworkBfdSessionServiceTest method enableEnable.
@Test
public void enableEnable() {
createOperationalSession();
// active
when(carrier.sendWorkerBfdSessionDeleteRequest(any(NoviBfdSession.class))).thenReturn(removeRequestKey);
BfdProperties update = BfdProperties.builder().interval(Duration.ofMillis(genericBfdProperties.getInterval().toMillis() + 100)).multiplier((short) (genericBfdProperties.getMultiplier() + 1)).build();
service.enableUpdate(alphaLogicalEndpoint, alphaEndpoint.getPortNumber(), new BfdSessionData(alphaToBetaIslRef, update));
verify(carrier).bfdKillNotification(alphaEndpoint);
ArgumentCaptor<NoviBfdSession> speakerBfdRequestArgument = ArgumentCaptor.forClass(NoviBfdSession.class);
verify(carrier).sendWorkerBfdSessionDeleteRequest(speakerBfdRequestArgument.capture());
NoviBfdSession speakerBfdSession = speakerBfdRequestArgument.getValue();
verifyNoMoreInteractions(carrier);
resetCarrier();
// reset
mockMissingBfdSession(alphaLogicalEndpoint);
when(carrier.sendWorkerBfdSessionCreateRequest(any(NoviBfdSession.class))).thenReturn(setupRequestKey);
BfdSessionResponse removeResponse = new BfdSessionResponse(speakerBfdSession, null);
service.speakerResponse(alphaLogicalEndpoint, removeRequestKey, removeResponse);
verify(carrier).sendWorkerBfdSessionCreateRequest(speakerBfdRequestArgument.capture());
speakerBfdSession = speakerBfdRequestArgument.getValue();
Assert.assertEquals(update.getInterval().toMillis(), speakerBfdSession.getIntervalMs());
Assert.assertEquals(update.getMultiplier(), speakerBfdSession.getMultiplier());
verify(carrier).sessionRotateRequest(alphaLogicalEndpoint, false);
verifyNoMoreInteractions(carrier);
resetCarrier();
reset(bfdSessionRepository);
// do_setup
BfdSession dbView = BfdSession.builder().switchId(alphaLogicalEndpoint.getDatapath()).port(alphaLogicalEndpoint.getPortNumber()).physicalPort(alphaEndpoint.getPortNumber()).interval(genericBfdProperties.getInterval()).multiplier(genericBfdProperties.getMultiplier()).build();
when(bfdSessionRepository.findBySwitchIdAndPort(alphaLogicalEndpoint.getDatapath(), alphaLogicalEndpoint.getPortNumber())).thenReturn(Optional.of(dbView));
BfdSessionResponse setupResponse = new BfdSessionResponse(speakerBfdSession, null);
service.speakerResponse(alphaLogicalEndpoint, setupRequestKey, setupResponse);
endpointStatusMonitor.update(alphaLogicalEndpoint, LinkStatus.UP);
verify(carrier).bfdUpNotification(alphaEndpoint);
verifyNoMoreInteractions(carrier);
resetCarrier();
Assert.assertEquals(update.getInterval(), dbView.getInterval());
Assert.assertEquals(update.getMultiplier(), BfdProperties.normalizeMultiplier(dbView.getMultiplier()));
// active
// ensure we are reaction on link status update
endpointStatusMonitor.update(alphaLogicalEndpoint, LinkStatus.DOWN);
verify(carrier).bfdDownNotification(alphaEndpoint);
}
use of org.openkilda.model.BfdSession in project open-kilda by telstra.
the class NetworkBfdSessionServiceTest method enableForAllocatedDiscriminatorByNotCreatedSession.
@Test
public void enableForAllocatedDiscriminatorByNotCreatedSession() {
BfdSession prehistory = makeBfdSessionBuilder(1).interval(null).multiplier((short) 0).build();
mockBfdSessionLookup(prehistory);
mockSwitchLookup(alphaSwitch);
mockSwitchLookup(betaSwitch);
switchOnlineStatusMonitor.update(prehistory.getSwitchId(), true);
when(carrier.sendWorkerBfdSessionCreateRequest(any(NoviBfdSession.class))).thenReturn(setupRequestKey);
service.enableUpdate(Endpoint.of(prehistory.getSwitchId(), prehistory.getPort()), prehistory.getPhysicalPort(), new BfdSessionData(alphaToBetaIslRef, genericBfdProperties));
verify(carrier).sendWorkerBfdSessionCreateRequest(any(NoviBfdSession.class));
verifyNoMoreInteractions(carrier);
}
Aggregations