use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByInPort.
@Test
public void shouldDeleteRuleByInPort() throws Exception {
// given
final int testInPort = 11;
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).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());
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());
assertThat(deletedRules, containsInAnyOrder(cookie));
}
use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByCookie.
@Test
public void shouldDeleteRuleByCookie() throws Exception {
// given
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().cookie(cookie).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(cookie, actual.getCookie().getValue());
assertEquals(U64.NO_MASK, actual.getCookieMask());
assertThat(deletedRules, containsInAnyOrder(cookie));
}
use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByInPortVlanAndPriority.
@Test
public void shouldDeleteRuleByInPortVlanAndPriority() throws Exception {
// given
final int testInPort = 11;
final short testInVlan = 101;
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().inPort(testInPort).encapsulationId((int) testInVlan).priority(testPriority).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());
assertEquals(testPriority, actual.getPriority());
assertThat(deletedRules, containsInAnyOrder(cookie));
}
use of org.openkilda.messaging.command.switches.DeleteRulesCriteria in project open-kilda by telstra.
the class SwitchManagerTest method shouldDeleteRuleByInPortAndVxlanTunnel.
@Test
public void shouldDeleteRuleByInPortAndVxlanTunnel() 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.VXLAN).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.TUNNEL_ID).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 CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithStringOutPort.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithStringOutPort() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String inVlan = "10";
String outPort = "in_port";
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());
assertNull(criteria.getOutPort());
assertNull(criteria.getMetadataValue());
assertNull(criteria.getMetadataMask());
}
Aggregations