1 # Test ensures buildbot master comes up correctly and workers can connect
3 import ./make-test-python.nix ({ pkgs, ... }: {
7 bbmaster = { pkgs, ... }: {
8 services.buildbot-master = {
11 # NOTE: use fake repo due to no internet in hydra ci
13 "steps.Git(repourl='git://gitrepo/fakerepo.git', mode='incremental')"
14 "steps.ShellCommand(command=['bash', 'fakerepo.sh'])"
17 "changes.GitPoller('git://gitrepo/fakerepo.git', workdir='gitpoller-workdir', branch='master', pollInterval=300)"
20 networking.firewall.allowedTCPPorts = [ 8010 8011 9989 ];
21 environment.systemPackages = with pkgs; [ git buildbot-full ];
24 bbworker = { pkgs, ... }: {
25 services.buildbot-worker = {
27 masterUrl = "bbmaster:9989";
29 environment.systemPackages = with pkgs; [ git buildbot-worker ];
32 gitrepo = { pkgs, ... }: {
33 services.openssh.enable = true;
34 networking.firewall.allowedTCPPorts = [ 22 9418 ];
35 environment.systemPackages = with pkgs; [ git ];
36 systemd.services.git-daemon = {
37 description = "Git daemon for the test";
38 wantedBy = [ "multi-user.target" ];
39 after = [ "network.target" "sshd.service" ];
41 serviceConfig.Restart = "always";
42 path = with pkgs; [ coreutils git openssh ];
43 environment = { HOME = "/root"; };
45 git config --global user.name 'Nobody Fakeuser'
46 git config --global user.email 'nobody\@fakerepo.com'
47 rm -rvf /srv/repos/fakerepo.git /tmp/fakerepo
48 mkdir -pv /srv/repos/fakerepo ~/.ssh
49 ssh-keyscan -H gitrepo > ~/.ssh/known_hosts
50 cat ~/.ssh/known_hosts
52 mkdir -p /src/repos/fakerepo
53 cd /srv/repos/fakerepo
56 echo -e '#!/bin/sh\necho fakerepo' > fakerepo.sh
58 touch .git/git-daemon-export-ok
59 git add fakerepo.sh .git/git-daemon-export-ok
60 git commit -m fakerepo
63 git daemon --verbose --export-all --base-path=/srv/repos --reuseaddr
70 gitrepo.wait_for_unit("git-daemon.service")
71 gitrepo.wait_for_unit("multi-user.target")
73 with subtest("Repo is accessible via git daemon"):
74 bbmaster.systemctl("start network-online.target")
75 bbmaster.wait_for_unit("network-online.target")
76 bbmaster.succeed("rm -rfv /tmp/fakerepo")
77 bbmaster.succeed("git clone git://gitrepo/fakerepo /tmp/fakerepo")
79 with subtest("Master service and worker successfully connect"):
80 bbmaster.wait_for_unit("buildbot-master.service")
81 bbmaster.wait_until_succeeds("curl --fail -s --head http://bbmaster:8010")
82 bbworker.systemctl("start network-online.target")
83 bbworker.wait_for_unit("network-online.target")
84 bbworker.succeed("nc -z bbmaster 8010")
85 bbworker.succeed("nc -z bbmaster 9989")
86 bbworker.wait_for_unit("buildbot-worker.service")
88 with subtest("Stop buildbot worker"):
89 bbmaster.succeed("systemctl -l --no-pager status buildbot-master")
90 bbmaster.succeed("systemctl stop buildbot-master")
91 bbworker.fail("nc -z bbmaster 8010")
92 bbworker.fail("nc -z bbmaster 9989")
93 bbworker.succeed("systemctl -l --no-pager status buildbot-worker")
94 bbworker.succeed("systemctl stop buildbot-worker")
96 with subtest("Buildbot daemon mode works"):
98 "buildbot create-master /tmp",
99 "mv -fv /tmp/master.cfg.sample /tmp/master.cfg",
100 "sed -i 's/8010/8011/' /tmp/master.cfg",
101 "buildbot start /tmp",
102 "nc -z bbmaster 8011",
104 bbworker.wait_until_succeeds("curl --fail -s --head http://bbmaster:8011")
105 bbmaster.wait_until_succeeds("buildbot stop /tmp")
106 bbworker.fail("nc -z bbmaster 8011")
109 meta.maintainers = pkgs.lib.teams.buildbot.members;