Search in sources :

Example 1 with FlowObjectiveStoreDelegate

use of org.onosproject.net.flowobjective.FlowObjectiveStoreDelegate in project onos by opennetworkinglab.

the class FlowObjectiveManagerTest method pendingForwardingObjective.

/**
 * Tests adding a pending forwarding objective.
 *
 * @throws TestUtilsException if lookup of a field fails
 */
@Test
public void pendingForwardingObjective() throws TestUtilsException {
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    ForwardingObjective forward4 = DefaultForwardingObjective.builder().fromApp(NetTestTools.APP_ID).withFlag(ForwardingObjective.Flag.SPECIFIC).withSelector(selector).withTreatment(treatment).makePermanent().nextStep(4).add();
    ForwardingObjective forward5 = DefaultForwardingObjective.builder().fromApp(NetTestTools.APP_ID).withFlag(ForwardingObjective.Flag.SPECIFIC).withSelector(selector).withTreatment(treatment).makePermanent().nextStep(5).add();
    // multiple pending forwards should be combined
    manager.forward(id1, forward4);
    manager.forward(id1, forward4);
    manager.forward(id1, forward5);
    // 1 should be complete, 1 pending
    TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1)));
    assertThat(forwardingObjectives, hasItem("of:d1"));
    assertThat(filteringObjectives, hasSize(0));
    assertThat(nextObjectives, hasSize(0));
    // Now send events to trigger the objective still in the queue
    ObjectiveEvent event1 = new ObjectiveEvent(ObjectiveEvent.Type.ADD, 4);
    FlowObjectiveStoreDelegate delegate = TestUtils.getField(manager, "delegate");
    delegate.notify(event1);
    // all should be processed now
    TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(2)));
    assertThat(forwardingObjectives, hasItem("of:d1"));
    assertThat(filteringObjectives, hasSize(0));
    assertThat(nextObjectives, hasSize(0));
}
Also used : ObjectiveEvent(org.onosproject.net.flowobjective.ObjectiveEvent) FlowObjectiveStoreDelegate(org.onosproject.net.flowobjective.FlowObjectiveStoreDelegate) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)1 FlowObjectiveStoreDelegate (org.onosproject.net.flowobjective.FlowObjectiveStoreDelegate)1 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)1 ObjectiveEvent (org.onosproject.net.flowobjective.ObjectiveEvent)1