Skip to content

Commit 7612489

Browse files
Ginakiraqinglongwang
authored andcommitted
Add a number_of_subscribers option to the latency testing Python launcher
Signed-off-by: qinglongwang <[email protected]>
1 parent 0e7204f commit 7612489

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

test/performance/latency/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ The python scripts offers several options:
166166
| --reliability | Set the Reliability QoS of the DDS entities to reliable. Default Reliability is best-effort |
167167
| --data_loans | Enable the use of the loan sample API. Default is disable |
168168
| --shared_memory [on/off] | Explicitly enable/disable shared memory transport. Fast DDS default is *on* |
169+
| --data_sharing [on/off] | Explicitly enable/disable data sharing. Fast DDS default is *AUTO* |
169170
| --interprocess | Publisher and subscriber in separate processes. Default is both in the sample process and using intraprocess communications |
171+
| --number_of_subscribers \<number> | Number of subscribers in the interprocess mode test. Default is *1 subscriber* |
170172
| --security | Enable security. Default disable |
171-
| -n \<number> | Number of samples sent in the test. Default is *10000 samples*
173+
| -n \<number> | Number of samples sent in the test. Default is *10000 samples* |
172174
| -f \<file> | A file containing the demands |
175+
| -x \<file> | A file containing the Fast DDS XML configuration |

test/performance/latency/latency_tests.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@
8080
choices=['on', 'off'],
8181
help='Explicitly enable/disable shared memory transport. (Defaults: Fast DDS default settings)',
8282
required=False
83-
)
83+
)
84+
parser.add_argument(
85+
'--number_of_subscribers',
86+
help='Number of subscribers',
87+
required=False,
88+
default='1',
89+
)
8490

8591
# Parse arguments
8692
args = parser.parse_args()
@@ -103,6 +109,17 @@
103109
)
104110
exit(1) # Exit with error
105111

112+
# Check that subscribers is positive
113+
if str.isdigit(args.number_of_subscribers) and int(args.number_of_subscribers) > 0:
114+
number_of_subscribers = str(args.number_of_subscribers)
115+
else:
116+
print(
117+
'"number_of_subscribers" must be a positive integer, NOT {}'.format(
118+
args.number_of_subscribers
119+
)
120+
)
121+
exit(1) # Exit with error
122+
106123
# Demands files options
107124
demands_options = []
108125
if args.demands_file:
@@ -199,6 +216,8 @@
199216
'publisher',
200217
'--samples',
201218
samples,
219+
'--subscribers',
220+
number_of_subscribers,
202221
'--export_raw_data',
203222
]
204223
# Base of test command for subscriber agent
@@ -246,14 +265,17 @@
246265

247266
# Spawn processes
248267
publisher = subprocess.Popen(pub_command)
249-
subscriber = subprocess.Popen(sub_command)
268+
subscribers = []
269+
for _ in range(int(number_of_subscribers)):
270+
subscribers.append(subprocess.Popen(sub_command))
250271
# Wait until finish
251-
subscriber.communicate()
252-
publisher.communicate()
272+
for subscriber in subscribers:
273+
subscriber.communicate()
274+
if subscriber.returncode != 0:
275+
exit(subscriber.returncode)
253276

254-
if subscriber.returncode != 0:
255-
exit(subscriber.returncode)
256-
elif publisher.returncode != 0:
277+
publisher.communicate()
278+
if publisher.returncode != 0:
257279
exit(publisher.returncode)
258280
else:
259281
# Base of test command to execute

0 commit comments

Comments
 (0)