Skip to content

Commit

Permalink
Add local testing mode to the buildmster config
Browse files Browse the repository at this point in the history
This makes it (relatively) easy to test a builder setup locally. The
buildmaster and the web interface should be bound only to local
interfaces for security reasons (you can use ssh port forwarding if
wanting to run on a server).
  • Loading branch information
asb committed Oct 30, 2024
1 parent 1904664 commit 30db356
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
5 changes: 4 additions & 1 deletion buildbot/osuosl/master/config/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
37 changes: 24 additions & 13 deletions buildbot/osuosl/master/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'] = "LLVM Buildbot (local testing mode)" 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
Expand Down

0 comments on commit 30db356

Please sign in to comment.