diff options
author | Max Romanov <max.romanov@nginx.com> | 2021-07-01 16:22:08 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2021-07-01 16:22:08 +0300 |
commit | 210c8bbd81a8836bffee221215effa00018868cd (patch) | |
tree | d2166093c42c6723387fbff4021dcee4a7e6a04c | |
parent | 830729a6c5a59615d611575c22516b0fb9dcab3d (diff) | |
download | unit-210c8bbd81a8836bffee221215effa00018868cd.tar.gz unit-210c8bbd81a8836bffee221215effa00018868cd.tar.bz2 |
Tests: fixing racing condition in respawn tests.
A race may occur between the router process restart and the main process
sending a notification to the running controller. For example, a test script
detects the new process and starts performing a smoke test, but the controller
has not yet received the 'remove PID' notification, so the connection to the
router is broken and any attempt to update the configuration will cause an
error.
The solution is to perform several attempts to reconfigure Unit with a short
delay between failures.
-rw-r--r-- | test/test_respawn.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/test/test_respawn.py b/test/test_respawn.py index edbfa2a8..5a5d6126 100644 --- a/test/test_respawn.py +++ b/test/test_respawn.py @@ -44,11 +44,16 @@ class TestRespawn(TestApplicationPython): return re.findall(str(ppid) + r'.*' + name, ps_output) def smoke_test(self, unit_pid): - for _ in range(5): - assert 'success' in self.conf( - '1', 'applications/' + self.app_name + '/processes' - ) - assert self.get()['status'] == 200 + for _ in range(10): + r = self.conf('1', 'applications/' + self.app_name + '/processes') + + if 'success' in r: + break + + time.sleep(0.1) + + assert 'success' in r + assert self.get()['status'] == 200 # Check if the only one router, controller, # and application processes running. |