use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.
the class FlowRuleManagerTest method validateState.
private boolean validateState(Map<FlowRule, FlowEntryState> expected) {
Map<FlowRule, FlowEntryState> expectedToCheck = new HashMap<>(expected);
Iterable<FlowEntry> rules = service.getFlowEntries(DID);
for (FlowEntry f : rules) {
assertTrue("Unexpected FlowRule " + f, expectedToCheck.containsKey(f));
assertEquals("FlowEntry" + f, expectedToCheck.get(f), f.state());
expectedToCheck.remove(f);
}
assertEquals(Collections.emptySet(), expectedToCheck.entrySet());
return true;
}
use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.
the class FlowRuleManagerTest method getFlowEntry.
@Test
public void getFlowEntry() {
assertTrue("store should be empty", Sets.newHashSet(service.getFlowEntries(DID)).isEmpty());
FlowRule f1 = addFlowRule(1);
FlowRule f2 = addFlowRule(2);
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
assertEquals("2 rules should exist", 2, flowCount());
FlowEntry actual1 = service.getFlowEntry(f1);
FlowEntry actual2 = service.getFlowEntry(f2);
assertEquals(fe1, actual1);
assertEquals(fe2, actual2);
}
use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.
the class FlowRuleManagerTest method applyFlowRules.
@Test
public void applyFlowRules() {
FlowRule r1 = flowRule(1, 1);
FlowRule r2 = flowRule(2, 2);
FlowRule r3 = flowRule(3, 3);
assertTrue("store should be empty", Sets.newHashSet(service.getFlowEntries(DID)).isEmpty());
mgr.applyFlowRules(r1, r2, r3);
assertEquals("3 rules should exist", 3, flowCount());
assertTrue("Entries should be pending add.", validateState(ImmutableMap.of(r1, FlowEntryState.PENDING_ADD, r2, FlowEntryState.PENDING_ADD, r3, FlowEntryState.PENDING_ADD)));
}
use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.
the class FlowRuleManagerTest method fallbackBasics.
@Test
public void fallbackBasics() {
FlowRule f1 = flowRule(FOO_DID, 1, 1);
flowRules.clear();
mgr.applyFlowRules(f1);
assertTrue("flow rule not applied", flowRules.contains(f1));
flowRules.clear();
mgr.removeFlowRules(f1);
assertTrue("flow rule not removed", flowRules.contains(f1));
}
use of org.onosproject.net.flow.FlowRule in project onos by opennetworkinglab.
the class FlowRuleManagerTest method fallbackPoll.
@Test
public void fallbackPoll() {
FlowRuleDriverProvider fallback = (FlowRuleDriverProvider) mgr.defaultProvider();
FlowRule f1 = flowRule(FOO_DID, 1, 1);
mgr.applyFlowRules(f1);
FlowEntry fe = mgr.getFlowEntries(FOO_DID).iterator().next();
assertEquals("incorrect state", FlowEntryState.PENDING_ADD, fe.state());
fallback.init(fallback.providerService, mgr.deviceService, mgr.mastershipService, 1);
TestTools.assertAfter(2000, () -> {
FlowEntry e = mgr.getFlowEntries(FOO_DID).iterator().next();
assertEquals("incorrect state", FlowEntryState.ADDED, e.state());
});
}
Aggregations