| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import base64 | 5 import base64 |
| 6 import zlib | 6 import zlib |
| 7 | 7 |
| 8 from common import cros_chromite | |
| 9 | 8 |
| 10 DEPS = [ | 9 DEPS = [ |
| 11 'chromite', | 10 'chromite', |
| 12 'gitiles', | 11 'gitiles', |
| 13 'json', | 12 'json', |
| 14 'properties', | 13 'properties', |
| 15 ] | 14 ] |
| 16 | 15 |
| 17 # Map master name to 'chromite' configuration name. | 16 # Map master name to 'chromite' configuration name. |
| 18 _MASTER_CONFIG_MAP = { | 17 _MASTER_CONFIG_MAP = { |
| 19 'chromiumos.tryserver': { | 18 'chromiumos.tryserver': { |
| 20 'master_config': 'chromiumos_tryserver', | 19 'master_config': 'chromiumos_tryserver', |
| 21 }, | 20 }, |
| 22 } | 21 } |
| 23 | 22 |
| 23 |
| 24 # Testing: Tryjob data file JSON. |
| 25 _TRYJOB_DATA = """ |
| 26 { |
| 27 "name": "12345", |
| 28 "email": "testauthor@fake.chromium.org", |
| 29 "extra_args": [ |
| 30 "--timeout", |
| 31 "14400", |
| 32 "--remote-trybot", |
| 33 "--remote-version=4" |
| 34 ] |
| 35 } |
| 36 """ |
| 37 |
| 38 # JSON string containing sufficient Chromite configuration layout for our test |
| 39 # configs. |
| 40 _CHROMITE_CONFIG = { |
| 41 '_default': { |
| 42 'type': 'undefined', |
| 43 }, |
| 44 '_templates': { |
| 45 'full': { |
| 46 'type': 'full', |
| 47 }, |
| 48 'paladin': { |
| 49 'type': 'paladin', |
| 50 }, |
| 51 }, |
| 52 'x86-generic-full': { |
| 53 '_template': 'full', |
| 54 }, |
| 55 'internal-paladin': { |
| 56 '_template': 'paladin', |
| 57 'internal': True, |
| 58 }, |
| 59 } |
| 60 |
| 61 |
| 24 def RunSteps(api): | 62 def RunSteps(api): |
| 25 # The 'cbuildbot' config name to build is the name of the builder. | 63 # The 'cbuildbot' config name to build is the name of the builder. |
| 26 # | 64 # |
| 27 # TODO(dnj): After we fully switch to BuildBucket scheduling, load the config | 65 # TODO(dnj): After we fully switch to BuildBucket scheduling, load the config |
| 28 # name from the BuildBucket job instead of `cbb_config` build | 66 # name from the BuildBucket job instead of `cbb_config` build |
| 29 # property. We can't do this yet b/c the job description can | 67 # property. We can't do this yet b/c the job description can |
| 30 # specify multiple configs in one tryjob, so there's no way for us | 68 # specify multiple configs in one tryjob, so there's no way for us |
| 31 # to know which one we are. | 69 # to know which one we are. |
| 32 cbb_config_name = api.properties.get('cbb_config') | 70 cbb_config_name = api.properties.get('cbb_config') |
| 33 assert cbb_config_name, "No configuration name specified." | 71 assert cbb_config_name, "No configuration name specified." |
| 34 | 72 |
| 35 cbb = cros_chromite.Get() | |
| 36 cbb_config = cbb.get(cbb_config_name) | |
| 37 | |
| 38 # Apply our generic configuration. | 73 # Apply our generic configuration. |
| 39 api.chromite.configure( | 74 api.chromite.configure( |
| 40 api.properties, | 75 api.properties, |
| 41 _MASTER_CONFIG_MAP) | 76 _MASTER_CONFIG_MAP) |
| 42 api.chromite.c.cbb.config = cbb_config_name | 77 api.chromite.c.cbb.config = cbb_config_name |
| 43 | 78 |
| 44 repository = api.properties.get('repository') | 79 repository = api.properties.get('repository') |
| 45 revision = api.properties.get('revision') | 80 revision = api.properties.get('revision') |
| 46 assert repository, "A repository must be specified." | 81 assert repository, "A repository must be specified." |
| 47 assert revision, "A revision must be specified." | 82 assert revision, "A revision must be specified." |
| 48 assert api.chromite.check_repository('tryjob', repository), ( | 83 assert api.chromite.check_repository('tryjob', repository), ( |
| 49 "Refusing to query unknown tryjob repository: %s" % (repository,)) | 84 "Refusing to query unknown tryjob repository: %s" % (repository,)) |
| 50 | 85 |
| 86 # Load the Chromite configuration for our target. |
| 87 api.chromite.checkout_chromite() |
| 88 cbb_config = api.chromite.load_config(cbb_config_name) |
| 89 |
| 51 # Add parameters specified in the tryjob description. | 90 # Add parameters specified in the tryjob description. |
| 52 tryjob_args = api.properties.get('cbb_extra_args', []) | 91 tryjob_args = api.properties.get('cbb_extra_args', []) |
| 53 if tryjob_args: | 92 if tryjob_args: |
| 54 if tryjob_args.startswith('z:'): | 93 if tryjob_args.startswith('z:'): |
| 55 tryjob_args = zlib.decompress(base64.b64decode(tryjob_args[2:])) | 94 tryjob_args = zlib.decompress(base64.b64decode(tryjob_args[2:])) |
| 56 tryjob_args = api.json.loads(tryjob_args) | 95 tryjob_args = api.json.loads(tryjob_args) |
| 57 | 96 |
| 58 # Determine our build directory name based on whether this build is internal | 97 # Determine our build directory name based on whether this build is internal |
| 59 # or external. | 98 # or external. |
| 60 # | 99 # |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 # executing. | 110 # executing. |
| 72 if not api.chromite.c.cbb.builddir: | 111 if not api.chromite.c.cbb.builddir: |
| 73 if cbb_config: | 112 if cbb_config: |
| 74 namebase = 'internal' if cbb_config.get('internal') else 'external' | 113 namebase = 'internal' if cbb_config.get('internal') else 'external' |
| 75 api.chromite.c.cbb.builddir = '%s_master' % (namebase,) | 114 api.chromite.c.cbb.builddir = '%s_master' % (namebase,) |
| 76 else: | 115 else: |
| 77 api.chromite.c.cbb.builddir = 'etc_master' | 116 api.chromite.c.cbb.builddir = 'etc_master' |
| 78 api.chromite.c.cbb.clobber = True | 117 api.chromite.c.cbb.clobber = True |
| 79 | 118 |
| 80 # Run our 'cbuildbot'. | 119 # Run our 'cbuildbot'. |
| 81 api.chromite.run_cbuildbot(args=tryjob_args) | 120 api.chromite.run(args=tryjob_args) |
| 82 | 121 |
| 83 | 122 |
| 84 def GenTests(api): | 123 def GenTests(api): |
| 85 # Test a CrOS tryjob. | 124 # Test a CrOS tryjob. |
| 86 yield ( | 125 yield ( |
| 87 api.test('basic') | 126 api.test('external') |
| 88 + api.properties( | 127 + api.properties( |
| 89 mastername='chromiumos.tryserver', | 128 mastername='chromiumos.tryserver', |
| 90 buildername='full', | 129 buildername='full', |
| 91 slavename='test', | 130 slavename='test', |
| 92 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 131 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
| 93 revision=api.gitiles.make_hash('test'), | 132 revision=api.gitiles.make_hash('test'), |
| 94 cbb_config='x86-generic-full', | 133 cbb_config='x86-generic-full', |
| 95 cbb_extra_args='["--timeout", "14400", "--remote-trybot",' | 134 cbb_extra_args='["--timeout", "14400", "--remote-trybot",' |
| 96 '"--remote-version=4"]', | 135 '"--remote-version=4"]', |
| 97 ) | 136 ) |
| 137 + api.chromite.seed_chromite_config(_CHROMITE_CONFIG) |
| 138 ) |
| 139 |
| 140 yield ( |
| 141 api.test('internal') |
| 142 + api.properties( |
| 143 mastername='chromiumos.tryserver', |
| 144 buildername='paladin', |
| 145 slavename='test', |
| 146 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
| 147 revision=api.gitiles.make_hash('test'), |
| 148 cbb_config='internal-paladin', |
| 149 cbb_extra_args='["--timeout", "14400", "--remote-trybot",' |
| 150 '"--remote-version=4"]', |
| 151 ) |
| 152 + api.chromite.seed_chromite_config(_CHROMITE_CONFIG) |
| 98 ) | 153 ) |
| 99 | 154 |
| 100 # Test a CrOS tryjob with compressed "cbb_extra_args". | 155 # Test a CrOS tryjob with compressed "cbb_extra_args". |
| 101 yield ( | 156 yield ( |
| 102 api.test('basic_compressed') | 157 api.test('basic_compressed') |
| 103 + api.properties( | 158 + api.properties( |
| 104 mastername='chromiumos.tryserver', | 159 mastername='chromiumos.tryserver', |
| 105 buildername='full', | 160 buildername='full', |
| 106 slavename='test', | 161 slavename='test', |
| 107 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 162 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
| 108 revision=api.gitiles.make_hash('test'), | 163 revision=api.gitiles.make_hash('test'), |
| 109 cbb_config='x86-generic-full', | 164 cbb_config='x86-generic-full', |
| 110 cbb_extra_args=( | 165 cbb_extra_args=( |
| 111 'z:eJyLVtLVLcnMTc0vLVHSUVAyNDExMAAxdHWLUnPzS1J1S4oqk/JLUITKUouKM' | 166 'z:eJyLVtLVLcnMTc0vLVHSUVAyNDExMAAxdHWLUnPzS1J1S4oqk/JLUITKUouKM' |
| 112 '/PzbE2UYgFJaBNI'), | 167 '/PzbE2UYgFJaBNI'), |
| 113 ) | 168 ) |
| 169 + api.chromite.seed_chromite_config(_CHROMITE_CONFIG) |
| 114 ) | 170 ) |
| 115 | 171 |
| 116 # Test a config that is not registered in Chromite. | 172 # Test a config that is not registered in Chromite. |
| 117 yield ( | 173 yield ( |
| 118 api.test('unknown_config') | 174 api.test('unknown_config') |
| 119 + api.properties( | 175 + api.properties( |
| 120 mastername='chromiumos.tryserver', | 176 mastername='chromiumos.tryserver', |
| 121 buildername='etc', | 177 buildername='etc', |
| 122 slavename='test', | 178 slavename='test', |
| 123 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 179 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
| 124 revision=api.gitiles.make_hash('test'), | 180 revision=api.gitiles.make_hash('test'), |
| 125 cbb_config='xxx-fakeboard-fakebuild', | 181 cbb_config='xxx-fakeboard-fakebuild', |
| 126 cbb_extra_args='["--timeout", "14400", "--remote-trybot",' | 182 cbb_extra_args='["--timeout", "14400", "--remote-trybot",' |
| 127 '"--remote-version=4"]', | 183 '"--remote-version=4"]', |
| 128 ) | 184 ) |
| 185 + api.chromite.seed_chromite_config(_CHROMITE_CONFIG) |
| 129 ) | 186 ) |
| OLD | NEW |