New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test to verify if all homu builders are listed in the buildbot config #571
Merged
+71
−0
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| @@ -0,0 +1,30 @@ | ||
| from __future__ import print_function | ||
|
|
||
| import imp | ||
| import json | ||
| import os.path | ||
| import sys | ||
|
|
||
| BUILDBOT_MASTER_PATH = '/home/servo/buildbot/master/' | ||
|
|
||
|
|
||
| def main(): | ||
| sys.path.append(BUILDBOT_MASTER_PATH) | ||
|
|
||
| config = imp.load_source( | ||
| 'config', | ||
| os.path.join(BUILDBOT_MASTER_PATH, 'master.cfg') | ||
| ) | ||
|
|
||
| for sched in config.c['schedulers']: | ||
| if sched.name == 'servo-auto': | ||
| out = {'builders': sched.builderNames} | ||
| print(json.dumps(out)) | ||
|
||
| return 0 | ||
|
|
||
| print('error: "servo-auto" scheduler not found', file=sys.stderr) | ||
| return 1 | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(main()) | ||
| @@ -0,0 +1,41 @@ | ||
| import json | ||
| import os.path | ||
| import subprocess | ||
| import toml | ||
|
|
||
| from tests.util import Failure, Success | ||
|
|
||
|
|
||
| def run(): | ||
| homu_cfg = toml.load('/home/servo/homu/cfg.toml') | ||
| homu_builders = homu_cfg['repo']['servo']['buildbot'] | ||
|
|
||
| # We need to invoke a new process to read the Buildbot master config | ||
| # because Buildbot is written in python2. | ||
| scriptpath = os.path.join(os.path.dirname(__file__), 'get_buildbot_cfg.py') | ||
| ret = subprocess.run( | ||
| ['/usr/bin/python2', scriptpath], | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.PIPE | ||
| ) | ||
| if ret.returncode != 0: | ||
| return Failure( | ||
| 'Unable to retrieve buildbot builders:', ret.stderr | ||
| ) | ||
|
|
||
| buildbot_builders = json.loads(ret.stdout.decode('utf-8'))['builders'] | ||
|
|
||
| failure_msg = '' | ||
| for builder_set in ['builders', 'try_builders']: | ||
| diff = set(homu_builders[builder_set]) - set(buildbot_builders) | ||
| if diff: | ||
| failure_msg += 'Invalid builders for "{}": {}\n' \ | ||
| .format(builder_set, diff) | ||
|
|
||
| if failure_msg: | ||
| return Failure( | ||
| "Homu config isn't synced with Buildbot config:", | ||
| failure_msg | ||
| ) | ||
|
|
||
| return Success('Buildbot and homu configs are synced') |
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Add a
return 0after printing to indicate success and exit early. After the loop (meaningservo-autowas not found, print an error message to sys.stderr (e.g.error: 'servo-auto' scheduler not found) and add areturn 1`.