use of org.openkilda.wfm.topology.network.model.BfdSessionData in project open-kilda by telstra.
the class NetworkBfdLogicalPortServiceTest method replacePropertiesDuringCreate.
@Test
public void replacePropertiesDuringCreate() {
NetworkBfdLogicalPortService service = makeService();
switchOnlineStatusMonitor.update(physical.getDatapath(), true);
final String requestId = "port-create-request";
when(carrier.createLogicalPort(eq(logical), eq(physical.getPortNumber()))).thenReturn(requestId);
service.apply(physical, reference, propertiesEnabled);
reset(carrier);
BfdProperties altProperties = new BfdProperties(Duration.ofMillis(propertiesEnabled.getInterval().toMillis() + 100), (short) (propertiesEnabled.getMultiplier() + 1));
service.apply(physical, reference, altProperties);
verify(carrier).createLogicalPort(eq(logical), eq(physical.getPortNumber()));
verifyNoMoreInteractions(carrier);
service.portAdd(logical, physical.getPortNumber());
verify(carrier).enableUpdateSession(eq(logical), eq(physical.getPortNumber()), eq(new BfdSessionData(reference, altProperties)));
}
use of org.openkilda.wfm.topology.network.model.BfdSessionData 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);
}
use of org.openkilda.wfm.topology.network.model.BfdSessionData in project open-kilda by telstra.
the class NetworkBfdSessionServiceTest method forceCleanupAfterInit.
private NoviBfdSession forceCleanupAfterInit(BfdSession initialBfdSession) {
switchOnlineStatusMonitor.update(alphaLogicalEndpoint.getDatapath(), true);
when(bfdSessionRepository.findBySwitchIdAndPort(alphaLogicalEndpoint.getDatapath(), alphaLogicalEndpoint.getPortNumber())).thenReturn(Optional.of(initialBfdSession));
mockSwitchLookup(alphaSwitch);
mockSwitchLookup(betaSwitch);
when(carrier.sendWorkerBfdSessionDeleteRequest(any(NoviBfdSession.class))).thenReturn(removeRequestKey);
service.enableUpdate(alphaLogicalEndpoint, alphaEndpoint.getPortNumber(), new BfdSessionData(alphaToBetaIslRef, genericBfdProperties));
ArgumentCaptor<NoviBfdSession> setupBfdSessionArgument = ArgumentCaptor.forClass(NoviBfdSession.class);
verify(carrier).sendWorkerBfdSessionDeleteRequest(setupBfdSessionArgument.capture());
resetCarrier();
reset(bfdSessionRepository);
return setupBfdSessionArgument.getValue();
}
use of org.openkilda.wfm.topology.network.model.BfdSessionData 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.wfm.topology.network.model.BfdSessionData 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