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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user