Soft Patch Panel
 help / color / mirror / Atom feed
From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 2/3] test: add spp_nfv test for forwarding
Date: Tue, 17 Dec 2019 11:37:29 +0900	[thread overview]
Message-ID: <20191217023730.30477-3-yasufum.o@gmail.com> (raw)
In-Reply-To: <20191217023730.30477-1-yasufum.o@gmail.com>

From: Yasufumi Ogawa <yasufum.o@gmail.com>

This update is to add a test for checking if packet is forwarded between
ports. In this test, it sends packets from src nullpmd to dst nullpmd
via ring, and number of forwarded packets is checked by referring status
of spp_primary.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 test/test_spp_nfv.py | 47 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/test/test_spp_nfv.py b/test/test_spp_nfv.py
index 1ebb3d3..1376df7 100644
--- a/test/test_spp_nfv.py
+++ b/test/test_spp_nfv.py
@@ -126,6 +126,14 @@ class TestSppNfv(unittest.TestCase):
                 sec_id=self.default_sec_id)
         requests.delete(url)
 
+    def _get_pri_status(self):
+        """Get status of spp_primary"""
+
+        url = "{baseurl}/primary/status".format(
+                baseurl=self.base_url)
+        response = requests.get(url)
+        return response.json()
+
     # Test methods for testing spp_nfv from here.
     def test_sec_id(self):
         """Confirm sec ID is expected value."""
@@ -177,3 +185,42 @@ class TestSppNfv(unittest.TestCase):
         self._reset_patches()
         nfv = self._get_status()
         self.assertEqual(nfv['patches'], [])
+
+        for port in ports:
+            self._del_port(port)
+
+    def test_forwarding(self):
+        """Check if forwarding packet is counted up.
+
+        This test confirm that packet counter on ring PMD is counted up
+        after forwarding is started. It waits about 1sec so that
+        certain amount of packets are forwarded.
+        """
+
+        wait_time = 1  # sec, wait for forwarding
+        ring_idx = 1
+        ports = {
+                'src': 'nullpmd:1',
+                'dst': 'nullpmd:2',
+                'ring': 'ring:{}'.format(ring_idx)
+                }
+
+        for port in ports.values():
+            self._add_port(port)
+
+        self._patch(ports['src'], ports['ring'])
+        self._patch(ports['ring'], ports['dst'])
+        self._set_forwarding_status('start')
+
+        # NOTE: this test is failed if sleep time is too small.
+        time.sleep(wait_time)  # wait to start forwarding
+
+        self._set_forwarding_status('stop')
+        self._reset_patches()
+        for port in ports.values():
+            self._del_port(port)
+
+        pri = self._get_pri_status()
+
+        self.assertTrue(pri['ring_ports'][ring_idx]['rx'] > 0)
+        self.assertTrue(pri['ring_ports'][ring_idx]['tx'] > 0)
-- 
2.17.1


  parent reply	other threads:[~2019-12-17  2:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17  2:37 [spp] [PATCH 0/3] Introduce unit test for SPP processes yasufum.o
2019-12-17  2:37 ` [spp] [PATCH 1/3] test: add test for spp_nfv yasufum.o
2019-12-17  2:37 ` yasufum.o [this message]
2019-12-17  2:37 ` [spp] [PATCH 3/3] test: add test for spp_primary yasufum.o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191217023730.30477-3-yasufum.o@gmail.com \
    --to=yasufum.o@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).