Search in sources :

Example 11 with SwitchProperties

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

the class FermaSwitchPropertiesRepositoryTest method shouldFindSwitchPropertiesBySwitchId.

@Test
public void shouldFindSwitchPropertiesBySwitchId() {
    Switch origSwitch = Switch.builder().switchId(TEST_SWITCH_ID).description("Some description").build();
    switchRepository.add(origSwitch);
    SwitchProperties switchProperties = SwitchProperties.builder().switchObj(origSwitch).supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES).build();
    switchPropertiesRepository.add(switchProperties);
    Optional<SwitchProperties> switchPropertiesOptional = switchPropertiesRepository.findBySwitchId(TEST_SWITCH_ID);
    assertTrue(switchPropertiesOptional.isPresent());
}
Also used : Switch(org.openkilda.model.Switch) SwitchProperties(org.openkilda.model.SwitchProperties) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 12 with SwitchProperties

use of org.openkilda.model.SwitchProperties 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 13 with SwitchProperties

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

the class SwitchOperationsServiceTest method createSwitchProperties.

private void createSwitchProperties(Switch sw, Set<FlowEncapsulationType> transitEncapsulation, boolean multiTable, boolean switchLldp, boolean switchArp) {
    SwitchProperties switchProperties = SwitchProperties.builder().switchObj(sw).supportedTransitEncapsulation(transitEncapsulation).multiTable(multiTable).switchLldp(switchLldp).switchArp(switchArp).build();
    switchPropertiesRepository.add(switchProperties);
}
Also used : SwitchProperties(org.openkilda.model.SwitchProperties)

Example 14 with SwitchProperties

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

the class PathsServiceTest method assertMaxLatencyPaths.

private void assertMaxLatencyPaths(List<PathsInfoData> paths, Duration maxLatency, long expectedCount, FlowEncapsulationType encapsulationType) {
    assertEquals(expectedCount, paths.size());
    assertPathLength(paths);
    for (PathsInfoData path : paths) {
        assertTrue(path.getPath().getLatency().minus(maxLatency).isNegative());
        Optional<SwitchProperties> properties = switchPropertiesRepository.findBySwitchId(path.getPath().getNodes().get(1).getSwitchId());
        assertTrue(properties.isPresent());
        assertTrue(properties.get().getSupportedTransitEncapsulation().contains(encapsulationType));
    }
}
Also used : PathsInfoData(org.openkilda.messaging.info.network.PathsInfoData) SwitchProperties(org.openkilda.model.SwitchProperties)

Example 15 with SwitchProperties

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

the class SwitchFsm method persistSwitchProperties.

private void persistSwitchProperties(Switch sw) {
    boolean multiTable = kildaConfigurationRepository.getOrDefault().getUseMultiTable() && sw.getFeatures().contains(SwitchFeature.MULTI_TABLE);
    Optional<SwitchProperties> switchPropertiesResult = switchPropertiesRepository.findBySwitchId(sw.getSwitchId());
    if (!switchPropertiesResult.isPresent()) {
        SwitchProperties switchProperties = SwitchProperties.builder().switchObj(sw).supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES).multiTable(multiTable).build();
        switchPropertiesRepository.add(switchProperties);
    }
}
Also used : SwitchProperties(org.openkilda.model.SwitchProperties)

Aggregations

SwitchProperties (org.openkilda.model.SwitchProperties)45 Switch (org.openkilda.model.Switch)19 SwitchId (org.openkilda.model.SwitchId)19 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 List (java.util.List)8 Set (java.util.Set)7 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)7 KildaFeatureToggles (org.openkilda.model.KildaFeatureToggles)6 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)6 Utils.buildSwitchProperties (org.openkilda.rulemanager.Utils.buildSwitchProperties)6 Sets (com.google.common.collect.Sets)5 Map (java.util.Map)5 Before (org.junit.Before)5 Collections (java.util.Collections)4 Assert.assertEquals (org.junit.Assert.assertEquals)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 Mockito.mock (org.mockito.Mockito.mock)4