twister: count retries after failures or errors

When twister is set to retry any failures, count the number of retries
and record the number in the json file. This will help us identify
unstable tests or tests requiring attention.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2022-10-24 13:34:48 -04:00
commit b89a3d955a
4 changed files with 7 additions and 0 deletions

View file

@ -267,6 +267,8 @@ class Reporting:
if rom_size: if rom_size:
suite["rom_size"] = rom_size suite["rom_size"] = rom_size
suite['retries'] = instance.retries
if instance.status in ["error", "failed"]: if instance.status in ["error", "failed"]:
suite['status'] = instance.status suite['status'] = instance.status
suite["reason"] = instance.reason suite["reason"] = instance.reason

View file

@ -972,6 +972,9 @@ class TwisterRunner:
if instance.status not in no_retry_statuses: if instance.status not in no_retry_statuses:
logger.debug(f"adding {instance.name}") logger.debug(f"adding {instance.name}")
if instance.status:
instance.retries += 1
instance.status = None instance.status = None
if test_only and instance.run: if test_only and instance.run:
pipeline.put({"op": "run", "test": instance}) pipeline.put({"op": "run", "test": instance})

View file

@ -40,6 +40,7 @@ class TestInstance:
self.handler = None self.handler = None
self.outdir = outdir self.outdir = outdir
self.execution_time = 0 self.execution_time = 0
self.retries = 0
self.name = os.path.join(platform.name, testsuite.name) self.name = os.path.join(platform.name, testsuite.name)
self.run_id = self._get_run_id() self.run_id = self._get_run_id()

View file

@ -524,6 +524,7 @@ class TestPlan:
if status in ["error", "failed"]: if status in ["error", "failed"]:
instance.status = None instance.status = None
instance.reason = None instance.reason = None
instance.retries += 1
# test marked as passed (built only) but can run when # test marked as passed (built only) but can run when
# --test-only is used. Reset status to capture new results. # --test-only is used. Reset status to capture new results.
elif status == 'passed' and instance.run and self.options.test_only: elif status == 'passed' and instance.run and self.options.test_only: