From: Noa Osherovich <noaos@mellanox.com>
To: "dledford@redhat.com" <dledford@redhat.com>,
Jason Gunthorpe <jgg@mellanox.com>,
Leon Romanovsky <leonro@mellanox.com>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Maxim Chicherin <maximc@mellanox.com>
Subject: [PATCH rdma-core 4/5] tests: Add RDMACM synchronous traffic test
Date: Mon, 4 Nov 2019 10:37:28 +0000 [thread overview]
Message-ID: <20191104103710.11196-5-noaos@mellanox.com> (raw)
In-Reply-To: <20191104103710.11196-1-noaos@mellanox.com>
From: Maxim Chicherin <maximc@mellanox.com>
This test creates active and passive sides for RDMACM communication
and validates received messages.
Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
tests/CMakeLists.txt | 2 ++
tests/rdmacm_utils.py | 43 ++++++++++++++++++++++++++++++++
tests/test_rdmacm.py | 57 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 102 insertions(+)
mode change 100644 => 100755 tests/CMakeLists.txt
create mode 100755 tests/rdmacm_utils.py
create mode 100755 tests/test_rdmacm.py
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
old mode 100644
new mode 100755
index 960276230860..0d81d1a98fb7
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -3,6 +3,7 @@
rdma_python_test(tests
__init__.py
+ rdmacm_utils.py
test_addr.py
base.py
test_cq.py
@@ -11,6 +12,7 @@ rdma_python_test(tests
test_pd.py
test_qp.py
test_odp.py
+ test_rdmacm.py
utils.py
)
diff --git a/tests/rdmacm_utils.py b/tests/rdmacm_utils.py
new file mode 100755
index 000000000000..59b627393e4f
--- /dev/null
+++ b/tests/rdmacm_utils.py
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB)
+# Copyright (c) 2019 Mellanox Technologies, Inc. All rights reserved. See COPYING file
+"""
+Provide some useful helper function for pyverbs rdmacm' tests.
+"""
+from tests.base import CMResources
+from tests.utils import validate
+
+
+def active_side(node):
+ client = CMResources(dst=node)
+ client.pre_run()
+ connected_id = client.cmid
+ send_msg = 'c' * client.msg_size
+ for _ in range(client.num_msgs):
+ client.mr.write(send_msg, client.msg_size)
+ connected_id.post_send(client.mr)
+ while connected_id.get_send_comp() is None:
+ pass
+ connected_id.post_recv(client.mr)
+ while connected_id.get_recv_comp() is None:
+ pass
+ msg_received = client.mr.read(client.msg_size, 0)
+ validate(msg_received, False, client.msg_size)
+ connected_id.disconnect()
+
+
+def passive_side(node):
+ server = CMResources(src=node)
+ server.pre_run()
+ connected_id = server.new_id
+ send_msg = 's' * server.msg_size
+ for _ in range(server.num_msgs):
+ connected_id.post_recv(server.mr)
+ while connected_id.get_recv_comp() is None:
+ pass
+ msg_received = server.mr.read(server.msg_size, 0)
+ validate(msg_received, True, server.msg_size)
+ server.mr.write(send_msg, server.msg_size)
+ connected_id.post_send(server.mr)
+ while connected_id.get_send_comp() is None:
+ pass
+ connected_id.disconnect()
diff --git a/tests/test_rdmacm.py b/tests/test_rdmacm.py
new file mode 100755
index 000000000000..e435c635d7b2
--- /dev/null
+++ b/tests/test_rdmacm.py
@@ -0,0 +1,57 @@
+from tests.rdmacm_utils import active_side, passive_side
+from tests.base import RDMATestCase
+from multiprocessing import Process
+import pyverbs.device as d
+import subprocess
+import unittest
+import json
+
+
+class CMTestCase(RDMATestCase):
+ def setUp(self):
+ if self.dev_name is not None:
+ net_name = self.get_net_name(self.dev_name)
+ try:
+ self.ip_addr = self.get_ip_address(net_name)
+ except KeyError:
+ raise unittest.SkipTest('Device {} has no net interface'
+ .format(self.dev_name))
+ else:
+ dev_list = d.get_device_list()
+ for dev in dev_list:
+ net_name = self.get_net_name(dev.name.decode())
+ try:
+ self.ip_addr = self.get_ip_address(net_name)
+ except IndexError:
+ continue
+ else:
+ self.dev_name = dev.name.decode()
+ break
+ if self.dev_name is None:
+ raise unittest.SkipTest('No devices with net interface')
+ super().setUp()
+
+ @staticmethod
+ def get_net_name(dev):
+ process = subprocess.Popen(['ls', '/sys/class/infiniband/{}/device/net/'
+ .format(dev)], stdout=subprocess.PIPE)
+ out, err = process.communicate()
+ return out.decode().split('\n')[0]
+
+ @staticmethod
+ def get_ip_address(ifname):
+ process = subprocess.Popen(['ip', '-j', 'addr', 'show', ifname],
+ stdout=subprocess.PIPE)
+ out, err = process.communicate()
+ loaded_json = json.loads(out.decode())
+ interface = loaded_json[0]['addr_info'][0]['local']
+ if 'fe80::' in interface:
+ interface = interface + '%' + ifname
+ return interface
+
+ def test_rdmacm_sync_traffic(self):
+ ps = Process(target=passive_side, args=[self.ip_addr])
+ ps.start()
+ ps.join(1)
+ active_side(self.ip_addr)
+ ps.join()
--
2.21.0
next prev parent reply other threads:[~2019-11-04 10:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-04 10:37 [PATCH rdma-core 0/5] Introducing RDMACM support in pyverbs Noa Osherovich
2019-11-04 10:37 ` [PATCH rdma-core 1/5] pyverbs: New CMID class Noa Osherovich
2019-11-04 11:09 ` Benjamin Drung
2019-11-05 14:46 ` Leon Romanovsky
2019-11-04 10:37 ` [PATCH rdma-core 2/5] tests: Fix PD API test Noa Osherovich
2019-11-04 10:37 ` [PATCH rdma-core 3/5] tests: New CMResources Class Noa Osherovich
2019-11-04 10:37 ` Noa Osherovich [this message]
2019-11-04 10:37 ` [PATCH rdma-core 5/5] Documentation: Document creation of CMID Noa Osherovich
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=20191104103710.11196-5-noaos@mellanox.com \
--to=noaos@mellanox.com \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=maximc@mellanox.com \
/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).