Skip to content

Commit

Permalink
Simplified the detection of read data in the subscriber app (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelrti authored Mar 7, 2024
1 parent 7eb857a commit 63c52ab
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 84 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:

Expand All @@ -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.
Expand Down
81 changes: 20 additions & 61 deletions interoperability_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions rtps_test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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]],
Expand Down

0 comments on commit 63c52ab

Please sign in to comment.