Commit 05fb9c17 authored by Xinan Lin's avatar Xinan Lin Committed by Chromium LUCI CQ

Support generating skylab test conf from source side

BUG=1142103
TEST=./generate_buildbot_json_coveragetest.py

Change-Id: If3966a93e875c775b15da2c30b11309b5b5b39e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586272Reviewed-by: default avatarStephen Martinis <martiniss@chromium.org>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837825}
parent ded541f9
......@@ -172,6 +172,25 @@ class JUnitGenerator(BaseGenerator):
return sorted(tests, key=lambda x: x['test'])
class SkylabGenerator(BaseGenerator):
def __init__(self, bb_gen):
super(SkylabGenerator, self).__init__(bb_gen)
def generate(self, waterfall, tester_name, tester_config, input_tests):
scripts = []
for test_name, test_config in sorted(input_tests.iteritems()):
for config in test_config:
test = self.bb_gen.generate_skylab_test(waterfall, tester_name,
tester_config, test_name,
config)
if test:
scripts.append(test)
return scripts
def sort(self, tests):
return sorted(tests, key=lambda x: x['test'])
def check_compound_references(other_test_suites=None,
sub_suite=None,
suite=None,
......@@ -821,6 +840,21 @@ class BBJSONGenerator(object):
self.substitute_magic_args(result)
return result
def generate_skylab_test(self, waterfall, tester_name, tester_config,
test_name, test_config):
if not self.should_run_on_tester(waterfall, tester_name, test_name,
test_config):
return None
result = copy.deepcopy(test_config)
result.update({
'test': test_name,
})
self.initialize_args_for_test(result, tester_config)
result = self.update_and_cleanup_test(result, test_name, tester_name,
tester_config, waterfall)
self.substitute_magic_args(result)
return result
def substitute_gpu_args(self, tester_config, swarming_config, args):
substitutions = {
# Any machine in waterfalls.pyl which desires to run GPU tests
......@@ -918,6 +952,8 @@ class BBJSONGenerator(object):
JUnitGenerator(self),
'scripts':
ScriptGenerator(self),
'skylab_tests':
SkylabGenerator(self),
}
def get_test_type_remapper(self):
......@@ -1078,6 +1114,12 @@ class BBJSONGenerator(object):
basic_swarming_def.update(variant_swarming_def)
cloned_config['swarming'] = basic_swarming_def
# Copy all skylab fields defined by the variant.
skylab_config = cloned_variant.get('skylab')
if skylab_config:
for k, v in skylab_config.items():
cloned_config[k] = v
# The identifier is used to make the name of the test unique.
# Generators in the recipe uniquely identify a test by it's name, so we
# don't want to have the same name for each variant.
......
......@@ -712,7 +712,6 @@ FOO_TEST_SUITE_WITH_REMOVE_BUILDER_MIXIN = """\
}
"""
FOO_SCRIPT_SUITE = """\
{
'basic_suites': {
......@@ -5508,6 +5507,109 @@ MATRIX_COMPOUND_VARIANTS_REF_OUTPUT = """\
}
"""
EMPTY_SKYLAB_TEST_EXCEPTIONS = """\
{
'tast.foo_OCTOPUS_TOT': {
'remove_from': [
'Fake Tester',
]
},
'tast.foo_OCTOPUS_TOT-1': {
'remove_from': [
'Fake Tester',
]
}
}
"""
MATRIX_SKYLAB_WATERFALL = """\
[
{
'project': 'chromium',
'bucket': 'ci',
'name': 'chromium.test',
'machines': {
'Fake Tester': {
'test_suites': {
'skylab_tests': 'cros_skylab_basic_x86',
},
},
},
},
]
"""
MATRIX_COMPOUND_SKYLAB_REF = """\
{
'basic_suites': {
'cros_skylab_basic': {
'tast.basic': {
'suite': 'tast.basic',
'timeout': 3600,
},
'tast.foo': {
'suite': 'tast.foo',
'timeout': 3600,
},
},
},
'compound_suites': {},
'matrix_compound_suites': {
'cros_skylab_basic_x86': {
'cros_skylab_basic': {
'variants': [
{
'skylab': {
'cros_board': 'octopus',
'cros_img': 'octopus-release/R89-13655.0.0',
},
'identifier': 'OCTOPUS_TOT',
},
{
'skylab': {
'cros_board': 'octopus',
'cros_img': 'octopus-release/R88-13597.23.0',
},
'identifier': 'OCTOPUS_TOT-1',
},
]
},
},
},
}
"""
VARIATION_SKYLAB_OUTPUT = """\
{
"AAAAA1 AUTOGENERATED FILE DO NOT EDIT": {},
"AAAAA2 See generate_buildbot_json.py to make changes": {},
"Fake Tester": {
"skylab_tests": [
{
"args": [],
"cros_board": "octopus",
"cros_img": "octopus-release/R89-13655.0.0",
"name": "tast.basic_OCTOPUS_TOT",
"suite": "tast.basic",
"swarming": {},
"test": "tast.basic",
"timeout": 3600
},
{
"args": [],
"cros_board": "octopus",
"cros_img": "octopus-release/R88-13597.23.0",
"name": "tast.basic_OCTOPUS_TOT-1",
"suite": "tast.basic",
"swarming": {},
"test": "tast.basic",
"timeout": 3600
}
]
}
}
"""
class MatrixCompositionTests(TestCase):
......@@ -5682,6 +5784,18 @@ class MatrixCompositionTests(TestCase):
'The following variants were unreferenced *'):
fbb.check_input_file_consistency(verbose=True)
def test_good_skylab_matrix_with_variants(self):
fbb = FakeBBGen(self.args,
MATRIX_SKYLAB_WATERFALL,
MATRIX_COMPOUND_SKYLAB_REF,
LUCI_MILO_CFG,
exceptions=EMPTY_SKYLAB_TEST_EXCEPTIONS)
self.create_testing_buildbot_json_file('chromium.test.json',
VARIATION_SKYLAB_OUTPUT)
fbb.check_input_file_consistency(verbose=True)
fbb.check_output_file_consistency(verbose=True)
self.assertFalse(fbb.printed_lines)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment