X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fbindings%2Frmr-python%2Ftests%2Ftest_rmr.py;h=b0e43ee7f8542d2630427f32101666a1e777b437;hb=04c3a6eab6289751feb358c4d3ebe451992d80cf;hp=50dffc272bcadfd19695c672ba14a81ef796f338;hpb=398a04fedca806ed800ba6909c715ef3e952e0b0;p=ric-plt%2Flib%2Frmr.git diff --git a/src/bindings/rmr-python/tests/test_rmr.py b/src/bindings/rmr-python/tests/test_rmr.py index 50dffc2..b0e43ee 100644 --- a/src/bindings/rmr-python/tests/test_rmr.py +++ b/src/bindings/rmr-python/tests/test_rmr.py @@ -168,6 +168,13 @@ def test_alloc_fancy(): assert sbuf.contents.sub_id == summary["subscription id"] == 654321 +def test_alloc_overlapping_flags(): + """test allocation with setting the transaction id""" + sbuf = rmr.rmr_alloc_msg(MRC_SEND, SIZE, gen_transaction_id=True, fixed_transaction_id=b"6" * 32) + summary = rmr.message_summary(sbuf) + assert summary["transaction id"] == b"66666666666666666666666666666666" + + def test_rcv_timeout(): """ test torcv; this is a scary test because if it fails... it doesn't fail, it will run forever! @@ -210,8 +217,7 @@ def test_send_rcv(): # send an ACK back ack_pay = b"message received" - rmr.set_payload_and_length(ack_pay, sbuf_rcv) - sbuf_rcv = rmr.rmr_rts_msg(MRC_RCV, sbuf_rcv) + sbuf_rcv = rmr.rmr_rts_msg(MRC_RCV, sbuf_rcv, payload=ack_pay, mtype=6666) rcv_ack_summary = rmr.message_summary(sbuf_rcv) # have the sender receive it @@ -221,6 +227,7 @@ def test_send_rcv(): assert send_ack_summary["message state"] == rcv_ack_summary["message state"] == 0 assert send_ack_summary["message status"] == rcv_ack_summary["message status"] == "RMR_OK" assert send_ack_summary["payload"] == ack_pay + assert send_ack_summary["message type"] == 6666 def test_send_rcv_subid_good(): @@ -311,7 +318,7 @@ def test_rcv_all(): bundle = helpers.rmr_rcvall_msgs(MRC_BUF_RCV) # use the buffered receiver to read all with a single call assert len(bundle) == 13 - for i in range(len(bundle)): + for i, ms in enumerate(bundle): ms = bundle[i] # validate each summary returned, and ordering preserved assert ms["message state"] == 0 expected_pay = bytes(pay_fmt % i, "UTF-8") @@ -323,15 +330,17 @@ def test_rcv_all(): send_burst(MRC_SEND, pay_fmt, mtype=2, num=4, counter=8) # total of 12 messages with type 2 should be queued time.sleep(1) # ensure underlying transport gets cycles to send/receive - bundle = helpers.rmr_rcvall_msgs(MRC_BUF_RCV, [2]) # receive only message type 2 messages + bundle = helpers.rmr_rcvall_msgs_raw(MRC_BUF_RCV, [2]) # receive only message type 2 messages assert len(bundle) == 12 # we should only get the second batch of 12 messages - for i in range(len(bundle)): - ms = bundle[i] # validate each summary + for i, (ms, sbuf) in enumerate(bundle): # test the raw version + test_summary = rmr.message_summary(sbuf) + assert test_summary == ms assert ms["message state"] == 0 # all should be OK assert ms["message type"] == 2 # only mtype 2 should have been received expected_pay = bytes(pay_fmt % i, "UTF-8") # ordering should still jive with the counter assert ms["payload"] == expected_pay + rmr.rmr_free_msg(sbuf) def test_bad_buffer():