Skip to content

Commit

Permalink
Improve failure detection and reporting in the Tests job. (#14729)
Browse files Browse the repository at this point in the history
* Fix exception formatting when a dependency of our chip-tool process
  has died.

* Detect startup crashes in the server app without having to wait for
  the entire 10-second timeout.

* Call apps_register.uninit() before sys.exit(), because otherwise on
  failure we end up sitting there waiting for an unjoined thread until
  the test job times out.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jan 12, 2024
1 parent d7c01ee commit 2373624
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/tests/chiptest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def RunSubprocess(self, cmd, name, wait=True, dependencies=[]):
for dependency in dependencies:
if dependency.poll() is not None:
s.kill()
raise Exception("Unexpected return %d for %r",
dependency.poll(), dependency)
raise Exception("Unexpected return %d for %r" %
(dependency.poll(), dependency))

code = s.wait()
if code != 0:
Expand Down
8 changes: 6 additions & 2 deletions scripts/tests/chiptest/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def start(self, discriminator):
self.process = None
process, outpipe, errpipe = self.__startServer(
self.runner, self.command, discriminator)
self.__waitForServerReady(outpipe)
self.__waitForServerReady(process, outpipe)
self.__updateSetUpCode(outpipe)
self.process = process
self.stopped = False
Expand Down Expand Up @@ -95,11 +95,15 @@ def __startServer(self, runner, command, discriminator):
app_cmd = command + ['--discriminator', str(discriminator)]
return runner.RunSubprocess(app_cmd, name='APP ', wait=False)

def __waitForServerReady(self, outpipe):
def __waitForServerReady(self, server_process, outpipe):
logging.debug('Waiting for server to listen.')
start_time = time.time()
server_is_listening = outpipe.CapturedLogContains("Server Listening")
while not server_is_listening:
if server_process.poll() is not None:
died_str = 'Server died during startup, returncode %d' % server_process.returncode
logging.error(died_str)
raise Exception(died_str)
if time.time() - start_time > 10:
raise Exception('Timeout for server listening')
time.sleep(0.1)
Expand Down
1 change: 1 addition & 0 deletions scripts/tests/run_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def cmd_run(context, iterations, all_clusters_app, tv_app):
test_end = time.time()
logging.exception('%s - FAILED in %0.2f seconds' %
(test.name, (test_end - test_start)))
apps_register.uninit()
sys.exit(2)

apps_register.uninit()
Expand Down

0 comments on commit 2373624

Please sign in to comment.