Set up the Linux host
The Linux host runs the MonkeyTester viewer and test runner. Any Linux with Python 3.10+ works; the lab uses one box at 192.168.125.70 that also runs Gitea.
Prerequisites
| Dependency | Why | Required |
|---|---|---|
| Python 3.10 or newer | Viewer, runner, unit tests (standard library only, no pip install) | yes |
ffmpeg with libvpx (VP9) and libopus | Converts recordings to WebM for the run page | for videos |
git | Clone the repos | yes |
| Nix with flakes | Optional for the viewer; a convenience the lab uses for repo runs | no |
| Pillow | Only mt-tests/scripts/generate_placeholders.py | no |
Install the packages
sudo apt-get update
sudo apt-get install -y python3 python3-venv ffmpeg git
Fedora: sudo dnf install -y python3 ffmpeg git (ffmpeg comes from RPM Fusion).
Install Nix (optional, recommended)
Install Nix with the official installer, then enable flakes:
mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
Every MonkeyTester repo has a flake.nix with nix run .#tests, nix run and nix develop. With Nix, nothing else is needed for that repo.
Install the viewer
mkdir -p ~/Workspace/MonkeyTester && cd ~/Workspace/MonkeyTester
git clone https://github.com/yurivibes/MonkeyTester.git
cd MonkeyTester
The viewer keeps its state (Run/, Conf/, build_config.json) next to app.py, so always start it from the repo root.
Verify the install
python3 --version # 3.10 or newer
ffmpeg -hide_banner -encoders | grep -E 'libvpx-vp9|libopus' # both listed
nix run .#tests # or, without Nix:
python3 -m unittest discover -s tests -t .
Both run every tests/**/test_*.py, the same command as CI (.github/workflows/test.yml). The tests need no devices, controller or vision model.
First start (foreground)
python3 app.py 8089
# or with Nix:
nix run . -- 8089
Check curl -s localhost:8089/health answers {"ok": true, …}, then open http://<host>:8089/. The viewer listens on every interface; set MT_VIEWER_BIND=127.0.0.1 to keep it on this machine. Every page and API requires a login — including from localhost. There is no self sign-up: on first start the viewer has one account, admin / admin (role admin).
Default credentials: sign in as admin / admin and change that password right away (Settings → Configuration → Account) — until you do, anyone who can reach port 8089 can sign in as admin, and a warning banner stays on every page. Then create accounts for other people on the admin-only Settings → Users page (create, reset password, delete, change role). Lost the only admin password? Stop the viewer, delete auth_config.json and start it again: admin / admin is seeded again.
The Mobile Controller, the plugins and their tokens are all set in Settings once you are signed in (see Connect the viewer to everything), not in the viewer's environment. A CONTROLLER_URL, CONTROLLER_TOKEN or MT_PLUGINS already in the environment is imported into Settings once at start and ignored after that.
Run the viewer as a service
The lab runs the viewer as a systemd user unit. Create ~/.config/systemd/user/monkeytester-viewer.service:
[Unit]
Description=MonkeyTester viewer (app.py web UI)
After=network.target
[Service]
WorkingDirectory=%h/Workspace/MonkeyTester/MonkeyTester
ExecStart=/usr/bin/python3 %h/Workspace/MonkeyTester/MonkeyTester/app.py 8089
Restart=always
RestartSec=3
[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable --now monkeytester-viewer
sudo loginctl enable-linger "$USER" # start user units at boot, without a login
journalctl --user -u monkeytester-viewer -f # live log
The unit needs no environment: the controller, the plugins and every token live in Settings. Optional variables (MT_VIEWER_BIND, MT_MAX_UPLOAD_MB, MT_DEVICE_CONNECT_WAIT_SECS, see Reference) go in an Environment= line or a drop-in in monkeytester-viewer.service.d/. Restart the unit after pulling a new version of the repo.
After the security update the viewer always requires a login, and there is no setting to turn it off. It still speaks plain HTTP, so passwords and session cookies cross the network unencrypted: keep it on a trusted LAN and use a VPN (Tailscale, WireGuard) for remote access. Do not keep tokens in the unit or its drop-ins — the viewer stores them in Settings. See Security.
Connect the viewer to everything
Everything is registered on one page, Settings → Plugins, in three sections: Test Plugins (the vision model and device plugins), Build Plugin and Controller Plugin. You only type an address (and a pairing token when the service needs one): each plugin reports its own name from GET /health, and the viewer saves nothing until that check passes.
- Mobile Controller: in Controller Plugin, add the controller's address (
http://192.168.125.71:8090). Then enter its token in Settings → Configuration → Service tokens (write-only: checked against the controller before it is saved, then shown only as its last four characters). Open/api/status:controller.okmust betruewithapi_version: 2. - Vision model: in Test Plugins, add the AI plugin's address (
http://192.168.125.71:8091) with its pairing token (theMTAI_TOKENthe AI service was started with, see Mac → serve on the LAN). The viewer checks that/healthis the AI plugin and that an authenticated/configanswers, and saves nothing if either fails. The row shows up as AI. - Provider: click Configure on the AI row, pick Local model and the installed model (
qwen2.5vl:7b-q4_K_M), then Save changes. The same panel renames the plugin (the name tests use, defaultAI). See Vision model providers for Remote server and Copilot. - DIFF plugin (for snapshot and layout steps): in Test Plugins, add
http://127.0.0.1:8095(see below). Without it,DIFF: SNAPSHOTandDIFF: ASSERT_LAYOUTsteps fail with "DIFF plugin is not configured". - Device plugins (optional): add each one's address in Test Plugins (the lab's ESP32 plugins:
http://127.0.0.1:8091→ESP32-SENSOR,http://127.0.0.1:8093→ESP32-SERVER). A plugin on this host listens on127.0.0.1by default and needs no token; a plugin on another machine requires one, entered in the Add row. See Device plugins. - Build & Test (optional): in Build Plugin, add the build plugin's address (
http://192.168.125.71:8094) and its pairing token, click Configure on its row and set the code host — Gitea or GitHub — with its URL and a read-only token. Then add each project repo (owner/repo), its plugin and its branch in Settings → Build & Test. The viewer itself never talks to a code host. See Build & Test. - CI token (optional): only for a CI outside Build & Test that uploads with
submit.py. Build plugins need none. See Build & Test → The CI token. - Device names (optional): Configure on the Controller Plugin row gives phones friendly names.
Test steps call plugins by these names, in UPPERCASE: AI: CLICK Login, ESP32-SERVER: expect, DIFF: SNAPSHOT home. The old MT_PLUGINS=name=url[,name=url] variable is imported once at viewer start and ignored after that.
DIFF plugin (snapshots and layout)
DIFF: SNAPSHOT and DIFF: ASSERT_LAYOUT run in a separate plugin, MonkeyTester-Plugin-Diff. It is standard-library Python, keeps no state, and runs next to the viewer on 127.0.0.1:8095.
git clone https://github.com/yurivibes/MonkeyTester-Plugin-Diff.git ~/Workspace/MonkeyTester-Plugin-Diff
cd ~/Workspace/MonkeyTester-Plugin-Diff
nix run .#tests # or: python3 -m unittest discover -s tests
nix run # or: python3 diff_plugin.py → 127.0.0.1:8095
curl -s localhost:8095/health # "plugin": {"name": "DIFF", ...}
Keep it running with the user unit in its repo:
cp packaging/systemd/monkeytester-diff.service ~/.config/systemd/user/
# edit WorkingDirectory if the checkout is not ~/Workspace/MonkeyTester-Plugin-Diff
systemctl --user daemon-reload
systemctl --user enable --now monkeytester-diff
Then add http://127.0.0.1:8095 in Settings → Plugins → Test Plugins. On loopback no token is needed; to run it on another machine, set PLUGIN_BIND and PLUGIN_TOKEN (it refuses to start on a LAN bind without one). See Snapshots and layout.
Ports to open
| Port | Service | Who connects |
|---|---|---|
8089/tcp | MonkeyTester viewer | Browsers (login required), build plugin uploads |
3000/tcp, 2222/tcp | Gitea web/API, Gitea SSH (the lab's code host) | Developers, and the build plugin configured for it |
Device plugins running on this host listen on loopback by default and need no open port. The one deliberate exception in the lab is the ESP32 server plugin's fake hub, which the real sensor board reaches over Wi-Fi (see Security).
Updating
cd ~/Workspace/MonkeyTester/MonkeyTester && git pull && systemctl --user restart monkeytester-viewer
Restarting the viewer stops the runner processes it started (systemd stops the whole unit), so a run in progress ends as Error. Check Settings → Run Status first.