diff --git a/buildbot/osuosl/master/config/workers.py b/buildbot/osuosl/master/config/workers.py index 0eaf8e1b7..db23c94f6 100644 --- a/buildbot/osuosl/master/config/workers.py +++ b/buildbot/osuosl/master/config/workers.py @@ -4,7 +4,10 @@ import config def create_worker(name, *args, **kwargs): - password = config.options.get('Worker Passwords', name) + if config.options.getboolean('Internal', 'test_mode'): + password = "test" + else: + password = config.options.get('Worker Passwords', name) return worker.Worker(name, password=password, *args, **kwargs) def get_all(): diff --git a/buildbot/osuosl/master/master.cfg b/buildbot/osuosl/master/master.cfg index f6dc0544b..3552d1c79 100644 --- a/buildbot/osuosl/master/master.cfg +++ b/buildbot/osuosl/master/master.cfg @@ -26,11 +26,18 @@ c['buildbotNetUsageData'] = None import config reload(config) +# Detect if the BUILDMASTER_TEST environment variable is set and non-zero. +# This will be used to enable a local testing mode. +buildmaster_test = os.environ.get('BUILDMASTER_TEST') +test_mode = bool(buildmaster_test) and buildmaster_test != '0' +config.options['Internal'] = {} +config.options['Internal']['test_mode'] = str(test_mode) + ####### Workers c['workers'] = config.workers.get_all() -c['protocols'] = {'pb': {'port': 9990}} +c['protocols'] = {'pb': {'port': "tcp:9990:interface=127.0.0.1" if test_mode else 9990}} ####### CHANGESOURCES @@ -94,25 +101,29 @@ c['services'] = config.status.getReporters() ####### PROJECT IDENTITY -c['title'] = config.options.get('Buildbot', 'title') -c['titleURL'] = config.options.get('Buildbot', 'title_url') -c['buildbotURL'] = config.options.get('Buildbot', 'my_url') +c['title'] = "Buildbot (test)" if test_mode else config.options.get('Buildbot', 'title') +c['titleURL'] = "http://localhost:8011/" if test_mode else config.options.get('Buildbot', 'title_url') +c['buildbotURL'] = "http://localhost:8011/" if test_mode else config.options.get('Buildbot', 'my_url') # minimalistic config to activate new web UI -c['www'] = dict(port=8011, - plugins=dict(waterfall_view={}, console_view={}, grid_view={}), # TODO: badges - default_page='console', - auth=config.auth.getAuth(), - authz=config.auth.getAuthz(), - #logRotateLength= - #maxRotatedFiles= - #versions= +www_config = dict(port="tcp:8011:interface=127.0.0.1" if test_mode else 8011, + plugins=dict(waterfall_view={}, console_view={}, grid_view={}), # TODO: badges + default_page='console', + #logRotateLength= + #maxRotatedFiles= + #versions= ) +if not test_mode: + www_config['auth'] = config.auth.getAuth() + www_config['authz'] = config.auth.getAuthz() + +c['www'] = www_config + ####### DB URL c['db'] = { - 'db_url' : config.options.get('Database', 'db_url'), + 'db_url' : "sqlite:///state.sqlite" if test_mode else config.options.get('Database', 'db_url'), } ####### RESOURCE USAGE