Search in sources :

Example 1 with BfdProperties

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

the class NetworkBfdLogicalPortServiceTest method enableDuringCleanup.

@Test
public void enableDuringCleanup() {
    NetworkBfdLogicalPortService service = makeService();
    switchOnlineStatusMonitor.update(physical.getDatapath(), true);
    service.portAdd(logical, physical.getPortNumber());
    service.apply(physical, reference, propertiesEnabled);
    verify(carrier).logicalPortControllerAddNotification(eq(physical));
    reset(carrier);
    final String deleteRequestId = "port-delete-request";
    when(carrier.deleteLogicalPort(eq(logical))).thenReturn(deleteRequestId);
    service.disable(physical);
    service.sessionCompleteNotification(physical);
    verify(carrier).deleteLogicalPort(eq(logical));
    reset(carrier);
    final String createRequestId = "port-create-request";
    when(carrier.createLogicalPort(eq(logical), eq(physical.getPortNumber()))).thenReturn(createRequestId);
    BfdProperties altProperties = new BfdProperties(Duration.ofMillis(propertiesEnabled.getInterval().toMillis() + 100), (short) (propertiesEnabled.getMultiplier() + 1));
    service.apply(physical, reference, altProperties);
    service.portDel(logical);
    service.portAdd(logical, physical.getPortNumber());
    verify(carrier).enableUpdateSession(eq(logical), eq(physical.getPortNumber()), eq(new BfdSessionData(reference, altProperties)));
}
Also used : BfdSessionData(org.openkilda.wfm.topology.network.model.BfdSessionData) BfdProperties(org.openkilda.model.BfdProperties) Test(org.junit.Test)

Example 2 with BfdProperties

use of org.openkilda.model.BfdProperties 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)));
}
Also used : BfdSessionData(org.openkilda.wfm.topology.network.model.BfdSessionData) BfdProperties(org.openkilda.model.BfdProperties) Test(org.junit.Test)

Example 3 with BfdProperties

use of org.openkilda.model.BfdProperties 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 4 with BfdProperties

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

the class IslMapper method map.

/**
 * Convert {@link Isl} to {@link IslInfoData}.
 */
public IslInfoData map(Isl isl) {
    if (isl == null) {
        return null;
    }
    PathNode src = new PathNode();
    src.setSwitchId(isl.getSrcSwitchId());
    src.setPortNo(isl.getSrcPort());
    src.setSegLatency(isl.getLatency());
    src.setSeqId(0);
    PathNode dst = new PathNode();
    dst.setSwitchId(isl.getDestSwitchId());
    dst.setPortNo(isl.getDestPort());
    dst.setSegLatency(isl.getLatency());
    dst.setSeqId(1);
    Long timeCreateMillis = Optional.ofNullable(isl.getTimeCreate()).map(Instant::toEpochMilli).orElse(null);
    Long timeModifyMillis = Optional.ofNullable(isl.getTimeModify()).map(Instant::toEpochMilli).orElse(null);
    BfdProperties bfdProperties = readBfdProperties(isl);
    return new IslInfoData(isl.getLatency(), src, dst, isl.getSpeed(), isl.getAvailableBandwidth(), isl.getMaxBandwidth(), isl.getDefaultMaxBandwidth(), map(isl.getStatus()), map(isl.getActualStatus()), map(isl.getRoundTripStatus()), isl.getCost(), timeCreateMillis, timeModifyMillis, isl.isUnderMaintenance(), bfdProperties.isEnabled(), map(isl.getBfdSessionStatus()), null);
}
Also used : BfdProperties(org.openkilda.model.BfdProperties) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode)

Example 5 with BfdProperties

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

the class IslFsm method loadBfdProperties.

private BfdProperties loadBfdProperties() {
    BfdProperties leftToRight = loadBfdProperties(reference.getSource(), reference.getDest());
    BfdProperties rightToLeft = loadBfdProperties(reference.getDest(), reference.getSource());
    if (!leftToRight.equals(rightToLeft)) {
        log.error("ISL {} records contains not equal BFD properties data {} != {} (use {})", reference, leftToRight, rightToLeft, leftToRight);
    }
    return leftToRight;
}
Also used : BfdProperties(org.openkilda.model.BfdProperties)

Aggregations

BfdProperties (org.openkilda.model.BfdProperties)6 Test (org.junit.Test)3 BfdSessionData (org.openkilda.wfm.topology.network.model.BfdSessionData)3 BfdSessionResponse (org.openkilda.messaging.floodlight.response.BfdSessionResponse)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 NoviBfdSession (org.openkilda.messaging.model.NoviBfdSession)1 BfdSession (org.openkilda.model.BfdSession)1 Isl (org.openkilda.model.Isl)1