cbuildbot: Set explicit quota account for paygen tests
BUG=chromium:1091878
TEST=./run_pytest cbuildbot/commands_unittest.py
Change-Id: I2b401b494bae865dabee543e5c8969b78e730b06
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2255332
Commit-Queue: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
diff --git a/cbuildbot/commands.py b/cbuildbot/commands.py
index bf19534..0442b4c 100644
--- a/cbuildbot/commands.py
+++ b/cbuildbot/commands.py
@@ -1321,6 +1321,7 @@
build=None,
legacy_suite=None,
pool=None,
+ quota_account=None,
board=None,
model=None,
timeout_mins=120,
@@ -1334,6 +1335,8 @@
legacy_suite: A string suite name, if non-empty it overrides the test plan
on the autotest backend.
pool: A string pool to run the test on.
+ quota_account: A string quota account to be used for Skylab tasks created by
+ the cros_test_platform build triggered for this test plan.
board: A string board to run the test on.
model: A string model to run the test on.
timeout_mins: An integer to indicate the test's timeout.
@@ -1355,6 +1358,9 @@
if pool:
args += ['-pool', pool]
+ if quota_account:
+ args += ['-qs-account', quota_account]
+
if board:
args += ['-board', board]
diff --git a/cbuildbot/commands_unittest.py b/cbuildbot/commands_unittest.py
index 06bea33..01cdf91 100644
--- a/cbuildbot/commands_unittest.py
+++ b/cbuildbot/commands_unittest.py
@@ -340,13 +340,14 @@
self.assertTrue(isinstance(error, failures_lib.TestFailure))
self.assertIn('Suite failed', str(error))
- def testCreateTest(self):
+ def testCreateTestPlan(self):
"""Test that function call args are mapped correctly to commandline args."""
test_plan = '{}'
build = 'foo-bar/R1234'
board = 'foo-board'
model = 'foo-model'
pool = 'foo-pool'
+ quota_account = 'foo-qa'
suite = 'foo-suite'
# An OrderedDict is used to make the keyval order on the command line
# deterministic for testing purposes.
@@ -360,6 +361,7 @@
'-image', build,
'-legacy-suite', suite,
'-pool', pool,
+ '-qs-account', quota_account,
'-board', board,
'-model', model,
'-timeout-mins', str(timeout_mins),
@@ -372,7 +374,8 @@
create_cmd, output=self._fakeCreateJson(task_id, 'foo://foo'))
result = commands.RunSkylabHWTestPlan(
- test_plan=test_plan, build=build, pool=pool, board=board, model=model,
+ test_plan=test_plan, build=build, pool=pool,
+ quota_account=quota_account, board=board, model=model,
timeout_mins=timeout_mins, keyvals=keyvals, legacy_suite=suite)
self.assertTrue(isinstance(result, commands.HWTestSuiteResult))
self.assertEqual(result.to_raise, None)
diff --git a/lib/paygen/paygen_build_lib.py b/lib/paygen/paygen_build_lib.py
index 5fa489d..e6272f1 100644
--- a/lib/paygen/paygen_build_lib.py
+++ b/lib/paygen/paygen_build_lib.py
@@ -28,6 +28,7 @@
from chromite.cbuildbot import commands
from chromite.lib import config_lib
from chromite.lib import failures_lib
+from chromite.lib import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import gs
@@ -388,6 +389,7 @@
# Hidden class level cache value.
_cachedPaygenJson = None
+ # pylint: disable=unsubscriptable-object
@classmethod
def GetPaygenJson(cls, board=None, channel=None):
"""Fetch the parsed Golden Eye payload generation configuration.
@@ -1163,7 +1165,6 @@
raise BoardNotConfigured(board)
-# pylint: disable=unused-argument
def ScheduleAutotestTests(suite_name, board, model, build, skip_duts_check,
debug, payload_test_configs, test_env,
job_keyvals=None):
@@ -1199,7 +1200,8 @@
test_plan=test_plan,
build=build,
legacy_suite=suite_name,
- pool='DUT_POOL_BVT',
+ pool=constants.HWTEST_QUOTA_POOL,
+ quota_account=constants.HWTEST_QUOTA_ACCOUNT_BVT,
board=board,
model=model,
timeout_mins=timeout_mins,
diff --git a/lib/paygen/paygen_build_lib_unittest.py b/lib/paygen/paygen_build_lib_unittest.py
index 1c25fc3..3ed2035 100644
--- a/lib/paygen/paygen_build_lib_unittest.py
+++ b/lib/paygen/paygen_build_lib_unittest.py
@@ -1339,40 +1339,6 @@
class HWTest(cros_test_lib.MockTestCase):
"""Test HW test invocation."""
- def testScheduleAutotestTests(self):
- run_test_mock = self.PatchObject(
- commands,
- 'RunSkylabHWTestPlan',
- return_value=commands.HWTestSuiteResult(None, None))
-
- paygen_build_lib.ScheduleAutotestTests(
- suite_name='dummy-suite',
- board='dummy-board',
- model='dummy-model',
- build='dummy-build',
- skip_duts_check=None, # ignored
- debug=None, # ignored
- payload_test_configs=[],
- test_env=None, # ignored
- job_keyvals=None) # ignored
-
- run_test_mock.assert_called_once_with(
- test_plan=paygen_build_lib._TestPlan(
- payload_test_configs=[],
- suite_name='dummy-suite',
- build='dummy-build'),
- build='dummy-build',
- legacy_suite='dummy-suite',
- pool='DUT_POOL_BVT',
- board='dummy-board',
- model='dummy-model',
- timeout_mins=2*3*60,
- tags=['build:dummy-build',
- 'suite:dummy-suite',
- 'user:PaygenTestStage'],
- keyvals={'build': 'dummy-build',
- 'suite': 'dummy-suite'})
-
def testTestPlan(self):
payload_test_configs = [
test_params.TestConfig(