summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-12-04 17:19:12 -0500
committerDave Barach <dave@barachs.net>2020-02-12 09:42:05 -0500
commit7c5a3536ce4c2fd4157c466367c495cefecaa52e (patch)
treefe6e70be8b1d2e0a594b0268d7a51962155b65a5 /test
parentd28bac409409ea821cd9ce2ec4f84a7786cbcb73 (diff)
classify: vpp packet tracer support
Configure n-tuple classifier filters which apply to the vpp packet tracer. Update the documentation to reflect the new feature. Add a test vector. Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Iefa911716c670fc12e4825b937b62044433fec36 (cherry picked from commit 87d24db65facb89ca524c951b8379ca2ec4dbc7a)
Diffstat (limited to 'test')
-rw-r--r--test/test_trace_filter.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/test_trace_filter.py b/test/test_trace_filter.py
new file mode 100644
index 00000000000..bde732d289f
--- /dev/null
+++ b/test/test_trace_filter.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+
+import unittest
+
+from framework import VppTestCase, VppTestRunner, running_extended_tests
+from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
+
+
+class TestTracefilter(VppTestCase):
+ """ Packet Tracer Filter Test """
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestTracefilter, cls).setUpClass()
+
+ @classmethod
+ def tearDownClass(cls):
+ super(TestTracefilter, cls).tearDownClass()
+
+ def setUp(self):
+ super(TestTracefilter, self).setUp()
+
+ def tearDown(self):
+ super(TestTracefilter, self).tearDown()
+
+ def test_mactime_unitTest(self):
+ """ Packet Tracer Filter Test """
+ cmds = ["loopback create",
+ "set int ip address loop0 192.168.1.1/24",
+ "set int state loop0 up",
+ "packet-generator new {\n"
+ " name classifyme\n"
+ " limit 100\n"
+ " size 300-300\n"
+ " interface loop0\n"
+ " node ethernet-input\n"
+ " data { \n"
+ " IP4: 1.2.3 -> 4.5.6\n"
+ " UDP: 192.168.1.10 - 192.168.1.20 -> 192.168.2.10\n"
+ " UDP: 1234 -> 2345\n"
+ " incrementing 286\n"
+ " }\n"
+ "}\n",
+ "classify filter trace mask l3 ip4 src\n"
+ " match l3 ip4 src 192.168.1.15",
+ "trace add pg-input 100 filter",
+ "pa en"]
+
+ for cmd in cmds:
+ r = self.vapi.cli_return_response(cmd)
+ if r.retval != 0:
+ if hasattr(r, 'reply'):
+ self.logger.info(cmd + " FAIL reply " + r.reply)
+ else:
+ self.logger.info(cmd + " FAIL retval " + str(r.retval))
+
+ # Check for 9 classifier hits, which is the right answer
+ r = self.vapi.cli_return_response("show classify table verbose 2")
+ self.assertTrue(r.retval == 0)
+ self.assertTrue(hasattr(r, 'reply'))
+ self.assertTrue(r.reply.find("hits 9") != -1)
+
+if __name__ == '__main__':
+ unittest.main(testRunner=VppTestRunner)