Search in sources :

Example 1 with LogicalPortMisconfiguredInfoEntry

use of org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry in project open-kilda by telstra.

the class ValidationServiceImplTest method validateLogicalPorts.

@Test
public void validateLogicalPorts() {
    ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
    LogicalPort proper = buildLogicalPort(LOGICAL_PORT_NUMBER_1, PHYSICAL_PORT_2, PHYSICAL_PORT_1);
    LogicalPort misconfigured = buildLogicalPort(LOGICAL_PORT_NUMBER_2, LogicalPortType.BFD, PHYSICAL_PORT_3);
    LogicalPort excess = buildLogicalPort(LOGICAL_PORT_NUMBER_4, PHYSICAL_PORT_6);
    LogicalPort bfdExcess = buildLogicalPort(LOGICAL_PORT_NUMBER_5, LogicalPortType.BFD, PHYSICAL_PORT_7);
    ValidateLogicalPortsResult result = validationService.validateLogicalPorts(SWITCH_ID_A, Lists.newArrayList(proper, misconfigured, excess, bfdExcess));
    assertEquals(1, result.getProperLogicalPorts().size());
    // bfdExcess port shouldn't be in this list
    assertEquals(1, result.getExcessLogicalPorts().size());
    assertEquals(1, result.getMissingLogicalPorts().size());
    assertEquals(1, result.getMisconfiguredLogicalPorts().size());
    assertEqualLogicalPort(proper, result.getProperLogicalPorts().get(0));
    assertEqualLogicalPort(excess, result.getExcessLogicalPorts().get(0));
    LogicalPortInfoEntry missing = LogicalPortInfoEntry.builder().type(org.openkilda.messaging.info.switches.LogicalPortType.LAG).logicalPortNumber(LOGICAL_PORT_NUMBER_3).physicalPorts(Lists.newArrayList(PHYSICAL_PORT_5, PHYSICAL_PORT_6)).build();
    assertEquals(missing, result.getMissingLogicalPorts().get(0));
    LogicalPortInfoEntry misconfiguredEntry = LogicalPortInfoEntry.builder().type(org.openkilda.messaging.info.switches.LogicalPortType.BFD).logicalPortNumber(LOGICAL_PORT_NUMBER_2).physicalPorts(Lists.newArrayList(PHYSICAL_PORT_3)).actual(new LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortType.BFD, Lists.newArrayList(PHYSICAL_PORT_3))).expected(new LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortType.LAG, Lists.newArrayList(PHYSICAL_PORT_3, PHYSICAL_PORT_4))).build();
    assertEquals(misconfiguredEntry, result.getMisconfiguredLogicalPorts().get(0));
}
Also used : LogicalPort(org.openkilda.messaging.model.grpc.LogicalPort) LagLogicalPort(org.openkilda.model.LagLogicalPort) LogicalPortInfoEntry(org.openkilda.messaging.info.switches.LogicalPortInfoEntry) LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) ValidateLogicalPortsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult) Test(org.junit.Test)

Example 2 with LogicalPortMisconfiguredInfoEntry

use of org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry in project open-kilda by telstra.

the class ValidationServiceImpl method calculateMisconfiguredLogicalPort.

@VisibleForTesting
LogicalPortInfoEntry calculateMisconfiguredLogicalPort(LogicalPortInfoEntry expectedPort, LogicalPortInfoEntry actualPort) {
    LogicalPortMisconfiguredInfoEntry expected = new LogicalPortMisconfiguredInfoEntry();
    LogicalPortMisconfiguredInfoEntry actual = new LogicalPortMisconfiguredInfoEntry();
    if (!Objects.equals(expectedPort.getType(), actualPort.getType())) {
        expected.setType(expectedPort.getType());
        actual.setType(actualPort.getType());
    }
    // compare, ignoring order
    if (!CollectionUtils.isEqualCollection(expectedPort.getPhysicalPorts(), actualPort.getPhysicalPorts())) {
        expected.setPhysicalPorts(expectedPort.getPhysicalPorts());
        actual.setPhysicalPorts(actualPort.getPhysicalPorts());
    }
    return LogicalPortInfoEntry.builder().logicalPortNumber(actualPort.getLogicalPortNumber()).type(actualPort.getType()).physicalPorts(actualPort.getPhysicalPorts()).expected(expected).actual(actual).build();
}
Also used : LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with LogicalPortMisconfiguredInfoEntry

use of org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry in project open-kilda by telstra.

