From patchwork Thu Nov 26 07:50:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Churchill Khangar X-Patchwork-Id: 84566 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F14ECA0524; Thu, 26 Nov 2020 08:53:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5BA7C950; Thu, 26 Nov 2020 08:53:04 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 9CFD6C94E for ; Thu, 26 Nov 2020 08:53:02 +0100 (CET) IronPort-SDR: oOu5OBKrnYlx+WdOM/ECaPBJTR9LtFY9GtZ+zIhobGAMtBIwAu5nks80rlpg9zS1f98wMf17Jl MDehLJF6wl5g== X-IronPort-AV: E=McAfee;i="6000,8403,9816"; a="160019026" X-IronPort-AV: E=Sophos;i="5.78,371,1599548400"; d="scan'208";a="160019026" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 23:53:02 -0800 IronPort-SDR: 8LhkKMBfVCWBZa1gyaHvVFiEJD9ZBQTKB8MGfCrkvpXjvvxnepnsUwM0FOz3+lDZLwptDbxcHB 6SEzVMKw9nbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,371,1599548400"; d="scan'208";a="547616882" Received: from unknown (HELO bdcdev09.localdomain) ([10.190.193.143]) by orsmga005.jf.intel.com with ESMTP; 25 Nov 2020 23:53:00 -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: Thu, 26 Nov 2020 02:50:50 -0500 Message-Id: <1606377051-47458-2-git-send-email-churchill.khangar@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1606377051-47458-1-git-send-email-churchill.khangar@intel.com> References: <1606377051-47458-1-git-send-email-churchill.khangar@intel.com> Subject: [dts] [PATCH v2 1/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.