Search in sources :

Example 6 with OpticalCircuitIntent

use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.

the class OpticalConnectivityTest method testLinkEstablishedByCircuitIntent.

/**
 * Checks that isAllRealizingLink(Not)Established works for OpticalCircuitIntent.
 */
@Test
public void testLinkEstablishedByCircuitIntent() {
    // Mock 7-nodes linear topology
    ConnectPoint cp12 = createConnectPoint(1, 2);
    ConnectPoint cp21 = createConnectPoint(2, 1);
    ConnectPoint cp22 = createConnectPoint(2, 2);
    ConnectPoint cp31 = createConnectPoint(3, 1);
    ConnectPoint cp32 = createConnectPoint(3, 2);
    ConnectPoint cp41 = createConnectPoint(4, 1);
    ConnectPoint cp42 = createConnectPoint(4, 2);
    ConnectPoint cp51 = createConnectPoint(5, 1);
    ConnectPoint cp52 = createConnectPoint(5, 2);
    ConnectPoint cp61 = createConnectPoint(6, 1);
    ConnectPoint cp62 = createConnectPoint(6, 2);
    ConnectPoint cp71 = createConnectPoint(7, 1);
    Link link1 = createLink(cp12, cp21);
    Link link2 = createLink(cp22, cp31);
    Link link3 = createLink(cp32, cp41);
    Link link4 = createLink(cp42, cp51);
    Link link5 = createLink(cp52, cp61);
    Link link6 = createLink(cp62, cp71);
    List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList());
    // Mocks 2 intents to create Och connectivity
    OpticalCircuitIntent circuitIntent1 = createCircuitIntent(cp21, cp32);
    PacketLinkRealizedByOptical ochLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, circuitIntent1);
    OpticalCircuitIntent circuitIntent2 = createCircuitIntent(cp51, cp62);
    PacketLinkRealizedByOptical ochLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, circuitIntent2);
    Set<PacketLinkRealizedByOptical> plinks = ImmutableSet.of(ochLink1, ochLink2);
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    OpticalConnectivityId cid = OpticalConnectivityId.of(1L);
    OpticalConnectivity oc1 = new OpticalConnectivity(cid, links, bandwidth, latency, plinks, Collections.emptySet());
    assertTrue(oc1.isAllRealizingLinkNotEstablished());
    assertFalse(oc1.isAllRealizingLinkEstablished());
    // Sets link realized by circuitIntent1 to be established
    OpticalConnectivity oc2 = oc1.setLinkEstablished(cp12, cp41, true);
    assertFalse(oc2.isAllRealizingLinkNotEstablished());
    assertFalse(oc2.isAllRealizingLinkEstablished());
    // Sets link realized by circuitIntent2 to be established
    OpticalConnectivity oc3 = oc2.setLinkEstablished(cp42, cp71, true);
    assertFalse(oc3.isAllRealizingLinkNotEstablished());
    assertTrue(oc3.isAllRealizingLinkEstablished());
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) Duration(java.time.Duration) ConnectPoint(org.onosproject.net.ConnectPoint) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) Test(org.junit.Test)

Example 7 with OpticalCircuitIntent

use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.

the class PacketLinkRealizedByOpticalTest method testCreateWithCircuitIntent.

/**
 * Checks the construction of OpticalConnectivityId object with OpticalCircuitIntent.
 */
