Skip to content
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 check Buildbot master config #307

Merged
merged 3 commits into from Apr 7, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -20,6 +20,8 @@ matrix:
os: linux
sudo: required
dist: trusty
language: python
python: 3.5
- env: SALT_NODE_ID=test # Not a Salt node, runs test suite instead
os: linux
sudo: required
@@ -20,4 +20,9 @@ else
sudo salt-call --id="${SALT_NODE_ID}" --retcode-passthrough state.show_highstate
# Full on installation test
sudo salt-call --id="${SALT_NODE_ID}" --retcode-passthrough --log-level=warning state.highstate

# TODO: don't hard-code this
if [ "${SALT_NODE_ID}" = "servo-master1" ]; then
./test.py sls.buildbot.master
fi
fi

This file was deleted.

This file was deleted.

@@ -1,10 +1,10 @@
exec /usr/local/bin/github_buildbot.py -p 9010 -m localhost:9001 --auth=change:{{ pillar['buildbot']['credentials']['change-pass'] }} --secret={{ pillar['buildbot']['credentials']['gh-hook-secret'] }} -l /home/servo/buildbot/master/github-listener.log
exec /usr/local/bin/github_buildbot.py -p 9010 -m localhost:9001 --auth=change:{{ pillar['buildbot']['credentials']['change-pass'] }} --secret={{ pillar['buildbot']['credentials']['gh-hook-secret'] }} -l {{ common.servo_home }}/buildbot/master/github-listener.log

setuid servo
setgid servo

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]

env HOME=/home/servo
env HOME={{ common.servo_home }}

@@ -0,0 +1,10 @@
exec /usr/local/bin/buildbot start --nodaemon {{ common.servo_home }}/buildbot/master

setuid servo
setgid servo

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]

env HOME={{ common.servo_home }}

@@ -3,7 +3,7 @@ import os
from twisted.application import service
from buildbot.master import BuildMaster

