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.
This commit is contained in:
Max Romanov
2021-07-01 16:22:08 +03:00
parent 830729a6c5
commit 210c8bbd81

View File

@@ -44,10 +44,15 @@ class TestRespawn(TestApplicationPython):
return re.findall(str(ppid) + r'.*' + name, ps_output) return re.findall(str(ppid) + r'.*' + name, ps_output)
def smoke_test(self, unit_pid): def smoke_test(self, unit_pid):
for _ in range(5): for _ in range(10):
assert 'success' in self.conf( r = self.conf('1', 'applications/' + self.app_name + '/processes')
'1', 'applications/' + self.app_name + '/processes'
) if 'success' in r:
break
time.sleep(0.1)
assert 'success' in r
assert self.get()['status'] == 200 assert self.get()['status'] == 200
# Check if the only one router, controller, # Check if the only one router, controller,