Search in sources :

Example 81 with Switch

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

the class NetworkUniIslServiceTest method newIslWithHistory.

@Test
public void newIslWithHistory() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Endpoint endpoint2 = Endpoint.of(alphaDatapath, 2);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islAtoB = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islAtoB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
    service.uniIslSetup(endpoint1, islAtoB);
    service.uniIslSetup(endpoint2, islAtoB2);
    // System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).setupIslFromHistory(endpoint1, IslReference.of(islAtoB), islAtoB);
    verify(carrier).setupIslFromHistory(endpoint2, IslReference.of(islAtoB2), islAtoB2);
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) Test(org.junit.Test)

Example 82 with Switch

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

the class NetworkUniIslServiceTest method fromUpToDown.

@Test
public void fromUpToDown() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Endpoint endpoint2 = Endpoint.of(alphaDatapath, 2);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islA1toB1 = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islA2toB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
    service.uniIslSetup(endpoint1, islA1toB1);
    service.uniIslSetup(endpoint2, islA2toB2);
    IslInfoData disco1 = IslMapper.INSTANCE.map(islA1toB1);
    IslInfoData disco2 = IslMapper.INSTANCE.map(islA2toB2);
    service.uniIslDiscovery(endpoint1, disco1);
    service.uniIslDiscovery(endpoint2, disco2);
    resetMocks();
    service.uniIslFail(endpoint1);
    service.uniIslPhysicalDown(endpoint2);
    // System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).notifyIslDown(endpoint1, IslReference.of(islA1toB1), IslDownReason.POLL_TIMEOUT);
    verify(carrier).notifyIslDown(endpoint2, IslReference.of(islA2toB2), IslDownReason.PORT_DOWN);
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) Test(org.junit.Test)

Example 83 with Switch

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

the class Server42FlowRttOutputVxlanRuleGeneratorTest method server42FlowRttOutputVxlanRuleGeneratorNoviflowTest.

@Test
public void server42FlowRttOutputVxlanRuleGeneratorNoviflowTest() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD, NOVIFLOW_PUSH_POP_VXLAN));
    testOutputRule(sw, new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), true);
}
Also used : Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) Test(org.junit.Test)

Example 84 with Switch

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

the class Server42FlowRttVxlanTurningRuleGeneratorTest method server42FlowRttVxlanTurningRuleGeneratorNoviflowTest.

@Test
public void server42FlowRttVxlanTurningRuleGeneratorNoviflowTest() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_SWAP_ETH_SRC_ETH_DST));
    testOutputRule(sw, ActionType.NOVI_SWAP_FIELD);
}
Also used : Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) Test(org.junit.Test)

Example 85 with Switch

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

the class Server42IslRttOutputRuleGeneratorTest method server42IslRttOutputRuleGeneratorTest.

@Test
public void server42IslRttOutputRuleGeneratorTest() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(new Cookie(SERVER_42_ISL_RTT_OUTPUT_COOKIE), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(SERVER_42_ISL_RTT_OUTPUT_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(MAC_ADDRESS.toLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_REVERSE_UDP_PORT).build());
    assertEquals(expectedMatch, flowCommandData.getMatch());
    List<Action> expectedApplyActions = Lists.newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(Utils.SERVER_42_VLAN).build(), SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(Utils.SERVER_42_MAC_ADDRESS.toLong()).build(), new PortOutAction(new PortNumber(Utils.SERVER_42_PORT)));
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) 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