@Test
public void testCreateWithCircuitIntent() {
    ConnectPoint cp1 = new ConnectPoint(DeviceId.deviceId("of:0000000000000001"), PortNumber.portNumber(1L));
    ConnectPoint cp2 = new ConnectPoint(DeviceId.deviceId("of:0000000000000002"), PortNumber.portNumber(2L));
    OpticalCircuitIntent circuitIntent = OpticalCircuitIntent.builder().appId(appId).src(cp1).dst(cp2).bidirectional(true).key(Key.of(0, appId)).signalType(CltSignalType.CLT_1GBE).build();
    PacketLinkRealizedByOptical plink = PacketLinkRealizedByOptical.create(cp1, cp2, circuitIntent);
    assertNotNull(plink);
    assertEquals(plink.src(), cp1);
    assertEquals(plink.dst(), cp2);
    assertEquals((long) plink.bandwidth().bps(), CltSignalType.CLT_1GBE.bitRate());
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Test(org.junit.Test)

Example 8 with OpticalCircuitIntent

use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.

the class PacketLinkRealizedByOpticalTest method testIsBetween.

/**
 * Checks that isBetween() method works.
 */
@Test
public void testIsBetween() {
    ConnectPoint cp1 = new ConnectPoint(DeviceId.deviceId("of:0000000000000001"), PortNumber.portNumber(1L));
    ConnectPoint cp2 = new ConnectPoint(DeviceId.deviceId("of:0000000000000002"), PortNumber.portNumber(2L));
    ConnectPoint cp3 = new ConnectPoint(DeviceId.deviceId("of:0000000000000003"), PortNumber.portNumber(3L));
    OpticalCircuitIntent ochIntent = OpticalCircuitIntent.builder().appId(appId).src(cp1).dst(cp2).bidirectional(true).key(Key.of(0, appId)).signalType(CltSignalType.CLT_1GBE).build();
    PacketLinkRealizedByOptical plink = PacketLinkRealizedByOptical.create(cp1, cp2, ochIntent);
    assertTrue(plink.isBetween(cp1, cp2));
    assertFalse(plink.isBetween(cp1, cp3));
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Test(org.junit.Test)

Example 9 with OpticalCircuitIntent

use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.

the class OpticalCircuitIntentCompilerTest method test10GbeNoMuxOverOdu2.

/**
 * Tests compile of OpticalCircuitIntent without allocation of TributarySlots.
 * Compile two ODUCLT ports (with CLT_10GBE), over OCH ports (with ODU2):
 *   - No TributarySlots are used
 */
@Test
public void test10GbeNoMuxOverOdu2() {
    // Use driver without support for TributarySlotQuery Behaviour
    sut.driverService = new MockDriverServiceNoTs();
    ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P3.number());
    ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P3.number());
    ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
    ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
    intent = OpticalCircuitIntent.builder().appId(APP_ID).key(KEY1).src(oduCltSrcCP).dst(oduCltDstCP).signalType(D1P3.signalType()).bidirectional(false).build();
    sut.activate(null);
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
    // validate SRC selector
    TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
    selectorBuilder1.matchInPort(oduCltSrcCP.port());
    assertThat(rule1.selector(), is(selectorBuilder1.build()));
    // validate SRC treatment (without OduSignalType and OduSignalId: i.e. No TributarySlots are used)
    TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
    treatmentBuilder1.setOutput(ochSrcCP.port());
    assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
    FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
    // validate DST selector (without OduSignalType and OduSignalId: i.e. No TributarySlots are used)
    TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
    selectorBuilder2.matchInPort(ochDstCP.port());
    assertThat(rule2.selector(), is(selectorBuilder2.build()));
    // validate DST treatment
    assertThat(rule2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()));
    rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
    sut.deactivate();
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 10 with OpticalCircuitIntent

use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.

the class OpticalCircuitIntentCompilerTest method test1GbeMultiplexOverOdu2.

/**
 * Tests compile of OpticalCircuitIntent with allocation of TributarySlots.
 * Compile two ODUCLT ports (with CLT_1GBE), over OCH ports (with ODU2):
 *   - only one TributarySlot is used
 */
@Test
public void test1GbeMultiplexOverOdu2() {
    // Use driver with TributarySlotQuery Behaviour
    sut.driverService = new MockDriverServiceWithTs();
    ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P1.number());
    ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P1.number());
    ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
    ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
    intent = OpticalCircuitIntent.builder().appId(APP_ID).key(KEY1).src(oduCltSrcCP).dst(oduCltDstCP).signalType(D1P1.signalType()).bidirectional(false).build();
    sut.activate(null);
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
    // validate SRC selector
    TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
    selectorBuilder1.matchInPort(oduCltSrcCP.port());
    selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    assertThat(rule1.selector(), is(selectorBuilder1.build()));
    // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
    TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
    Set<TributarySlot> slots = new HashSet<>();
    slots.add(TributarySlot.of(1));
    OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(D1P2.signalType(), slots);
    treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
    treatmentBuilder1.setOutput(ochSrcCP.port());
    assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
    FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
    // validate DST selector (with OduSignalId, where the same TributarySlot is used)
    TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
    selectorBuilder2.matchInPort(ochDstCP.port());
    selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
    assertThat(rule2.selector(), is(selectorBuilder2.build()));
    // validate DST treatment
    assertThat(rule2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()));
    rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
    sut.deactivate();
}
Also used : OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) TributarySlot(org.onosproject.net.TributarySlot) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) FlowRule(org.onosproject.net.flow.FlowRule) OduSignalId(org.onosproject.net.OduSignalId) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Aggregations

OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)10 ConnectPoint (org.onosproject.net.ConnectPoint)9 Intent (org.onosproject.net.intent.Intent)7 Test (org.junit.Test)6 TrafficSelector (org.onosproject.net.flow.TrafficSelector)4 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)4 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)4 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 FlowRule (org.onosproject.net.flow.FlowRule)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)3 HashSet (java.util.HashSet)2 Pair (org.apache.commons.lang3.tuple.Pair)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 MoreObjects.firstNonNull (com.google.common.base.MoreObjects.firstNonNull)1 Strings (com.google.common.base.Strings)1