Search in sources :

Example 16 with SwitchPropertiesDto

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

the class SwitchOperationsServiceTest method shouldValidateFlowWithLldpFlagWhenUpdatingSwitchProperties.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowWithLldpFlagWhenUpdatingSwitchProperties() {
    Switch firstSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    Switch secondSwitch = Switch.builder().switchId(TEST_SWITCH_ID_2).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(firstSwitch);
    switchRepository.add(secondSwitch);
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_1).srcSwitch(firstSwitch).destSwitch(secondSwitch).detectConnectedDevices(new DetectConnectedDevices(true, false, true, false, false, false, false, false)).build();
    flowRepository.add(flow);
    createSwitchProperties(firstSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false);
    // user can't disable multiTable if some flows has enabled detect connected devices via LLDP
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setMultiTable(false);
    update.setSwitchLldp(false);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Also used : SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) Switch(org.openkilda.model.Switch) DetectConnectedDevices(org.openkilda.model.DetectConnectedDevices) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 17 with SwitchPropertiesDto

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

the class SwitchOperationsServiceTest method shouldUpdateServer42FlowRttSwitchProperties.

@Test
public void shouldUpdateServer42FlowRttSwitchProperties() {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).features(Collections.singleton(SwitchFeature.MULTI_TABLE)).build();
    switchRepository.add(sw);
    createServer42SwitchProperties(sw, false, SERVER_42_PORT_1, SERVER_42_VLAN_1, SERVER_42_MAC_ADDRESS_1);
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setMultiTable(true);
    update.setServer42FlowRtt(true);
    update.setServer42Port(SERVER_42_PORT_2);
    update.setServer42Vlan(SERVER_42_VLAN_2);
    update.setServer42MacAddress(SERVER_42_MAC_ADDRESS_2);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
    Optional<SwitchProperties> updated = switchPropertiesRepository.findBySwitchId(TEST_SWITCH_ID);
    assertTrue(updated.isPresent());
    assertTrue(updated.get().isServer42FlowRtt());
    assertEquals(SERVER_42_PORT_2, updated.get().getServer42Port());
    assertEquals(SERVER_42_VLAN_2, updated.get().getServer42Vlan());
    assertEquals(SERVER_42_MAC_ADDRESS_2, updated.get().getServer42MacAddress());
}
Also used : SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) Switch(org.openkilda.model.Switch) SwitchProperties(org.openkilda.model.SwitchProperties) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 18 with SwitchPropertiesDto

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

the class SwitchOperationsServiceTest method shouldUpdateServer42IslRttSwitchProperties.

@Test
public void shouldUpdateServer42IslRttSwitchProperties() {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).features(Collections.singleton(SwitchFeature.MULTI_TABLE)).build();
    switchRepository.add(sw);
    SwitchProperties switchProperties = SwitchProperties.builder().switchObj(sw).supportedTransitEncapsulation(Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN)).multiTable(false).server42IslRtt(SwitchProperties.RttState.DISABLED).server42Port(SERVER_42_PORT_1).server42Vlan(SERVER_42_VLAN_1).server42MacAddress(SERVER_42_MAC_ADDRESS_1).build();
    switchPropertiesRepository.add(switchProperties);
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setServer42IslRtt(RttState.ENABLED);
    update.setServer42Port(SERVER_42_PORT_2);
    update.setServer42Vlan(SERVER_42_VLAN_2);
    update.setServer42MacAddress(SERVER_42_MAC_ADDRESS_2);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
    Optional<SwitchProperties> updated = switchPropertiesRepository.findBySwitchId(TEST_SWITCH_ID);
    assertTrue(updated.isPresent());
    assertEquals(SwitchProperties.RttState.ENABLED, updated.get().getServer42IslRtt());
    assertEquals(SERVER_42_PORT_2, updated.get().getServer42Port());
    assertEquals(SERVER_42_VLAN_2, updated.get().getServer42Vlan());
    assertEquals(SERVER_42_MAC_ADDRESS_2, updated.get().getServer42MacAddress());
}
Also used : SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) Switch(org.openkilda.model.Switch) SwitchProperties(org.openkilda.model.SwitchProperties) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 SwitchPropertiesDto (org.openkilda.messaging.model.SwitchPropertiesDto)18 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)18 Switch (org.openkilda.model.Switch)12 DetectConnectedDevices (org.openkilda.model.DetectConnectedDevices)3 Flow (org.openkilda.model.Flow)3 PathId (org.openkilda.model.PathId)3 SwitchProperties (org.openkilda.model.SwitchProperties)3 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)2 GroupId (org.openkilda.model.GroupId)2 MirrorGroup (org.openkilda.model.MirrorGroup)2 FlowMirrorPath (org.openkilda.model.FlowMirrorPath)1