Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address request from #10771 - add timeouts to thread join in test #11297

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,22 @@ def run(self):
changeThread.start()
with handler.cv:
while handler.subscriptionReceived < 5:
# We should observe 10 attribute changes
handler.cv.wait()
changeThread.join()
return True
# We should observe 5 attribute changes
# The changing thread will change the value after 3 seconds. If we're waiting more than 10, assume something
# is really wrong and bail out here with some information.
if not handler.cv.wait(10.0):
self.logger.error(
f"Failed to receive subscription update")
break

# thread changes 5 times, and sleeps for 3 seconds in between. Add an additional 3 seconds of slack. Timeout is in seconds.
changeThread.join(18.0)
if changeThread.is_alive():
# Thread join timed out
self.logger.error(f"Failed to join change thread")
return False
return True if handler.subscriptionReceived == 5 else False

except Exception as ex:
self.logger.exception(f"Failed to finish API test: {ex}")
return False
Expand Down