basedir = '/home/servo/buildbot/master'
basedir = '{{ common.servo_home }}/buildbot/master'
rotateLength = 10000000
maxRotatedFiles = 10
configfile = 'master.cfg'
@@ -97,9 +97,9 @@ linux_test_env = dict({
linux_headless_env = dict({'SERVO_HEADLESS': '1'}, **linux_test_env)

mac_test_env = dict({
'CARGO_HOME': '/Users/servo/.cargo',
'CARGO_HOME': '{{ common.servo_home }}/.cargo',
'CCACHE': '/usr/local/bin/ccache',
'SERVO_CACHE_DIR': '/Users/servo/.servo'
'SERVO_CACHE_DIR': '{{ common.servo_home }}/.servo'
}, **common_test_env)

linux_dev_factory = create_servo_factory([
File renamed without changes.
File renamed without changes.
@@ -11,14 +11,16 @@ buildbot-master:
- pkg: pip
service.running:
- enable: True
- watch:
# Buildbot must be restarted manually! See 'Buildbot administration' on the
# wiki and https://github.com/servo/saltfs/issues/304.
- require:
- pip: buildbot-master
- file: /home/servo/buildbot/master
- file: {{ common.servo_home }}/buildbot/master
- file: /etc/init/buildbot-master.conf
/home/servo/buildbot/master:
{{ common.servo_home }}/buildbot/master:
file.recurse:
- source: salt://buildbot/master
- source: salt://{{ tpldir }}/files/config
- user: servo
- group: servo
- dir_mode: 755
@@ -29,25 +31,30 @@ buildbot-master:
/etc/init/buildbot-master.conf:
file.managed:
- source: salt://buildbot/buildbot-master.conf
- source: salt://{{ tpldir }}/files/buildbot-master.conf
- user: root
- group: root
- mode: 644
- template: jinja
- context:
common: {{ common }}
/usr/local/bin/github_buildbot.py:
file.managed:
- source: salt://buildbot/github_buildbot.py
- source: salt://{{ tpldir }}/files/github_buildbot.py
- user: root
- group: root
- mode: 755
/etc/init/buildbot-github-listener.conf:
file.managed:
- source: salt://buildbot/buildbot-github-listener.conf
- template: jinja
- source: salt://{{ tpldir }}/files/buildbot-github-listener.conf
- user: root
- group: root
- mode: 644
- template: jinja
- context:
common: {{ common }}
buildbot-github-listener:
service.running:
@@ -58,7 +65,7 @@ buildbot-github-listener:
remove-old-build-logs:
cron.present:
- name: 'find /home/servo/buildbot/master/*/*.bz2 -mtime +5 -delete'
- name: 'find {{ common.servo_home }}/buildbot/master/*/*.bz2 -mtime +5 -delete'
- user: root
- minute: 1
- hour: 0
@@ -0,0 +1,10 @@
exec /usr/local/bin/buildslave start --nodaemon {{ common.servo_home }}/buildbot/slave

setuid servo
setgid servo

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]

env HOME={{ common.servo_home }}

@@ -4,11 +4,7 @@ import os
from buildslave.bot import BuildSlave
from twisted.application import service

{% if grains["kernel"] != "Darwin" %}
basedir = '/home/servo/buildbot/slave'
{% else %}
basedir = '/Users/servo/buildbot/slave'
{% endif %}
basedir = '{{ common.servo_home }}/buildbot/slave'
rotateLength = 10000000
maxRotatedFiles = 10

File renamed without changes.
File renamed without changes.
@@ -9,8 +9,7 @@ buildbot-slave-dependencies:
{{ common.servo_home }}/buildbot/slave:
file.recurse:
- source: salt://buildbot/slave
- template: jinja
- source: salt://{{ tpldir }}/files/config
- user: servo
{% if grains['kernel'] == 'Darwin' %}
- group: staff
@@ -19,6 +18,9 @@ buildbot-slave-dependencies:
{% endif %}
- dir_mode: 755
- file_mode: 644
- template: jinja
- context:
common: {{ common }}
{% if grains['kernel'] != 'Darwin' %}
- watch_in:
- service: buildbot-slave
@@ -28,7 +30,7 @@ buildbot-slave-dependencies:
/Library/LaunchDaemons/net.buildbot.buildslave.plist:
file.managed:
- source: salt://buildbot/net.buildbot.buildslave.plist
- source: salt://{{ tpldir }}/files/net.buildbot.buildslave.plist
- user: root
- group: wheel
- mode: 644
@@ -43,10 +45,13 @@ launchctl load -w /Library/LaunchDaemons/net.buildbot.buildslave.plist:
/etc/init/buildbot-slave.conf:
file.managed:
- source: salt://buildbot/buildbot-slave.conf
- source: salt://{{ tpldir }}/files/buildbot-slave.conf
- user: root
- group: root
- mode: 644
- template: jinja
- context:
common: {{ common }}
- watch_in:
- service: buildbot-slave
@@ -55,4 +60,3 @@ buildbot-slave:
- enable: True
{% endif %}
65 test.py
@@ -7,35 +7,48 @@
from tests.util import color, GREEN, RED, Failure, project_path


def is_python_script(path):
return path.endswith('.py')
def is_python_script(dir_entry):
return dir_entry.name.endswith('.py') and dir_entry.is_file()


def run_tests(tests):
any_failures = False

for test_spec in tests:
test_dir = os.path.join(project_path(), 'tests', *test_spec.split('.'))

python_scripts = filter(is_python_script, os.scandir(test_dir))
tests = sorted([entry.name for entry in python_scripts])

for test in tests:
test_mod_name = 'tests.{}.{}'.format(test_spec, test[:-3])
test_mod = importlib.import_module(test_mod_name)
if not hasattr(test_mod, 'run'): # Not a test script
continue

try:
result = test_mod.run()
except Exception as e:
message = 'Test \'{}\' raised an exception:'.format(test)
result = Failure(message, str(e))

if result.is_success():
print('[ {} ] {}'.format(color(GREEN, 'PASS'), result.message))
else:
any_failures = True
print('[ {} ] {}'.format(color(RED, 'FAIL'), result.message))
for line in result.output.splitlines():
print(' {}'.format(line))

return 1 if any_failures else 0


def main():
ANY_FAILURES = False

test_dir = os.path.join(project_path(), 'tests')
tests = sorted(filter(is_python_script, os.listdir(test_dir)))
for test in tests:
test_mod = importlib.import_module('tests.{}'.format(test[:-3]))
if not hasattr(test_mod, 'run'): # Not a test script
continue

try:
result = test_mod.run()
except Exception as e:
result = Failure('Test \'{}\' raised an exception:'.format(test),
str(e))

if result.is_success():
print('[ {} ] {}'.format(color(GREEN, 'PASS'), result.message))
else:
ANY_FAILURES = True
print('[ {} ] {}'.format(color(RED, 'FAIL'), result.message))
for line in result.output.splitlines():
print(' {}'.format(line))

return 1 if ANY_FAILURES else 0
tests = ['lint'] # Only tests that are always safe and meaningful to run
if len(sys.argv) > 1:
tests = sys.argv[1:]

return run_tests(tests)

if __name__ == '__main__':
sys.exit(main())
No changes.
@@ -1,7 +1,7 @@
import os
import stat

from .util import display_path, paths, Failure, Success
from tests.util import display_path, paths, Failure, Success


SHEBANG = """\
@@ -1,7 +1,7 @@
import itertools
import re

from .util import colon, color, display_path, paths, Failure, Success
from tests.util import colon, color, display_path, paths, Failure, Success


def display_trailing_whitespace(whitespace):
No changes.
No changes.
No changes.
@@ -0,0 +1,17 @@
import subprocess

from tests.util import Failure, Success


def run():
command = ['sudo', # To get access to buildbot files owned by servo
'buildbot', 'checkconfig', '/home/servo/buildbot/master']
ret = subprocess.run(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)

if ret.returncode == 0:
return Success("Buildbot master config passed checkconfig")
else:
return Failure("Buildbot master config check failed:", ret.stderr)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.