From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C9587A04B1; Mon, 23 Nov 2020 10:52:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BFD9AC8E6; Mon, 23 Nov 2020 10:52:09 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id A6362C8E6 for ; Mon, 23 Nov 2020 10:52:07 +0100 (CET) IronPort-SDR: TlaEmgW72N8wuM+Pi/cz1c21sviFEfyYc+sIqM9KgfdMlpvlYKocbIh4eHivCaaKQ6JFjB/1SB yPRfhUBg/aQw== X-IronPort-AV: E=McAfee;i="6000,8403,9813"; a="235875832" X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="235875832" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 01:52:07 -0800 IronPort-SDR: lcdGoPqgAAv/W3OVWzkmpF/23KSWhULli2LcN/gQsobKh667dyoG70uvZLf41uu4mDH0fctH5w VHTaRDRmcO7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="534401174" Received: from unknown (HELO bdcdev09.localdomain) ([10.190.193.143]) by fmsmga006.fm.intel.com with ESMTP; 23 Nov 2020 01:52:05 -0800 From: Churchill Khangar To: dts@dpdk.org Cc: cristian.dumitrescu@intel.com, venkata.suresh.kumar.p@intel.com, churchill.khangar@intel.com, yogesh.jangra@intel.com Date: Mon, 23 Nov 2020 04:49:52 -0500 Message-Id: <1606124992-45581-3-git-send-email-churchill.khangar@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1606124992-45581-1-git-send-email-churchill.khangar@intel.com> References: <1606124992-45581-1-git-send-email-churchill.khangar@intel.com> Subject: [dts] [PATCH 2/2] tests/pipeline: add table default and normal rule tests X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Add additional pipeline table test scenarios to verify the behavior of pipeline library when table is populated with normal rules, default rule and action. Signed-off-by: Churchill Khangar Tested-by: Venkata Suresh Kumar P --- tests/TestSuite_pipeline.py | 215 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) diff --git a/tests/TestSuite_pipeline.py b/tests/TestSuite_pipeline.py index 9b13575..9933fd7 100644 --- a/tests/TestSuite_pipeline.py +++ b/tests/TestSuite_pipeline.py @@ -32,6 +32,7 @@ import utils import re import time +import socket from settings import HEADER_SIZE from test_case import TestCase @@ -5818,6 +5819,220 @@ class TestPipeline(TestCase): cmd = "^C" self.dut.send_expect(cmd, "# ", 20) + def test_table_002(self): + + cli_file = '/tmp/pipeline/table_002/table_002.cli' + + cmd = "sed -i -e 's/0000:00:04.0/%s/' {}".format(cli_file) % self.dut_p0_pci + self.dut.send_expect(cmd, "# ", 20) + cmd = "sed -i -e 's/0000:00:05.0/%s/' {}".format(cli_file) % self.dut_p1_pci + self.dut.send_expect(cmd, "# ", 20) + cmd = "sed -i -e 's/0000:00:06.0/%s/' {}".format(cli_file) % self.dut_p2_pci + self.dut.send_expect(cmd, "# ", 20) + cmd = "sed -i -e 's/0000:00:07.0/%s/' {}".format(cli_file) % self.dut_p3_pci + self.dut.send_expect(cmd, "# ", 20) + + DUT_PORTS = " -w {0} -w {1} -w {2} -w {3} "\ + .format(self.dut_p0_pci, self.dut_p1_pci, self.dut_p2_pci, self.dut_p3_pci) + + cmd = "{0} -c 0x3 -n 4 {1} -- -s {2}".format(self.app_pipeline_path, DUT_PORTS, cli_file) + self.dut.send_expect(cmd, "PIPELINE0 enable", 60) + + sleep(2) + + # create TCP connection to the server + SERVER_IP = '192.168.122.216' + SERVER_PORT = 8086 + BUFFER_SIZE = 1024 + + try: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + except socket.error as err: + print("socket creation failed with error %s" % (err)) + + try: + s.connect((SERVER_IP, SERVER_PORT)) + except socket.error as err: + print("socket connection failed with error %s" % (err)) + + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + # print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + + # test empty table scenario + in_pcap_file = 'pipeline/table_002/pcap_files/in_1.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_1.txt' + filters = "tcp" + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 2, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 3, in_pcap_file, out_pcap_file, filters) + + # test single rule scenario + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_2.txt' + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update {} none none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + # print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_2.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_2.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 2, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 3, in_pcap_file, out_pcap_file, filters) + + # test two rules scenario + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_3.txt' + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update {} none none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + # print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_3.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_3.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 2, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 3, in_pcap_file, out_pcap_file, filters) + + # delete one rule scenario + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_4_1.txt' + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update none {} none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + # print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_4_1.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_4_1.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 2, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 3, in_pcap_file, out_pcap_file, filters) + + # delete all rules scenario + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_4_2.txt' + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update none {} none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + # print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_4_2.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_4_2.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 2, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 3, in_pcap_file, out_pcap_file, filters) + + # action update scenario (restore one of the previously deleted rules and check the update) + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_5_1.txt' + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update {} none none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_5_1.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_5_1.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + + # action update scenario (change the action of restored rule and check the update) + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_5_2.txt' + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update {} none none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_5_1.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_5_1.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 3, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 2, in_pcap_file, out_pcap_file, filters) + + # deafult action scenario [empty table] + ''' + Empty table => Lookup MISS with default action executed + ''' + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_6_1.txt' # delete the previously added rule + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update none {} none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_6_1.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_6_1.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 2, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 3, in_pcap_file, out_pcap_file, filters) + + # deafult action scenario [table with one rule] + ''' + Add key A => Lookup HIT for the right packet with the specific key associated action executed + Lookup MISS for any other packets with default action executed + ''' + CMD_FILE = '/tmp/pipeline/table_002/cmd_files/cmd_6_2.txt' # add a new rule + CLI_CMD = 'pipeline PIPELINE0 table table_002_table update {} none none\n'.format(CMD_FILE) + s.send(CLI_CMD.encode('utf-8')) + sleep(0.1) + msg = s.recv(BUFFER_SIZE) + response = msg.decode() + print('Rxd: ' + response) + if "pipeline>" not in response: + s.close() + self.verify(0, "CLI response error") + filters = "tcp" + in_pcap_file = 'pipeline/table_002/pcap_files/in_6_2.txt' + out_pcap_file = 'pipeline/table_002/pcap_files/out_6_2.txt' + sniff_pkts = self.send_and_sniff_pkts(0, 0, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(1, 1, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(2, 2, in_pcap_file, out_pcap_file, filters) + sniff_pkts = self.send_and_sniff_pkts(3, 3, in_pcap_file, out_pcap_file, filters) + + s.close() + sleep(1) + cmd = "^C" + self.dut.send_expect(cmd, "# ", 20) + def tear_down(self): """ Run after each test case. -- 1.8.3.1