diff mbox series

[RFC] tests: Fix test_mr_rereg_pd

Message ID 20230525042517.14657-1-rpearsonhpe@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series [RFC] tests: Fix test_mr_rereg_pd | expand

Commit Message

Bob Pearson May 25, 2023, 4:25 a.m. UTC
This patch adds a util method drain_cq which drains out
the cq associated with a client or server. This is then
added to the method restate_qps in tests/test_mr.py.
This allows correct operation when recovering test state
from an error which may have also left stray completions
in the cqs before resetting the qps for use.

Fixes: 4bc72d894481 ("tests: Add rereg MR tests")
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 tests/test_mr.py |  2 ++
 tests/utils.py   | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

Comments

Edward Srouji May 29, 2023, 10:48 a.m. UTC | #1
I see that the traffic() function used in this test posts just one 
receive/send WR each iteration.
Meaning that once the first CQE with error occurs, there are no more 
CQEs left to drain.

If that is the case, I'm not sure why you still see stray completions in 
the CQ.

On 5/25/2023 7:25 AM, Bob Pearson wrote:
> External email: Use caution opening links or attachments
>
>
> This patch adds a util method drain_cq which drains out
> the cq associated with a client or server. This is then
> added to the method restate_qps in tests/test_mr.py.
> This allows correct operation when recovering test state
> from an error which may have also left stray completions
> in the cqs before resetting the qps for use.
>
> Fixes: 4bc72d894481 ("tests: Add rereg MR tests")
> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
> ---
>   tests/test_mr.py |  2 ++
>   tests/utils.py   | 14 ++++++++++++++
>   2 files changed, 16 insertions(+)
>
> diff --git a/tests/test_mr.py b/tests/test_mr.py
> index 534df46a..73dfbff2 100644
> --- a/tests/test_mr.py
> +++ b/tests/test_mr.py
> @@ -109,6 +109,8 @@ class MRTest(RDMATestCase):
>           self.server.qp.to_rts(self.server_qp_attr)
>           self.client.qp.modify(QPAttr(qp_state=e.IBV_QPS_RESET), e.IBV_QP_STATE)
>           self.client.qp.to_rts(self.client_qp_attr)
> +        u.drain_cq(self.client.cq)
> +        u.drain_cq(self.server.cq)
>
>       def test_mr_rereg_access(self):
>           self.create_players(MRRes)
> diff --git a/tests/utils.py b/tests/utils.py
> index a1dfa7d8..f6966b1a 100644
> --- a/tests/utils.py
> +++ b/tests/utils.py
> @@ -672,6 +672,20 @@ def poll_cq_ex(cqex, count=1, data=None, sgid=None):
>       finally:
>           cqex.end_poll()
Keep two blank lines before and after module-level function definition 
(PEP-8 convention)
> +def drain_cq(cq):
> +    """
> +    Drain completions from a CQ.
> +    :param cq: CQ to drain
> +    :return: None
> +    """
> +    channel = cq.comp_channel
> +    while 1:
> +        if channel:
> +            channel.get_cq_event(cq)
> +            cq.req_notify()
> +        nc, tmp_wcs = cq.poll(1)

tmp_wcs is unused. You can do this instead:

nc, _ = cq.poll(1)

> +        if nc == 0:
> +            break
>
>   def validate(received_str, is_server, msg_size):
>       """
> --
> 2.39.2
>
Bob Pearson May 29, 2023, 5:20 p.m. UTC | #2
On 5/29/23 05:48, Edward Srouji wrote:
> I see that the traffic() function used in this test posts just one receive/send WR each iteration.
> Meaning that once the first CQE with error occurs, there are no more CQEs left to drain.
I believe it is the receive WQEs that are getting flushed.
> 
> If that is the case, I'm not sure why you still see stray completions in the CQ.
> 
> On 5/25/2023 7:25 AM, Bob Pearson wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> This patch adds a util method drain_cq which drains out
>> the cq associated with a client or server. This is then
>> added to the method restate_qps in tests/test_mr.py.
>> This allows correct operation when recovering test state
>> from an error which may have also left stray completions
>> in the cqs before resetting the qps for use.
>>
>> Fixes: 4bc72d894481 ("tests: Add rereg MR tests")
>> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
>> ---
>>   tests/test_mr.py |  2 ++
>>   tests/utils.py   | 14 ++++++++++++++
>>   2 files changed, 16 insertions(+)
>>
>> diff --git a/tests/test_mr.py b/tests/test_mr.py
>> index 534df46a..73dfbff2 100644
>> --- a/tests/test_mr.py
>> +++ b/tests/test_mr.py
>> @@ -109,6 +109,8 @@ class MRTest(RDMATestCase):
>>           self.server.qp.to_rts(self.server_qp_attr)
>>           self.client.qp.modify(QPAttr(qp_state=e.IBV_QPS_RESET), e.IBV_QP_STATE)
>>           self.client.qp.to_rts(self.client_qp_attr)
>> +        u.drain_cq(self.client.cq)
>> +        u.drain_cq(self.server.cq)
>>
>>       def test_mr_rereg_access(self):
>>           self.create_players(MRRes)
>> diff --git a/tests/utils.py b/tests/utils.py
>> index a1dfa7d8..f6966b1a 100644
>> --- a/tests/utils.py
>> +++ b/tests/utils.py
>> @@ -672,6 +672,20 @@ def poll_cq_ex(cqex, count=1, data=None, sgid=None):
>>       finally:
>>           cqex.end_poll()
> Keep two blank lines before and after module-level function definition (PEP-8 convention)
>> +def drain_cq(cq):
>> +    """
>> +    Drain completions from a CQ.
>> +    :param cq: CQ to drain
>> +    :return: None
>> +    """
>> +    channel = cq.comp_channel
>> +    while 1:
>> +        if channel:
>> +            channel.get_cq_event(cq)
>> +            cq.req_notify()
>> +        nc, tmp_wcs = cq.poll(1)
> 
> tmp_wcs is unused. You can do this instead:
> 
> nc, _ = cq.poll(1)
> 
>> +        if nc == 0:
>> +            break
>>
>>   def validate(received_str, is_server, msg_size):
>>       """
>> -- 
>> 2.39.2
>>

Thanks, I can fix those.

Bob
diff mbox series

Patch

diff --git a/tests/test_mr.py b/tests/test_mr.py
index 534df46a..73dfbff2 100644
--- a/tests/test_mr.py
+++ b/tests/test_mr.py
@@ -109,6 +109,8 @@  class MRTest(RDMATestCase):
         self.server.qp.to_rts(self.server_qp_attr)
         self.client.qp.modify(QPAttr(qp_state=e.IBV_QPS_RESET), e.IBV_QP_STATE)
         self.client.qp.to_rts(self.client_qp_attr)
+        u.drain_cq(self.client.cq)
+        u.drain_cq(self.server.cq)
 
     def test_mr_rereg_access(self):
         self.create_players(MRRes)
diff --git a/tests/utils.py b/tests/utils.py
index a1dfa7d8..f6966b1a 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -672,6 +672,20 @@  def poll_cq_ex(cqex, count=1, data=None, sgid=None):
     finally:
         cqex.end_poll()
 
+def drain_cq(cq):
+    """
+    Drain completions from a CQ.
+    :param cq: CQ to drain
+    :return: None
+    """
+    channel = cq.comp_channel
+    while 1:
+        if channel:
+            channel.get_cq_event(cq)
+            cq.req_notify()
+        nc, tmp_wcs = cq.poll(1)
+        if nc == 0:
+            break
 
 def validate(received_str, is_server, msg_size):
     """