the class SwitchMapperTest method testToLogicalPortsValidationDto.

@Test
public void testToLogicalPortsValidationDto() {
    LogicalPortInfoEntry missing = LogicalPortInfoEntry.builder().logicalPortNumber(LOGICAL_PORT_NUMBER_1).type(LAG).physicalPorts(newArrayList(PHYSICAL_PORT_1, PHYSICAL_PORT_2)).build();
    LogicalPortInfoEntry excess = LogicalPortInfoEntry.builder().logicalPortNumber(LOGICAL_PORT_NUMBER_2).type(LAG).physicalPorts(newArrayList(PHYSICAL_PORT_3)).build();
    LogicalPortInfoEntry misconfigured = LogicalPortInfoEntry.builder().logicalPortNumber(LOGICAL_PORT_NUMBER_3).type(BFD).physicalPorts(newArrayList(PHYSICAL_PORT_4)).actual(new LogicalPortMisconfiguredInfoEntry(BFD, newArrayList(PHYSICAL_PORT_4))).expected(new LogicalPortMisconfiguredInfoEntry(LAG, newArrayList(PHYSICAL_PORT_4, PHYSICAL_PORT_5))).build();
    LogicalPortInfoEntry proper = LogicalPortInfoEntry.builder().logicalPortNumber(LOGICAL_PORT_NUMBER_4).type(LAG).physicalPorts(newArrayList(PHYSICAL_PORT_6)).build();
    LogicalPortsValidationEntry validationEntry = LogicalPortsValidationEntry.builder().missing(newArrayList(missing)).misconfigured(newArrayList(misconfigured)).proper(newArrayList(proper)).excess(newArrayList(excess)).build();
    LogicalPortsValidationDto validationDto = switchMapper.toLogicalPortsValidationDto(validationEntry);
    assertEquals(1, validationDto.getProper().size());
    assertEquals(1, validationDto.getMissing().size());
    assertEquals(1, validationDto.getMisconfigured().size());
    assertEquals(1, validationDto.getExcess().size());
    assertEqualsLogicalPortInfoDto(validationDto.getMissing().get(0), LOGICAL_PORT_NUMBER_1, LAG.toString(), PHYSICAL_PORT_1, PHYSICAL_PORT_2);
    assertEqualsLogicalPortInfoDto(validationDto.getExcess().get(0), LOGICAL_PORT_NUMBER_2, LAG.toString(), PHYSICAL_PORT_3);
    assertEqualsLogicalPortInfoDto(validationDto.getMisconfigured().get(0), LOGICAL_PORT_NUMBER_3, BFD.toString(), PHYSICAL_PORT_4);
    assertEqualsLogicalPortInfoDto(validationDto.getProper().get(0), LOGICAL_PORT_NUMBER_4, LAG.toString(), PHYSICAL_PORT_6);
    assertEquals(BFD.toString(), validationDto.getMisconfigured().get(0).getActual().getType());
    assertEquals(newArrayList(PHYSICAL_PORT_4), validationDto.getMisconfigured().get(0).getActual().getPhysicalPorts());
    assertEquals(LAG.toString(), validationDto.getMisconfigured().get(0).getExpected().getType());
    assertEquals(newArrayList(PHYSICAL_PORT_4, PHYSICAL_PORT_5), validationDto.getMisconfigured().get(0).getExpected().getPhysicalPorts());
}
Also used : LogicalPortInfoEntry(org.openkilda.messaging.info.switches.LogicalPortInfoEntry) LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry) LogicalPortsValidationDto(org.openkilda.northbound.dto.v1.switches.LogicalPortsValidationDto) LogicalPortsValidationEntry(org.openkilda.messaging.info.switches.LogicalPortsValidationEntry) Test(org.junit.Test)

Aggregations

LogicalPortMisconfiguredInfoEntry (org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry)3 Test (org.junit.Test)2 LogicalPortInfoEntry (org.openkilda.messaging.info.switches.LogicalPortInfoEntry)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 LogicalPortsValidationEntry (org.openkilda.messaging.info.switches.LogicalPortsValidationEntry)1 LogicalPort (org.openkilda.messaging.model.grpc.LogicalPort)1 LagLogicalPort (org.openkilda.model.LagLogicalPort)1 LogicalPortsValidationDto (org.openkilda.northbound.dto.v1.switches.LogicalPortsValidationDto)1 ValidateLogicalPortsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult)1 ValidationService (org.openkilda.wfm.topology.switchmanager.service.ValidationService)1