Search in sources :

Example 51 with Switch

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

the class SwitchOperationsServiceTest method runInvalidServer42PropsTest.

private void runInvalidServer42PropsTest(SwitchPropertiesDto invalidProperties) {
    invalidProperties.setMultiTable(true);
    invalidProperties.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    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);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, invalidProperties);
}
Also used : Switch(org.openkilda.model.Switch)

Example 52 with Switch

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

the class SwitchOperationsServiceTest method shouldUpdateServer42IslRttSwitchPropertiesToAuto.

@Test
public void shouldUpdateServer42IslRttSwitchPropertiesToAuto() {
    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.AUTO);
    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.AUTO, 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)

Example 53 with Switch

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

the class SwitchOperationsServiceTest method shouldValidateMultiTableFlagWhenUpdatingSwitchPropertiesWithArp.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateMultiTableFlagWhenUpdatingSwitchPropertiesWithArp() {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(sw);
    createSwitchProperties(sw, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, true);
    // user can't disable multiTable without disabling ARP
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setMultiTable(false);
    update.setSwitchArp(true);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Also used : SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) Switch(org.openkilda.model.Switch) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 54 with Switch

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

the class SwitchOperationsServiceTest method shouldValidateFlowWhenUpdatingServer42PortSwitchProperties.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowWhenUpdatingServer42PortSwitchProperties() {
    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).srcPort(TEST_FLOW_SRC_PORT).destSwitch(secondSwitch).detectConnectedDevices(new DetectConnectedDevices(false, true, false, true, false, false, false, false)).build();
    flowRepository.add(flow);
    createSwitchProperties(firstSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false);
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setServer42Port(TEST_FLOW_SRC_PORT);
    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 55 with Switch

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

the class SwitchOperationsServiceTest method shouldDeletePortPropertiesWhenDeletingSwitch.

@Test
public void shouldDeletePortPropertiesWhenDeletingSwitch() throws SwitchNotFoundException {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(sw);
    PortProperties portProperties = PortProperties.builder().switchObj(sw).port(7).discoveryEnabled(false).build();
    portPropertiesRepository.add(portProperties);
    switchOperationsService.deleteSwitch(TEST_SWITCH_ID, false);
    assertFalse(switchRepository.findById(TEST_SWITCH_ID).isPresent());
    assertTrue(portPropertiesRepository.findAll().isEmpty());
}
Also used : Switch(org.openkilda.model.Switch) PortProperties(org.openkilda.model.PortProperties) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

Switch (org.openkilda.model.Switch)230 Test (org.junit.Test)126 Flow (org.openkilda.model.Flow)68 SwitchId (org.openkilda.model.SwitchId)67 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)46 FlowPath (org.openkilda.model.FlowPath)34 PathId (org.openkilda.model.PathId)32 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)32 PathComputer (org.openkilda.pce.PathComputer)28 GetPathsResult (org.openkilda.pce.GetPathsResult)23 List (java.util.List)22 SwitchProperties (org.openkilda.model.SwitchProperties)21 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)20 SpeakerData (org.openkilda.rulemanager.SpeakerData)19 String.format (java.lang.String.format)17 Set (java.util.Set)17 Isl (org.openkilda.model.Isl)15 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13