summaryrefslogtreecommitdiffstats
path: root/vpp-classifier/impl/src/test/java/io/fd
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-08-13 17:18:23 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-08-14 10:37:52 +0200
commit4eee8fa4da610eced563f12f9ee935130fdb09c7 (patch)
tree28f9b5dfc02c7171215ecd403403b5f016bba7e5 /vpp-classifier/impl/src/test/java/io/fd
parent5003049edb722ad7c415981fa2c85c17ba876264 (diff)
HC2VPP-375: align classify session's match with skip-n-vectors zeros
If bigger values of skip-n-vectors are used (e.g. policer usecase), also key is very long, making the API hard to use. To make it easier, match value will be now aligned with zeros if needed. Read part does not need to be updated, beacause classify_session_dump returns match without skip-n-vectors part. Change-Id: Iab54480e7a3851690aed30c8f5b8b0e6769c054f Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-classifier/impl/src/test/java/io/fd')
-rw-r--r--vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java31
1 files changed, 13 insertions, 18 deletions
diff --git a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java
index 68d20a728..c33a21ece 100644
--- a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java
+++ b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java
@@ -78,15 +78,20 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
private static ClassifyAddDelSession generateClassifyAddDelSession(final byte isAdd, final int tableIndex,
final int sessionIndex) {
+ return generateClassifyAddDelSession(isAdd, tableIndex, sessionIndex,
+ new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
+ (byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00});
+ }
+
+ private static ClassifyAddDelSession generateClassifyAddDelSession(final byte isAdd, final int tableIndex,
+ final int sessionIndex, final byte[] match) {
final ClassifyAddDelSession request = new ClassifyAddDelSession();
request.isAdd = isAdd;
request.tableIndex = tableIndex;
request.opaqueIndex = sessionIndex;
request.hitNextIndex = 0;
request.advance = 123;
- request.match =
- new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
- (byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00};
+ request.match = match;
request.matchLen = request.match.length;
return request;
}
@@ -193,19 +198,6 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(id, classifySession, writeContext);
}
- @Test(expected = IllegalArgumentException.class)
- public void testCreateInvalidMatchLength() throws WriteFailedException {
- final ClassifyTable table = mock(ClassifyTable.class);
- when(table.getMask()).thenReturn(new HexString("00:00:00:00:00:00:ff:FF:ff:ff:ff:FF:00:00:00:00"));
- when(table.getSkipNVectors()).thenReturn(1L);
- when(writeContext.readAfter(ArgumentMatchers.any())).thenReturn(Optional.of(table));
-
- final String match = "00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00";
- final ClassifySession classifySession = generateClassifySession(SESSION_INDEX, match);
- final InstanceIdentifier<ClassifySession> id = getClassifySessionId(TABLE_NAME, match);
- customizer.writeCurrentAttributes(id, classifySession, writeContext);
- }
-
@Test
public void testCreateSkipOneVector() throws WriteFailedException {
final ClassifyTable table = mock(ClassifyTable.class);
@@ -214,10 +206,13 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest {
when(writeContext.readAfter(ArgumentMatchers.any())).thenReturn(Optional.of(table));
whenClassifyAddDelSessionThenSuccess();
- final String match =
- "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00";
+ final String match = "01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10";
final ClassifySession classifySession = generateClassifySession(SESSION_INDEX, match);
final InstanceIdentifier<ClassifySession> id = getClassifySessionId(TABLE_NAME, match);
customizer.writeCurrentAttributes(id, classifySession, writeContext);
+ verify(api).classifyAddDelSession(generateClassifyAddDelSession((byte) 1, TABLE_INDEX, SESSION_INDEX,
+ new byte[] {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));
}
} \ No newline at end of file