Skip to content

Commit 8a25920

Browse files
authored
Add local testing mode to the buildmaster config (llvm#289)
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 llvm#293 is needed to avoid disabling certain builders or needing to hack your local buildbot install.
1 parent de862c7 commit 8a25920

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

buildbot/osuosl/master/config/workers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import config
55

66
def create_worker(name, *args, **kwargs):
7-
password = config.options.get('Worker Passwords', name)
7+
if config.options.getboolean('Internal', 'test_mode'):
8+
password = "test"
9+
else:
10+
password = config.options.get('Worker Passwords', name)
811
return worker.Worker(name, password=password, *args, **kwargs)
912

1013
def get_all():

buildbot/osuosl/master/master.cfg

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ c['buildbotNetUsageData'] = None
2626
import config
2727
reload(config)
2828

29+
# Detect if the BUILDMASTER_TEST environment variable is set and non-zero.
30+
# This will be used to enable a local testing mode.
31+
buildmaster_test = os.environ.get('BUILDMASTER_TEST')
32+
test_mode = bool(buildmaster_test) and buildmaster_test != '0'
33+
config.options['Internal'] = {}
34+
config.options['Internal']['test_mode'] = str(test_mode)
35+
2936
####### Workers
3037

3138
c['workers'] = config.workers.get_all()
3239

33-
c['protocols'] = {'pb': {'port': 9990}}
40+
c['protocols'] = {'pb': {'port': "tcp:9990:interface=127.0.0.1" if test_mode else 9990}}
3441

3542
####### CHANGESOURCES
3643

@@ -94,25 +101,29 @@ c['services'] = config.status.getReporters()
94101

95102
####### PROJECT IDENTITY
96103

97-
c['title'] = config.options.get('Buildbot', 'title')
98-
c['titleURL'] = config.options.get('Buildbot', 'title_url')
99-
c['buildbotURL'] = config.options.get('Buildbot', 'my_url')
104+
c['title'] = "Buildbot (test)" if test_mode else config.options.get('Buildbot', 'title')
105+
c['titleURL'] = "http://localhost:8011/" if test_mode else config.options.get('Buildbot', 'title_url')
106+
c['buildbotURL'] = "http://localhost:8011/" if test_mode else config.options.get('Buildbot', 'my_url')
100107

101108
# minimalistic config to activate new web UI
102-
c['www'] = dict(port=8011,
103-
plugins=dict(waterfall_view={}, console_view={}, grid_view={}), # TODO: badges
104-
default_page='console',
105-
auth=config.auth.getAuth(),
106-
authz=config.auth.getAuthz(),
107-
#logRotateLength=
108-
#maxRotatedFiles=
109-
#versions=
109+
www_config = dict(port="tcp:8011:interface=127.0.0.1" if test_mode else 8011,
110+
plugins=dict(waterfall_view={}, console_view={}, grid_view={}), # TODO: badges
111+
default_page='console',
112+
#logRotateLength=
113+
#maxRotatedFiles=
114+
#versions=
110115
)
111116

117+
if not test_mode:
118+
www_config['auth'] = config.auth.getAuth()
119+
www_config['authz'] = config.auth.getAuthz()
120+
121+
c['www'] = www_config
122+
112123
####### DB URL
113124

114125
c['db'] = {
115-
'db_url' : config.options.get('Database', 'db_url'),
126+
'db_url' : "sqlite:///state.sqlite" if test_mode else config.options.get('Database', 'db_url'),
116127
}
117128

118129
####### RESOURCE USAGE

0 commit comments

Comments
 (0)