Skip to content

Commit

Permalink
Add local testing mode to the buildmaster config (#289)
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).

See llvm/llvm-project#115024 for instructions on how to use, but note #293 is needed to avoid disabling certain builders or needing to hack your local buildbot install.
  • Loading branch information
asb authored Nov 8, 2024
1 parent de862c7 commit 8a25920
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'] = "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
Expand Down

0 comments on commit 8a25920

Please sign in to comment.