Add skip_duts_check option in run_suite
Add skip_duts_check option in args for run_suite.py. If skip_duts_check is
True, run_suite will skip checking minimum available DUTs; else, enforce
the minimum_duts checking. Will make changes in chromite/cbuildbot to
pass in skip_duts_check value. If users choose to run hwtest without
checking minimum DUTs, they need to add --skip_duts_check in the trybot
options; otherwise, run_suite will check DUTs and throw
NotEnoughDutsError when current available DUTs cannot satisfy
minimum_duts requirement.
BUG=chromium:403232
TEST=run_suite_unittest;diagnosis_utils_unittest
CQ-DEPEND=CL:338899
Change-Id: Ie2d286534d99ca613f9cc32b65369ebc2c39a2df
Reviewed-on: https://chromium-review.googlesource.com/338926
Commit-Ready: Ningning Xia <[email protected]>
Tested-by: Ningning Xia <[email protected]>
Reviewed-by: Chris Sosa <[email protected]>
Reviewed-by: Aviv Keshet <[email protected]>
diff --git a/site_utils/diagnosis_utils.py b/site_utils/diagnosis_utils.py
index 3bb3917..bc8a97e 100644
--- a/site_utils/diagnosis_utils.py
+++ b/site_utils/diagnosis_utils.py
@@ -198,7 +198,7 @@
job_info)
- def check_dut_availability(self, board, pool, minimum_duts=0):
+ def check_dut_availability(self, board, pool, minimum_duts=0, skip_duts_check=False):
"""Check if DUT availability for a given board and pool is less than
minimum.
@@ -208,6 +208,7 @@
run the suite. Default is set to 0, which means do
not force the check of available machines before
running the suite.
+ @param skip_duts_check: If True, skip minimum available DUTs check.
@raise: NotEnoughDutsError if DUT availability is lower than minimum.
@raise: BoardNotAvailableError if no host found for requested
board/pool.
@@ -224,13 +225,21 @@
'currently does not cover test for this board and pool.'%
(board, pool))
+ if skip_duts_check:
+ # Bypass minimum avilable DUTs check
+ logging.debug('skip_duts_check is on, do not enforce minimum DUTs check.')
+ return
+
if len(hosts) < minimum_duts:
logging.debug('The total number of DUTs for %s in pool:%s is %d, '
'which is no more than the required minimum number of'
- ' available DUTS of %d. Minimum available DUT rule is'
- ' not enforced.', board, pool, len(hosts),
+ ' available DUTS of %d.', board, pool, len(hosts),
minimum_duts)
- return
+
+ # skip_duts_check is off, enfore checking dut availability
+ raise NotEnoughDutsError('skip_duts_check option is on and total number DUTs '
+ 'in the pool is less than the required '
+ 'minimum avaialble DUTs.')
# TODO(dshi): Replace the hard coded string with enum value,
# models.Host.Status.REPAIRING and REPAIR_FAILED