1 # Test ensures buildbot master comes up correctly and workers can connect
3 { system ? builtins.currentSystem,
5 pkgs ? import ../.. { inherit system config; }
8 import ./make-test-python.nix {
12 bbmaster = { pkgs, ... }: {
13 services.buildbot-master = {
16 # NOTE: use fake repo due to no internet in hydra ci
18 "steps.Git(repourl='git://gitrepo/fakerepo.git', mode='incremental')"
19 "steps.ShellCommand(command=['bash', 'fakerepo.sh'])"
22 "changes.GitPoller('git://gitrepo/fakerepo.git', workdir='gitpoller-workdir', branch='master', pollinterval=300)"
25 networking.firewall.allowedTCPPorts = [ 8010 8011 9989 ];
26 environment.systemPackages = with pkgs; [ git python3Packages.buildbot-full ];
29 bbworker = { pkgs, ... }: {
30 services.buildbot-worker = {
32 masterUrl = "bbmaster:9989";
34 environment.systemPackages = with pkgs; [ git python3Packages.buildbot-worker ];
37 gitrepo = { pkgs, ... }: {
38 services.openssh.enable = true;
39 networking.firewall.allowedTCPPorts = [ 22 9418 ];
40 environment.systemPackages = with pkgs; [ git ];
41 systemd.services.git-daemon = {
42 description = "Git daemon for the test";
43 wantedBy = [ "multi-user.target" ];
44 after = [ "network.target" "sshd.service" ];
46 serviceConfig.Restart = "always";
47 path = with pkgs; [ coreutils git openssh ];
48 environment = { HOME = "/root"; };
50 git config --global user.name 'Nobody Fakeuser'
51 git config --global user.email 'nobody\@fakerepo.com'
52 rm -rvf /srv/repos/fakerepo.git /tmp/fakerepo
53 mkdir -pv /srv/repos/fakerepo ~/.ssh
54 ssh-keyscan -H gitrepo > ~/.ssh/known_hosts
55 cat ~/.ssh/known_hosts
57 mkdir -p /src/repos/fakerepo
58 cd /srv/repos/fakerepo
61 echo -e '#!/bin/sh\necho fakerepo' > fakerepo.sh
63 touch .git/git-daemon-export-ok
64 git add fakerepo.sh .git/git-daemon-export-ok
65 git commit -m fakerepo
68 git daemon --verbose --export-all --base-path=/srv/repos --reuseaddr
75 gitrepo.wait_for_unit("git-daemon.service")
76 gitrepo.wait_for_unit("multi-user.target")
78 with subtest("Repo is accessible via git daemon"):
79 bbmaster.wait_for_unit("network-online.target")
80 bbmaster.succeed("rm -rfv /tmp/fakerepo")
81 bbmaster.succeed("git clone git://gitrepo/fakerepo /tmp/fakerepo")
83 with subtest("Master service and worker successfully connect"):
84 bbmaster.wait_for_unit("buildbot-master.service")
85 bbmaster.wait_until_succeeds("curl --fail -s --head http://bbmaster:8010")
86 bbworker.wait_for_unit("network-online.target")
87 bbworker.succeed("nc -z bbmaster 8010")
88 bbworker.succeed("nc -z bbmaster 9989")
89 bbworker.wait_for_unit("buildbot-worker.service")
91 with subtest("Stop buildbot worker"):
92 bbmaster.succeed("systemctl -l --no-pager status buildbot-master")
93 bbmaster.succeed("systemctl stop buildbot-master")
94 bbworker.fail("nc -z bbmaster 8010")
95 bbworker.fail("nc -z bbmaster 9989")
96 bbworker.succeed("systemctl -l --no-pager status buildbot-worker")
97 bbworker.succeed("systemctl stop buildbot-worker")
99 with subtest("Buildbot daemon mode works"):
101 "buildbot create-master /tmp",
102 "mv -fv /tmp/master.cfg.sample /tmp/master.cfg",
103 "sed -i 's/8010/8011/' /tmp/master.cfg",
104 "buildbot start /tmp",
105 "nc -z bbmaster 8011",
107 bbworker.wait_until_succeeds("curl --fail -s --head http://bbmaster:8011")
108 bbmaster.wait_until_succeeds("buildbot stop /tmp")
109 bbworker.fail("nc -z bbmaster 8011")
112 meta.maintainers = with pkgs.lib.maintainers; [ ];