summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-10-04 13:08:51 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-10-05 11:54:27 +0000
commit15f481bc86adfd879e0e0d001ef3dd0939aa3649 (patch)
tree1942ac4271b325ad04052112f415cf3cbfeda18d /v3po/v3po2vpp/src/test/java/io/fd
parent6e92b4740d62b5977590f8a247b08eb945b9e5b7 (diff)
HONEYCOMB-238: provide interface mode as a part of ietf-acl configuration
- L2 only rules for L3 interfaces are not allowed by vpp - describes other limitations of ietf-acl model implementation Change-Id: If7e79e4bbfe3113b82e3411d9a951c409799a29f Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceEthWriterTest.java23
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4WriterTest.java65
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6WriterTest.java78
3 files changed, 117 insertions, 49 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceEthWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceEthWriterTest.java
index c352b5104..c334d4a83 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceEthWriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceEthWriterTest.java
@@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.cont
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEth;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEthBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.InterfaceMode;
public class AceEthWriterTest {
@@ -42,7 +43,7 @@ public class AceEthWriterTest {
private AceEth aceEth;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
initMocks(this);
writer = new AceEthWriter(jvpp);
action = new DenyBuilder().setDeny(true).build();
@@ -55,9 +56,9 @@ public class AceEthWriterTest {
}
@Test
- public void testGetClassifyAddDelTableRequest() throws Exception {
+ public void testCreateClassifyTable() {
final int nextTableIndex = 42;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceEth, nextTableIndex, 0);
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceEth, InterfaceMode.L2, nextTableIndex, 0);
assertEquals(1, request.isAdd);
assertEquals(-1, request.tableIndex);
@@ -78,10 +79,15 @@ public class AceEthWriterTest {
assertArrayEquals(expectedMask, request.mask);
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testCreateClassifyTableForL3Interface() {
+ writer.createClassifyTable(action, aceEth, InterfaceMode.L3, 42, 0);
+ }
+
@Test
- public void testGetClassifyAddDelSessionRequest() throws Exception {
+ public void testCreateClassifySession() {
final int tableIndex = 123;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceEth, tableIndex, 0);
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceEth, InterfaceMode.L2, tableIndex, 0);
assertEquals(1, request.isAdd);
assertEquals(tableIndex, request.tableIndex);
@@ -97,8 +103,13 @@ public class AceEthWriterTest {
assertArrayEquals(expectedMatch, request.match);
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testCreateClassifySessionForL3Interface() {
+ writer.createClassifySession(action, aceEth, InterfaceMode.L3, 42, 0);
+ }
+
@Test
- public void testSetClassifyTable() throws Exception {
+ public void testSetClassifyTable() {
final int tableIndex = 321;
final InputAclSetInterface request = new InputAclSetInterface();
writer.setClassifyTable(request, tableIndex);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4WriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4WriterTest.java
index 85ee57f79..3954ad425 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4WriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4WriterTest.java
@@ -34,6 +34,7 @@ import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession;
import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable;
import io.fd.vpp.jvpp.core.dto.InputAclSetInterface;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.InterfaceMode;
public class AceIp4WriterTest {
@@ -59,7 +60,7 @@ public class AceIp4WriterTest {
}
private static void verifyTableRequest(final ClassifyAddDelTable request, final int nextTableIndex,
- final int vlanTags) {
+ final int vlanTags, final boolean isL2) {
assertEquals(1, request.isAdd);
assertEquals(-1, request.tableIndex);
assertEquals(1, request.nbuckets);
@@ -74,12 +75,17 @@ public class AceIp4WriterTest {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1,
-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
+
+ if (isL2) {
+ expectedMask[12] = (byte) 0xff;
+ expectedMask[13] = (byte) 0xff;
+ }
AceIpWriterTestUtils.assertArrayEqualsWithOffset(expectedMask, request.mask, vlanTags * VLAN_TAG_LEN);
}
private static void verifySessionRequest(final ClassifyAddDelSession request, final int tableIndex,
- final int vlanTags) {
+ final int vlanTags, final boolean isL2) {
assertEquals(1, request.isAdd);
assertEquals(tableIndex, request.tableIndex);
assertEquals(0, request.hitNextIndex);
@@ -89,55 +95,74 @@ public class AceIp4WriterTest {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 1, 2,
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
+
+ if (isL2) {
+ expectedMatch[12] = (byte) 0x08;
+ expectedMatch[13] = (byte) 0x00;
+ }
AceIpWriterTestUtils.assertArrayEqualsWithOffset(expectedMatch, request.match, vlanTags * VLAN_TAG_LEN);
}
@Test
- public void testGetClassifyAddDelTableRequest() throws Exception {
+ public void testCreateClassifyTable() throws Exception {
+ final int nextTableIndex = 42;
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, InterfaceMode.L3, nextTableIndex, 0);
+ verifyTableRequest(request, nextTableIndex, 0, false);
+ }
+
+ @Test
+ public void testCreateClassifyTableForL2Interface() throws Exception {
final int nextTableIndex = 42;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, 0);
- verifyTableRequest(request, nextTableIndex, 0);
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, InterfaceMode.L2, nextTableIndex, 0);
+ verifyTableRequest(request, nextTableIndex, 0, true);
}
@Test
- public void testGetClassifyAddDelTableRequest1VlanTag() throws Exception {
+ public void testCreateClassifyTable1VlanTag() throws Exception {
final int nextTableIndex = 42;
final int vlanTags = 1;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
- verifyTableRequest(request, nextTableIndex, vlanTags);
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, InterfaceMode.L3, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags, false);
}
@Test
- public void testGetClassifyAddDelTableRequest2VlanTags() throws Exception {
+ public void testCreateClassifyTable2VlanTags() throws Exception {
final int nextTableIndex = 42;
final int vlanTags = 2;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
- verifyTableRequest(request, nextTableIndex, vlanTags);
+ final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, InterfaceMode.L3, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags, false);
+ }
+
+ @Test
+ public void testCreateClassifySession() throws Exception {
+ final int tableIndex = 123;
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, InterfaceMode.L3, tableIndex, 0);
+ verifySessionRequest(request, tableIndex, 0, false);
}
@Test
- public void testGetClassifyAddDelSessionRequest() throws Exception {
+ public void testCreateClassifySessionForL2Interface() throws Exception {
final int tableIndex = 123;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, 0);
- verifySessionRequest(request, tableIndex, 0);
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, InterfaceMode.L2, tableIndex, 0);
+ verifySessionRequest(request, tableIndex, 0, true);
}
@Test
- public void testGetClassifyAddDelSessionRequest1VlanTag() throws Exception {
+ public void testCreateClassifySession1VlanTag() throws Exception {
final int tableIndex = 123;
final int vlanTags = 1;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
- verifySessionRequest(request, tableIndex, vlanTags);
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, InterfaceMode.L3, tableIndex, vlanTags);
+ verifySessionRequest(request, tableIndex, vlanTags, false);
}
@Test
- public void testGetClassifyAddDelSessionRequest2VlanTags() throws Exception {
+ public void testCreateClassifySession2VlanTags() throws Exception {
final int tableIndex = 123;
final int vlanTags = 2;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
+ final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, InterfaceMode.L3, tableIndex, vlanTags);
- verifySessionRequest(request, tableIndex, vlanTags);
+ verifySessionRequest(request, tableIndex, vlanTags, false);
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6WriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6WriterTest.java
index 3f3c6f7bc..260d45487 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6WriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6WriterTest.java
@@ -35,6 +35,7 @@ import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession;
import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable;
import io.fd.vpp.jvpp.core.dto.InputAclSetInterface;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.InterfaceMode;
public class AceIp6WriterTest {
@@ -45,7 +46,7 @@ public class AceIp6WriterTest {
private AceIp aceIp;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
initMocks(this);
writer = new AceIp6Writer(jvpp);
action = new DenyBuilder().setDeny(true).build();
@@ -62,7 +63,7 @@ public class AceIp6WriterTest {
private static void verifyTableRequest(final ClassifyAddDelTable request, final int nextTableIndex,
- final int vlanTags) {
+ final int vlanTags, final boolean isL2) {
assertEquals(1, request.isAdd);
assertEquals(-1, request.tableIndex);
assertEquals(1, request.nbuckets);
@@ -87,12 +88,16 @@ public class AceIp6WriterTest {
// padding to multiple of 16B:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- AceIpWriterTestUtils.assertArrayEqualsWithOffset(expectedMask, request.mask, vlanTags * VLAN_TAG_LEN);
+ if (isL2) {
+ expectedMask[12] = (byte) 0xff;
+ expectedMask[13] = (byte) 0xff;
+ }
+ AceIpWriterTestUtils.assertArrayEqualsWithOffset(expectedMask, request.mask, vlanTags * VLAN_TAG_LEN);
}
private static void verifySessionRequest(final ClassifyAddDelSession request, final int tableIndex,
- final int vlanTags) {
+ final int vlanTags, final boolean isL2) {
assertEquals(1, request.isAdd);
assertEquals(tableIndex, request.tableIndex);
assertEquals(0, request.hitNextIndex);
@@ -112,58 +117,85 @@ public class AceIp6WriterTest {
// padding to multiple of 16B:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
+
+ if (isL2) {
+ expectedMatch[12] = (byte) 0x86;
+ expectedMatch[13] = (byte) 0xdd;
+ }
AceIpWriterTestUtils.assertArrayEqualsWithOffset(expectedMatch, request.match, vlanTags * VLAN_TAG_LEN);
}
@Test
- public void testGetClassifyAddDelTableRequest() throws Exception {
+ public void testCreateClassifyTable() {
final int nextTableIndex = 42;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, 0);
- verifyTableRequest(request, nextTableIndex, 0);
+ final ClassifyAddDelTable request =
+ writer.createClassifyTable(action, aceIp, InterfaceMode.L3, nextTableIndex, 0);
+ verifyTableRequest(request, nextTableIndex, 0, false);
}
@Test
- public void testGetClassifyAddDelTableRequest1VlanTag() throws Exception {
+ public void testCreateClassifyTableForL2Interface() {
+ final int nextTableIndex = 42;
+ final ClassifyAddDelTable request =
+ writer.createClassifyTable(action, aceIp, InterfaceMode.L2, nextTableIndex, 0);
+ verifyTableRequest(request, nextTableIndex, 0, true);
+ }
+
+ @Test
+ public void testCreateClassifyTable1VlanTag() {
final int nextTableIndex = 42;
final int vlanTags = 1;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
- verifyTableRequest(request, nextTableIndex, vlanTags);
+ final ClassifyAddDelTable request =
+ writer.createClassifyTable(action, aceIp, InterfaceMode.L3, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags, false);
}
@Test
- public void testGetClassifyAddDelTableRequest2VlanTag() throws Exception {
+ public void testCreateClassifyTable2VlanTags() {
final int nextTableIndex = 42;
final int vlanTags = 2;
- final ClassifyAddDelTable request = writer.createClassifyTable(action, aceIp, nextTableIndex, vlanTags);
- verifyTableRequest(request, nextTableIndex, vlanTags);
+ final ClassifyAddDelTable request =
+ writer.createClassifyTable(action, aceIp, InterfaceMode.L3, nextTableIndex, vlanTags);
+ verifyTableRequest(request, nextTableIndex, vlanTags, false);
+ }
+
+ @Test
+ public void testCreateClassifySession() {
+ final int tableIndex = 123;
+ final ClassifyAddDelSession request =
+ writer.createClassifySession(action, aceIp, InterfaceMode.L3, tableIndex, 0);
+ verifySessionRequest(request, tableIndex, 0, false);
}
@Test
- public void testGetClassifyAddDelSessionRequest() throws Exception {
+ public void testCreateClassifySessionForL2Interface() {
final int tableIndex = 123;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, 0);
- verifySessionRequest(request, tableIndex, 0);
+ final ClassifyAddDelSession request =
+ writer.createClassifySession(action, aceIp, InterfaceMode.L2, tableIndex, 0);
+ verifySessionRequest(request, tableIndex, 0, true);
}
@Test
- public void testGetClassifyAddDelSessionRequest1VlanTag() throws Exception {
+ public void testCreateClassifySession1VlanTag() {
final int tableIndex = 123;
final int vlanTags = 1;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
- verifySessionRequest(request, tableIndex, vlanTags);
+ final ClassifyAddDelSession request =
+ writer.createClassifySession(action, aceIp, InterfaceMode.L3, tableIndex, vlanTags);
+ verifySessionRequest(request, tableIndex, vlanTags, false);
}
@Test
- public void testGetClassifyAddDelSessionRequest2VlanTag() throws Exception {
+ public void testCreateClassifySession2VlanTags() {
final int tableIndex = 123;
final int vlanTags = 2;
- final ClassifyAddDelSession request = writer.createClassifySession(action, aceIp, tableIndex, vlanTags);
- verifySessionRequest(request, tableIndex, vlanTags);
+ final ClassifyAddDelSession request =
+ writer.createClassifySession(action, aceIp, InterfaceMode.L3, tableIndex, vlanTags);
+ verifySessionRequest(request, tableIndex, vlanTags, false);
}
@Test
- public void testSetClassifyTable() throws Exception {
+ public void testSetClassifyTable() {
final int tableIndex = 321;
final InputAclSetInterface request = new InputAclSetInterface();
writer.setClassifyTable(request, tableIndex);