From 30db3560a252dc03f61421f3f65cac1a5b9b8cf0 Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Wed, 30 Oct 2024 12:43:37 +0000 Subject: [PATCH 1/3] Add local testing mode to the buildmster config 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). --- buildbot/osuosl/master/config/workers.py | 5 +++- buildbot/osuosl/master/master.cfg | 37 +++++++++++++++--------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/buildbot/osuosl/master/config/workers.py b/buildbot/osuosl/master/config/workers.py index 0eaf8e1b..db23c94f 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 f6dc0544..438de5fc 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'] = "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 From 7344d8017b43dee5fe33de09925a1e464d2ed92d Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Tue, 5 Nov 2024 14:27:34 +0000 Subject: [PATCH 2/3] Shorten buildbot name used for testing mode Buildbot limits the maximum length to 18 characters. --- buildbot/osuosl/master/master.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildbot/osuosl/master/master.cfg b/buildbot/osuosl/master/master.cfg index 438de5fc..04e37488 100644 --- a/buildbot/osuosl/master/master.cfg +++ b/buildbot/osuosl/master/master.cfg @@ -101,7 +101,7 @@ c['services'] = config.status.getReporters() ####### PROJECT IDENTITY -c['title'] = "LLVM Buildbot (local testing mode)" if test_mode else config.options.get('Buildbot', 'title') +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') From ef715682077e252c862c3995a83cccf749f0cad4 Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Tue, 5 Nov 2024 16:55:29 +0000 Subject: [PATCH 3/3] Add / to end of URLs to avoid warning in web UI --- buildbot/osuosl/master/master.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildbot/osuosl/master/master.cfg b/buildbot/osuosl/master/master.cfg index 04e37488..3552d1c7 100644 --- a/buildbot/osuosl/master/master.cfg +++ b/buildbot/osuosl/master/master.cfg @@ -102,8 +102,8 @@ c['services'] = config.status.getReporters() ####### PROJECT IDENTITY 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') +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 www_config = dict(port="tcp:8011:interface=127.0.0.1" if test_mode else 8011,