use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByInPortAndVlan.
@Test
public void shouldDeleteRuleByInPortAndVlan() throws Exception {
// given
final int testInPort = 11;
final short testInVlan = 101;
expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch);
expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL);
expect(iofSwitch.write(capture(capture))).andReturn(true).times(3);
mockBarrierRequest();
mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
expectLastCall();
replay(ofSwitchService, iofSwitch);
// when
DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().inPort(testInPort).encapsulationId((int) testInVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).egressSwitchId(SWITCH_ID).build();
List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria);
// then
final OFFlowMod actual = capture.getValue();
assertEquals(OFFlowModCommand.DELETE, actual.getCommand());
assertEquals(testInPort, actual.getMatch().get(MatchField.IN_PORT).getPortNumber());
assertEquals(testInVlan, actual.getMatch().get(MatchField.VLAN_VID).getVlan());
assertEquals("any", actual.getOutPort().toString());
assertEquals(0, actual.getInstructions().size());
assertEquals(0L, actual.getCookie().getValue());
assertEquals(0L, actual.getCookieMask().getValue());
assertThat(deletedRules, containsInAnyOrder(cookie));
}
use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByInPortVlanAndMetadata.
@Test
public void shouldDeleteRuleByInPortVlanAndMetadata() throws Exception {
// given
final int testInPort = 11;
final short testInVlan = 101;
final long metadataValue = 17;
final long metadataMask = 255;
expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch);
expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL);
expect(iofSwitch.write(capture(capture))).andReturn(true).times(3);
mockBarrierRequest();
mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
expectLastCall();
replay(ofSwitchService, iofSwitch);
// when
DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().inPort(testInPort).metadataValue(metadataValue).metadataMask(metadataMask).encapsulationId((int) testInVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).egressSwitchId(SWITCH_ID).build();
List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria);
// then
final OFFlowMod actual = capture.getValue();
assertEquals(OFFlowModCommand.DELETE, actual.getCommand());
assertEquals(testInPort, actual.getMatch().get(MatchField.IN_PORT).getPortNumber());
assertEquals(testInVlan, actual.getMatch().get(MatchField.VLAN_VID).getVlan());
assertEquals(metadataValue, actual.getMatch().getMasked(MatchField.METADATA).getValue().getValue().getValue());
assertEquals(metadataMask, actual.getMatch().getMasked(MatchField.METADATA).getMask().getValue().getValue());
assertEquals("any", actual.getOutPort().toString());
assertEquals(0, actual.getInstructions().size());
assertEquals(0L, actual.getCookie().getValue());
assertEquals(0L, actual.getCookieMask().getValue());
assertThat(deletedRules, containsInAnyOrder(cookie));
}
use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByOutPort.
@Test
public void shouldDeleteRuleByOutPort() throws Exception {
// given
final int testOutPort = 21;
expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch);
expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL);
expect(iofSwitch.write(capture(capture))).andReturn(true).times(3);
mockBarrierRequest();
mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
expectLastCall();
replay(ofSwitchService, iofSwitch);
// when
DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().outPort(testOutPort).build();
List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria);
// then
final OFFlowMod actual = capture.getValue();
assertEquals(OFFlowModCommand.DELETE, actual.getCommand());
assertNull(actual.getMatch().get(MatchField.IN_PORT));
assertNull(actual.getMatch().get(MatchField.VLAN_VID));
assertEquals(testOutPort, actual.getOutPort().getPortNumber());
assertEquals(0L, actual.getCookie().getValue());
assertEquals(0L, actual.getCookieMask().getValue());
assertThat(deletedRules, containsInAnyOrder(cookie));
}
use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByPriority.
@Test
public void shouldDeleteRuleByPriority() throws Exception {
// given
final int testPriority = 999;
expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch);
expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
Capture<OFFlowMod> capture = EasyMock.newCapture(CaptureType.ALL);
expect(iofSwitch.write(capture(capture))).andReturn(true).times(3);
mockBarrierRequest();
mockFlowStatsRequest(DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE);
expectLastCall();
replay(ofSwitchService, iofSwitch);
// when
DeleteRulesCriteria criteria = DeleteRulesCriteria.builder().priority(testPriority).build();
List<Long> deletedRules = switchManager.deleteRulesByCriteria(dpid, false, null, criteria);
// then
final OFFlowMod actual = capture.getValue();
assertEquals(OFFlowModCommand.DELETE, actual.getCommand());
assertNull(actual.getMatch().get(MatchField.IN_PORT));
assertNull(actual.getMatch().get(MatchField.VLAN_VID));
assertEquals("any", actual.getOutPort().toString());
assertEquals(0, actual.getInstructions().size());
assertEquals(0L, actual.getCookie().getValue());
assertEquals(0L, actual.getCookieMask().getValue());
assertEquals(testPriority, actual.getPriority());
assertThat(deletedRules, containsInAnyOrder(cookie));
}
use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String inVlan = "10";
String outPort = "2";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, inVlan, outPort, null, false, null, null);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertEquals(Integer.valueOf(inVlan), criteria.getEncapsulationId());
assertEquals(Integer.valueOf(outPort), criteria.getOutPort());
assertNull(criteria.getMetadataValue());
assertNull(criteria.getMetadataMask());
}
Aggregations