From 63c52ab26ec38d4aca5ae4f0be5c2d925f429c3c Mon Sep 17 00:00:00 2001 From: Angel Martinez Date: Thu, 7 Mar 2024 07:27:32 -0800 Subject: [PATCH] Simplified the detection of read data in the subscriber app (#26) --- README.md | 24 ++++++----- interoperability_report.py | 81 ++++++++++---------------------------- rtps_test_utilities.py | 4 -- test_suite.py | 12 +++--- 4 files changed, 37 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index 6c43db5..0e1e2e6 100644 --- a/README.md +++ b/README.md @@ -227,8 +227,9 @@ These printed strings and the corresponding Return Codes follows this workflow * `'on_publication_matched()'`: * case '-w' not in parameters -> `OK` * case '-w' in parameters: - * `'[10-99]'`-> `OK` - * `'[10-99]'` not found -> `DATA_NOT_SENT` + * `'[[0-9]+]'`-> `OK` + * `'on_offered_deadline_missed'` -> `DEADLINE_MISSED` + * No string matched -> `DATA_NOT_SENT` **Subscriber**: @@ -238,17 +239,14 @@ These printed strings and the corresponding Return Codes follows this workflow * No string matched -> `READER_NOT_CREATED` * `'Create reader for topic'`: * `'on_requested_incompatible_qos()'`-> `INCOMPATIBLE_QOS` - * None string matched -> `WRITER_NOT_MATCHED` - * `'on_subscription_matched()'`: - * `'on_liveliness_changed()'` not found -> `WRITER_NOT_ALIVE` - * `'on_liveliness_changed()'`: - * `'[10-99]'` not found -> `DATA_NOT_RECEIVED` - * `'[10-99]'`: - * `checking_function` not defined in Test Case -> `OK` - * `checking_function` defined in Test Case -> `OK`, `DATA_NOT_CORRECT`, - `RECEIVING_FROM_ONE` or `RECEIVING_FROM_BOTH`, depending on the function. - -> **Note**: `'[10-99]'` is the shapesize of the samples. The + * `'on_requested_deadline_missed'` -> `DEADLINE_MISSED` + * `'[[0-9]+]'`: + * `checking_function` not defined in Test Case -> `OK` + * `checking_function` defined in Test Case -> `OK`, `DATA_NOT_CORRECT`, + `RECEIVING_FROM_ONE` or `RECEIVING_FROM_BOTH`, depending on the function. + * No string matched -> `DATA_NOT_RECEIVED` + +> **Note**: `'[[0-9]+]'` is the shapesize of the samples. The > `interoperability_report` script is only taking into account the shapesize in > order to match a printed shape sample. This does not prevent the script to > recover the other information: x, y and color. diff --git a/interoperability_report.py b/interoperability_report.py index ef1de34..eee32d8 100644 --- a/interoperability_report.py +++ b/interoperability_report.py @@ -134,70 +134,30 @@ def run_subscriber_shape_main( # on_subscription_matched() takes precedence over on_liveliness_changed() index = child_sub.expect( [ - 'on_subscription_matched()', # index = 0 - pexpect.TIMEOUT, # index = 1 - 'on_requested_incompatible_qos()', # index = 2 - 'on_liveliness_changed()' # index = 3 + '\[[0-9]+\]', # index = 0 + 'on_requested_incompatible_qos()', # index = 1 + 'on_requested_deadline_missed()', # index = 2 + pexpect.TIMEOUT, # index = 3 ], timeout ) if index == 1: - produced_code[produced_code_index] = ReturnCode.WRITER_NOT_MATCHED - elif index == 2: produced_code[produced_code_index] = ReturnCode.INCOMPATIBLE_QOS - # This case handles when on_liveliness_changed() happens before - # on_subscription_matched() - elif index == 0 or index == 3: - # Step 5: Check if the reader detects the writer as alive - if index == 3: - log_message(f'Subscriber {subscriber_index}: Found alive ' - 'DataWriter. Waiting for matching DataWriter.', verbosity) - index = child_sub.expect( - [ - 'on_subscription_matched()', # index = 0 - pexpect.TIMEOUT # index = 1 - ], - timeout - ) - else: - log_message(f'Subscriber {subscriber_index}: Waiting for ' - 'detecting DataWriter alive', verbosity) - index = child_sub.expect( - [ - 'on_liveliness_changed()', # index = 0 - pexpect.TIMEOUT # index = 1 - ], - timeout - ) - - if index == 1: - produced_code[produced_code_index] = ReturnCode.WRITER_NOT_ALIVE - elif index == 0: - # Step 6: Check if the reader receives the samples - log_message(f'Subscriber {subscriber_index}: Receiving ' - 'samples', verbosity) - index = child_sub.expect( - [ - '\[[0-9]+\]', # index = 0 - 'on_requested_deadline_missed()', # index = 1 - pexpect.TIMEOUT # index = 2 - ], - timeout - ) + elif index == 2: + produced_code[produced_code_index] = ReturnCode.DEADLINE_MISSED + elif index == 3: + produced_code[produced_code_index] = ReturnCode.DATA_NOT_RECEIVED + elif index == 0: + # Step 5: Receiving samples + log_message(f'Subscriber {subscriber_index}: Receiving samples', + verbosity) - if index == 1: - produced_code[produced_code_index] = ReturnCode.DEADLINE_MISSED - elif index == 2: - produced_code[produced_code_index] = ReturnCode.DATA_NOT_RECEIVED - elif index == 0: - # this is used to check how the samples are arriving - # to the Subscriber. By default it does not check - # anything and returns ReturnCode.OK. - produced_code[produced_code_index] = check_function( - child_sub, - samples_sent, - timeout) + # this is used to check how the samples are arriving + # to the Subscriber. By default it does not check + # anything and returns ReturnCode.OK. + produced_code[produced_code_index] = check_function( + child_sub, samples_sent, timeout) subscriber_finished.set() # set subscriber as finished log_message(f'Subscriber {subscriber_index}: Waiting for Publishers to ' @@ -316,13 +276,12 @@ def run_publisher_shape_main( elif index == 0: # In the case that the option -w is selected, the Publisher # saves the samples sent in order, so the Subscriber can check - # them. In this way, the script can check the functionality of - # reliability (all the samples are received and in the same - # order). + # them. In this way, the script can check some functionality + # such as reliability. # In the case that the option -w is not selected, the Publisher # will only save the ReturnCode OK. if '-w' in parameters: - #Step 5: Check if the writer sends the samples + # Step 5: Check whether the writer sends the samples index = child_pub.expect([ '\[[0-9]+\]', # index = 0 'on_offered_deadline_missed()', # index = 1 diff --git a/rtps_test_utilities.py b/rtps_test_utilities.py index 99d1f3c..f432db6 100644 --- a/rtps_test_utilities.py +++ b/rtps_test_utilities.py @@ -19,8 +19,6 @@ class ReturnCode(Enum): FILTER_NOT_CREATED : Subscriber does not create the content filter INCOMPATIBLE_QOS : Publisher/Subscriber with incompatible QoS. READER_NOT_MATCHED : Publisher does not find any compatible Data Reader - WRITER_NOT_MATCHED : Subscriber does not find any compatible Data Writer - WRITER_NOT_ALIVE : Subscriber does not find any live Data Writer DATA_NOT_RECEIVED : Subscriber does not receive the data DATA_NOT_SENT : Publisher does not send the data DATA_NOT_CORRECT : Subscriber does not find the data expected @@ -35,8 +33,6 @@ class ReturnCode(Enum): FILTER_NOT_CREATED = 4 INCOMPATIBLE_QOS = 5 READER_NOT_MATCHED = 6 - WRITER_NOT_MATCHED = 7 - WRITER_NOT_ALIVE = 8 DATA_NOT_RECEIVED = 9 DATA_NOT_SENT = 10 DATA_NOT_CORRECT = 11 diff --git a/test_suite.py b/test_suite.py index 5c6c532..7dbbc98 100644 --- a/test_suite.py +++ b/test_suite.py @@ -338,8 +338,8 @@ def test_deadline_missed(child_sub, samples_sent, timeout): # DOMAIN 'Test_Domain_0' : [['-P -t Square', '-S -t Square'], [ReturnCode.OK, ReturnCode.OK]], - 'Test_Domain_1' : [['-P -t Square', '-S -t Square -d 1'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.WRITER_NOT_MATCHED]], - 'Test_Domain_2' : [['-P -t Square -d 1', '-S -t Square'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.WRITER_NOT_MATCHED]], + 'Test_Domain_1' : [['-P -t Square', '-S -t Square -d 1'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.DATA_NOT_RECEIVED]], + 'Test_Domain_2' : [['-P -t Square -d 1', '-S -t Square'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.DATA_NOT_RECEIVED]], 'Test_Domain_3' : [['-P -t Square -d 1', '-S -t Square -d 1'], [ReturnCode.OK, ReturnCode.OK]], # RELIABILITY @@ -364,8 +364,8 @@ def test_deadline_missed(child_sub, samples_sent, timeout): # TOPIC 'Test_Topic_0' : [['-P -t Square', '-S -t Square'], [ReturnCode.OK, ReturnCode.OK]], - 'Test_Topic_1' : [['-P -t Square', '-S -t Circle'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.WRITER_NOT_MATCHED]], - 'Test_Topic_2' : [['-P -t Circle', '-S -t Square'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.WRITER_NOT_MATCHED]], + 'Test_Topic_1' : [['-P -t Square', '-S -t Circle'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.DATA_NOT_RECEIVED]], + 'Test_Topic_2' : [['-P -t Circle', '-S -t Square'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.DATA_NOT_RECEIVED]], 'Test_Topic_3' : [['-P -t Circle', '-S -t Circle'], [ReturnCode.OK, ReturnCode.OK]], # COLOR @@ -381,8 +381,8 @@ def test_deadline_missed(child_sub, samples_sent, timeout): # PARTITION 'Test_Partition_0' : [['-P -t Square -p "p1"', '-S -t Square -p "p1"'], [ReturnCode.OK, ReturnCode.OK]], - 'Test_Partition_1' : [['-P -t Square -p "p1"', '-S -t Square -p "p2"'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.WRITER_NOT_MATCHED]], - 'Test_Partition_2' : [['-P -t Square -p "p2"', '-S -t Square -p "p1"'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.WRITER_NOT_MATCHED]], + 'Test_Partition_1' : [['-P -t Square -p "p1"', '-S -t Square -p "p2"'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.DATA_NOT_RECEIVED]], + 'Test_Partition_2' : [['-P -t Square -p "p2"', '-S -t Square -p "p1"'], [ReturnCode.READER_NOT_MATCHED, ReturnCode.DATA_NOT_RECEIVED]], # DURABILITY 'Test_Durability_0' : [['-P -t Square -D v', '-S -t Square -D v'], [ReturnCode.OK, ReturnCode.OK]],