Search in sources :

Example 6 with BfdSession

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);
}
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 7 with BfdSession

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());
}
Also used : BfdSession(org.openkilda.model.BfdSession) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 8 with BfdSession

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());
}
Also used : BfdSession(org.openkilda.model.BfdSession) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 9 with BfdSession

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);
}
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) BfdProperties(org.openkilda.model.BfdProperties) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) Test(org.junit.Test)

Example 10 with BfdSession

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);
}
Also used : BfdSessionData(org.openkilda.wfm.topology.network.model.BfdSessionData) BfdSession(org.openkilda.model.BfdSession) NoviBfdSession(org.openkilda.messaging.model.NoviBfdSession) 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