Search in sources :

Example 1 with FlowRuleOperation

use of org.onosproject.net.flow.FlowRuleOperation in project onos by opennetworkinglab.

the class OpenstackFlowRuleManagerTest method validateFlowRule.

private void validateFlowRule(FlowRule ref) {
    assertEquals("Flow Rule size was not match", 1, fros.size());
    List<FlowRuleOperation> froList = Lists.newArrayList();
    froList.addAll(fros);
    FlowRuleOperation fro = froList.get(0);
    FlowRule fr = fro.rule();
    assertEquals("Application ID did not match", ref.appId(), fr.appId());
    assertEquals("Device ID did not match", ref.deviceId(), fr.deviceId());
    assertEquals("Selector did not match", ref.selector(), fr.selector());
    assertEquals("Treatment did not match", ref.treatment(), fr.treatment());
    assertEquals("Priority did not match", ref.priority(), fr.priority());
    assertEquals("Table ID did not match", ref.table(), fr.table());
    assertEquals("Permanent did not match", ref.isPermanent(), fr.isPermanent());
}
Also used : DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowRuleOperation(org.onosproject.net.flow.FlowRuleOperation)

Example 2 with FlowRuleOperation

use of org.onosproject.net.flow.FlowRuleOperation in project onos by opennetworkinglab.

the class ECFlowRuleStoreTest method testStoreBatch.

/**
 * Tests initial state of flowrule.
 */
@Test
public void testStoreBatch() {
    FlowRuleOperation op = new FlowRuleOperation(flowRule, FlowRuleOperation.Type.ADD);
    Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = ArrayListMultimap.create();
    perDeviceBatches.put(op.rule().deviceId(), new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, op.rule()));
    FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId), deviceId, 1);
    flowStoreImpl.storeBatch(b);
    FlowEntry flowEntry1 = flowStoreImpl.getFlowEntry(flowRule);
    assertEquals("PENDING_ADD", flowEntry1.state().toString());
}
Also used : FlowRuleBatchOperation(org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation) DeviceId(org.onosproject.net.DeviceId) FlowRuleBatchEntry(org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) FlowRuleOperation(org.onosproject.net.flow.FlowRuleOperation) Test(org.junit.Test)

Example 3 with FlowRuleOperation

use of org.onosproject.net.flow.FlowRuleOperation in project onos by opennetworkinglab.

the class ECFlowRuleStoreTest method testAddFlow.

/**
 * Tests adding a flowrule.
 */
@Test
public void testAddFlow() {
    FlowEntry flowEntry = new DefaultFlowEntry(flowRule);
    FlowRuleOperation op = new FlowRuleOperation(flowRule, FlowRuleOperation.Type.ADD);
    Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = ArrayListMultimap.create();
    perDeviceBatches.put(op.rule().deviceId(), new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, op.rule()));
    FlowRuleBatchOperation b = new FlowRuleBatchOperation(perDeviceBatches.get(deviceId), deviceId, 1);
    flowStoreImpl.storeBatch(b);
    FlowEntry flowEntry1 = flowStoreImpl.getFlowEntry(flowRule);
    assertEquals("PENDING_ADD", flowEntry1.state().toString());
    flowStoreImpl.addOrUpdateFlowRule(flowEntry);
    assertFlowsOnDevice(deviceId, 1);
    FlowEntry flowEntry2 = flowStoreImpl.getFlowEntry(flowRule);
    assertEquals("ADDED", flowEntry2.state().toString());
    assertThat(flowStoreImpl.getTableStatistics(deviceId), notNullValue());
}
Also used : FlowRuleBatchOperation(org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DeviceId(org.onosproject.net.DeviceId) FlowRuleBatchEntry(org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) FlowRuleOperation(org.onosproject.net.flow.FlowRuleOperation) Test(org.junit.Test)

Aggregations

FlowRuleOperation (org.onosproject.net.flow.FlowRuleOperation)3 Test (org.junit.Test)2 DeviceId (org.onosproject.net.DeviceId)2 DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)2 FlowEntry (org.onosproject.net.flow.FlowEntry)2 FlowRuleBatchEntry (org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry)2 FlowRuleBatchOperation (org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation)2 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)1 FlowRule (org.onosproject.net.flow.FlowRule)1