Skip to content

Commit

Permalink
Add test for concurrent client calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz committed Jan 26, 2018
1 parent c37e447 commit f60ec40
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rclpy/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ def test_wait_for_service_exists(self):
self.node.destroy_client(cli)
self.node.destroy_service(srv)

def test_concurrent_calls_to_service(self):
cli = self.node.create_client(GetParameters, 'get/parameters')
srv = self.node.create_service(
GetParameters, 'get/parameters',
lambda request, response: response)
try:
self.assertTrue(cli.wait_for_service(timeout_sec=20))
future1 = cli.call_async(GetParameters.Request())
future2 = cli.call_async(GetParameters.Request())
rclpy.spin_until_future_complete(self.node, future1)
rclpy.spin_until_future_complete(self.node, future2)
self.assertTrue(future1.result() is not None)
self.assertTrue(future2.result() is not None)
finally:
self.node.destroy_client(cli)
self.node.destroy_service(srv)


if __name__ == '__main__':
unittest.main()

0 comments on commit f60ec40

Please sign in to comment.