github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/docs/content/developers/buildkite-testmachine-setup.md (about) 1 --- 2 search: 3 boost: .2 4 --- 5 # Buildkite Test Agent Setup 6 7 We are using [Buildkite](https://buildkite.com/ddev) for Windows and macOS testing. The build machines and `buildkite-agent` must be set up before use. 8 9 ## Windows Test Agent Setup 10 11 1. Create the user “testbot” on the machine. Use the password for `ddevtestbot@gmail.com`, available in 1Password. 12 2. In admin PowerShell, `wsl --install`. 13 3. In admin PowerShell, `Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"`. 14 4. In admin PowerShell, download and run [windows_buildkite_start.ps1](scripts/windows_buildkite_start.ps1) with `curl <url> -O windows_buildkite_start.ps1`. 15 5. After restart, in **administrative** Git Bash window, `Rename-Computer <testbot-win10(home|pro)-<description>-1` and then `export BUILDKITE_AGENT_TOKEN=<token>`. 16 6. Now download and run [`windows_buildkite-testmachine_setup.sh`](scripts/windows_buildkite_setup.sh). 17 7. Download and run [windows_postinstall.sh](scripts/windows_postinstall.sh). 18 8. Launch Docker. It may require you to take further actions. 19 9. Log into Chrome with the user `ddevtestbot@gmail.com` and enable Chrome Remote Desktop. 20 10. Enable gd, fileinfo, and curl extensions in `/c/tools/php*/php.ini`. 21 11. If a laptop, set the “lid closing” setting to do nothing. 22 12. Set the “Sleep after time” setting in settings to never. 23 13. Install [winaero tweaker](https://winaero.com/request.php?1796) and “Enable user autologin checkbox”. Set up the machine to [automatically log in on boot](https://www.cnet.com/how-to/automatically-log-in-to-your-windows-10-pc/). Then run netplwiz, provide the password for the main user, uncheck “require a password to log in”. 24 14. Set the `buildkite-agent` service to run as the testbot user and use delayed start: Choose “Automatic, delayed start” and on the “Log On” tab in the services widget it must be set up to log in as the testbot user, so it inherits environment variables and home directory (and can access NFS, has testbot Git config, etc). 25 15. `git config --global --add safe.directory '*'`. 26 16. Manually run `testbot_maintenance.sh`, `curl -sL -O https://raw.githubusercontent.com/ddev/ddev/master/.buildkite/testbot_maintenance.sh && bash testbot_maintenance.sh`. 27 17. Run `.buildkite/sanetestbot.sh` to check your work. 28 18. Reboot the machine and do a test run. (On Windows, the machine name only takes effect on reboot.) 29 19. Verify that `go`, `ddev`, `git-bash` are in the path. 30 20. In “Advanced Windows Update Settings” enable “Receive updates for other Microsoft products” to make sure you get WSL2 kernel upgrades. Make sure to run Windows Update to get the latest kernel. 31 32 ## Additional Windows Setup for WSL2+Docker Desktop Testing 33 34 1. The Ubuntu distro should be set up with the user `buildkite-agent` 35 2. `buildkite-agent` should have home directory `/var/lib/buildkite-agent`: `sudo usermod -d /var/lib/buildkite-agent buildkite-agent` 36 3. Configure buildkite agent in /etc/buildkite-agent: 37 * tags="os=wsl2,architecture=amd64,dockertype=wsl2" 38 * token="xxx" 39 4. `wsl.exe --update` 40 5. Open WSL2 and check out [ddev/ddev](https://github.com/ddev/ddev). 41 6. Install DDEV using the standard WSL2 Docker Desktop installation. 42 7. Delete the CAROOT and WSLENV environment variables from administrative PowerShell: 43 44 ```powershell 45 [Environment]::SetEnvironmentVariable("CAROOT", $null, "Machine") 46 [Environment]::SetEnvironmentVariable("WSLENV", $null, "Machine") 47 ``` 48 49 8. Configure brew in PATH with: 50 51 ``` 52 echo "export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH" >>~/.bashrc 53 source ~/.bashrc 54 ``` 55 56 9. As root user, add sudo capability with `echo "ALL ALL=NOPASSWD: ALL" >/etc/sudoers.d/all && chmod 440 /etc/sudoers.d/all`. 57 10. Manually run `testbot_maintenance.sh`, `.buildkite/testbot_maintenance.sh`. 58 11. `git config --global --add safe.directory '*'` 59 12. Install basics in WSL2: 60 61 ```bash 62 curl -fsSL https://pkg.ddev.com/apt/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/ddev.gpg > /dev/null 63 echo "deb [signed-by=/etc/apt/keyrings/ddev.gpg] https://pkg.ddev.com/apt/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list >/dev/null 64 # Update package information and install DDEV 65 sudo apt update && sudo apt install -y build-essential ddev icinga2 mariadb-client 66 brew install docker-compose golang 67 68 sudo mkdir -p /usr/sharekeyrings && curl -fsSL https://keys.openpgp.org/vks/v1/by-fingerprint/32A37959C2FA5C3C99EFBC32A79206696452D198 | sudo gpg --dearmor -o /usr/share/keyrings/buildkite-agent-archive-keyring.gpg 69 echo "deb [signed-by=/usr/share/keyrings/buildkite-agent-archive-keyring.gpg] https://apt.buildkite.com/buildkite-agent stable main" | sudo tee /etc/apt/sources.list.d/buildkite-agent.list 70 sudo apt update && sudo apt install -y build-essential buildkite-agent ca-certificates curl ddev etckeeper gnupg icinga2 nagios-plugins lsb-release make mariadb-client 71 (mkcert -uninstall || true); rm -rf $(mkcert -CAROOT) || true; mkcert -install 72 sudo snap install --classic go 73 sudo snap install ngrok 74 sudo systemctl enable buildkite-agent && sudo systemctl start buildkite-agent 75 ``` 76 77 13. Verify that `buildkite-agent` is running. 78 14. Follow the [Icinga instructions](https://newmonitor.thefays.us/icingaweb2/doc/module/director/chapter/Working-with-agents) to configure the agent. Under the "Agent" tab it provides a script to configure the agent. 79 15. Windows Terminal should be installed. Set "Ubuntu" as the default and have it start on Windows startup. 80 16. `echo "capath=/etc/ssl/certs/" >>~/.curlrc` 81 17. `nc.exe -L -p 9003` on Windows to trigger and allow Windows Defender. 82 18. Run `ngrok config add-authtoken <token>` with token for free account. 83 84 ## Additional Windows Setup for WSL2+Docker-Inside Testing 85 86 1. Uninstall Docker Desktop. 87 2. Remove all of the entries (especially `host.docker.internal`) that Docker Desktop might have added in `C:\Windows\system32\drivers\etc\hosts`. 88 3. Install Docker and basics in WSL2: 89 90 ```bash 91 sudo mkdir -p /etc/apt/keyrings 92 sudo mkdir -p /etc/apt/keyrings && sudo rm -f /etc/apt/keyrings/docker.gpg && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg 93 echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 94 sudo apt update && sudo apt install -y docker-ce docker-ce-cli etckeeper containerd.io docker-compose-plugin 95 sudo usermod -aG docker $USER 96 ``` 97 98 4. Run `.buildkite/sanetestbot.sh` 99 100 ## Icinga2 monitoring setup for WSL2 instances 101 102 1. Icinga Director web UI, configure the host on `newmonitor.thefays.us`, normally making a copy of an existing identical item. 103 2. Deploy the new host using Icinga Director. 104 3. On the WSL2 Ubuntu instance, install needed packages: `sudo apt update && sudo apt install -y etckeeper icinga2 monitoring-plugins-contrib nagios-plugins` 105 4. Add `nagios` to the `docker` group in `/etc/group`. 106 5. `sudo icinga2 node wizard` to configure the agent, see [docs](https://icinga.com/docs/icinga-2/latest/doc/06-distributed-monitoring/#agentsatellite-setup-on-linux) 107 6. Restart `sudo systemctl restart icinga2` 108 7. Hope that it can all work sometime. 109 110 ## macOS Docker Desktop Test Agent Setup (Intel and Apple Silicon) 111 112 1. Create the user “testbot” on the machine. Use the password for `ddevtestbot@gmail.com`, available in 1Password. 113 2. Change the name of the machine to something in keeping with current style, perhaps `testbot-macos-arm64-8`. This is done in **Settings** → **General** → **About** → **Name** and in **Sharing** → **Computer Name** and in **Sharing** → **Local Hostname**. 114 3. Download and install Chrome and log the browser into the account used for test runners. It will pick up the Chrome Remote Desktop setup as a result. Configure Chrome Remote Desktop to serve. When this is done, the machine will be available for remote access and most other tasks can be done using Chrome Remote Desktop. 115 4. The machine should be on the correct network and have a static IP handed out by DHCP. IP addresses are listed in /etc/hosts on `pi.ddev.site`, so this one should be added. 116 5. Power should be set up as in . 117 6. Auto login should be set up as in , see [automatically log in on boot](https://support.apple.com/en-us/HT201476). 118 7. Remote login should be enabled as in . 119 8. Automatic updates should be set to mostly security only as in . 120 9. Set the time zone to US MT (nearest city: Denver, Colorado). 121 10. `sudo mkdir -p /usr/local/bin && sudo chown -R testbot /usr/local/bin` 122 11. Install [Homebrew](https://brew.sh/) `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` 123 12. After installing Homebrew follow the instructions it gives you at the end to add brew to your PATH. 124 13. Install everything you’ll need with `brew install buildkite/buildkite/buildkite-agent bats-core composer ddev/ddev/ddev git golang jq mariadb mkcert netcat p7zip && brew install --cask docker iterm2 ngrok`. 125 14. Run `ngrok authtoken <token>` with token for free account from 1Password. 126 15. Run `mkcert -install`. 127 16. If Docker Desktop will be deployed, run Docker manually and go through its configuration routine. 128 17. If OrbStack will be deployed, install it from [orbstack.dev](https://orbstack.dev). 129 * Install with Docker only. 130 * Click "Sign in" in the lower left to sign in with OrbStack credentials (normal test runner gmail address; it will receive an email with a login code). 131 * Configure it to automatically start and download updates, see . 132 18. If Rancher Desktop will be deployed, install it. 133 * Turn off kubernetes. 134 19. Run iTerm. You may need to allow full disk access permissions. 135 20. Run `mkdir ~/workspace && cd ~/workspace && git clone https://github.com/ddev/ddev`. 136 21. Set up `nfsd` by running `bash ~/workspace/ddev/scripts/macos_ddev_nfs_setup.sh`. 137 22. `git config --global --add safe.directory '*'`. 138 23. Edit `/usr/local/etc/buildkite-agent/buildkite-agent.cfg` or `/opt/homebrew/etc/buildkite-agent/buildkite-agent.cfg` to add 139 * the agent `token` (from [agents tab](https://buildkite.com/organizations/ddev/agents), "Reveal Agent Token"). 140 * the agent `name` (the name of the machine). 141 * `tags`, like `"os=macos,architecture=arm64,osvariant=sonoma,dockertype=dockerformac,rancher-desktop=true,orbstack=true,docker-desktop=true"` 142 * `build-path="~/tmp/buildkite-agent/builds"` 143 24. Run `brew services start buildkite-agent`. 144 25. Run `bash ~/workspace/ddev/.buildkite/testbot_maintenance.sh`. 145 26. Run `bash ~/workspace/ddev/.buildkite/sanetestbot.sh` to check your work. 146 27. The `testbot` user's ssh account is used for monitoring, so `ssh-keygen` and then add the public key `id_testbot` from 1Password to `~/.ssh/authorized_keys` and `chmod 600 ~/.ssh/authorized_keys`. 147 28. Add the new machine to Icinga by copying an existing Icinga service to the new one. This is done in **Icinga Director** → **Services** → **Single Services** → **Select a Service** → **Clone** → **Deploy**. The new service has to have `by-ssh-address` set to the name of the test runner, and that address needs to be added to `pi.ddev.site`'s `/etc/hosts` file. 148 29. If `zsh` is the shell configured, add `/etc/zshenv` so that `/usr/local/bin/docker` will be picked up: 149 150 ```bash 151 PATH=$PATH:/usr/local/bin:/opt/homebrew/bin 152 ``` 153 154 ## Additional Colima macOS setup 155 156 1. `brew install colima` 157 2. `colima start --cpu 4 --memory 6 --disk 100 --vm-type=qemu --mount-type=sshfs --dns=1.1.1.1` 158 3. `colima stop` 159 4. `colima start vz --cpu 4 --memory 6 --disk 60 --vm-type=vz --mount-type=virtiofs --dns=1.1.1.1` 160 5. `colima stop vz` 161 162 Then the Buildkite agent must be configured with tags `colima=true` and `colima_vz=true`. 163 164 ## Additional Lima macOS setup (not yet working) 165 166 1. `limactl create --name=lima-vz --vm-type=vz --mount-type=virtiofs --mount="~/:w" --memory=6 --cpus=4 --disk=100 template://docker` 167 2. `limactl start lima-vz` 168 3. `docker context use lima-lima-vz` 169 170 Then the Buildkite agent must be configured with tags `lima=true`.