2929 order ,
3030 multi_node ,
3131)
32+ from blazingmq .dev .it .common import BMQTestError , BMQTST_ASSERT
3233from blazingmq .dev .it .process .client import Client
3334from blazingmq .dev .it .util import wait_until
3435
3536pytestmark = order (6 )
3637
3738
38- class BMQITError (RuntimeError ):
39- """
40- BMQ IT error.
41- """
42-
43-
4439class TestClusterNodeShutdown :
4540 """
4641 This suite of test cases exercises node shutdown and subsequent failover
@@ -50,10 +45,12 @@ class TestClusterNodeShutdown:
5045 @staticmethod
5146 def open_or_raise (client : Client , uri : str , flags : List [str ]):
5247 rc = client .open (uri , flags = flags , succeed = True )
53- if rc != Client .e_SUCCESS :
54- raise BMQITError (
55- f"Failed to open a queue: client = { client } , uri = { uri } , rc = { rc } "
56- )
48+ BMQTST_ASSERT (rc == Client .e_SUCCESS ,
49+ "Failed to open a queue" ,
50+ client = client ,
51+ uri = uri ,
52+ flags = flags ,
53+ rc = rc )
5754
5855 def setup_cluster (self , cluster : Cluster , domain_urls : tc .DomainUrls ):
5956 du = domain_urls
@@ -128,7 +125,7 @@ def release_recovery_if_state_restored(line: str) -> None:
128125 _ = recovery .get (timeout = 120 )
129126 except queue .Empty as ex :
130127 # No recovery log observed
131- raise BMQITError ("State is not restored" ) from ex
128+ raise BMQTestError ("State is not restored" ) from ex
132129 sleep (5 )
133130
134131 self ._verify_all_queues_operational (domain_urls ) # After recovery
@@ -149,14 +146,20 @@ def check_received_one_of(consumer: Client, uri_group: str, *expected):
149146 )
150147 msgs = consumer .list (uri_group , block = True )
151148 self .history .append ((str (consumer .name ), uri_group , msgs ))
152- if len (msgs ) != 1 :
153- raise BMQITError (
154- f"Expected 1 message, got: { len (msgs )} msgs.\n Messages history:\n { self .history } "
155- )
156- if msgs [0 ].payload not in expected :
157- raise BMQITError (
158- f"Unexpected message payload: { msgs [0 ].payload } (expected: { expected } )"
159- )
149+ BMQTST_ASSERT (len (msgs ) == 1 ,
150+ "Expected exactly 1 message" ,
151+ client = consumer ,
152+ uri = uri_group ,
153+ observed_messages = msgs ,
154+ history = self .history )
155+ BMQTST_ASSERT (msgs [0 ].payload in expected ,
156+ "Unexpected message payload" ,
157+ client = consumer ,
158+ uri = uri_group ,
159+ observed_messages = msgs ,
160+ history = self .history ,
161+ expected_any_of = expected
162+ )
160163 consumer .confirm (uri_group , "*" , succeed = True )
161164
162165 def check_both_received_one_of (* expected ):
0 commit comments