Move activitypub automated test to run under a container

This commit is contained in:
Gabe Kangas
2026-03-30 12:32:04 -07:00
parent 5d4fcf9686
commit a2981903c2
7 changed files with 191 additions and 95 deletions
+33 -73
View File
@@ -2,83 +2,29 @@
This test verifies Owncast's ActivityPub federation by having snac2 users follow the Owncast instance and confirming message delivery.
## One-Time Setup
All test infrastructure (snac2, Caddy, mkcert, Go) runs inside a Docker container so you don't need to install anything on the host besides Docker.
### 1. Install mkcert
## Prerequisites
- Docker installed and running
## Running the Tests
```bash
# Ubuntu/Debian
sudo apt install mkcert
# Or download directly
curl -sLO https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64
chmod +x mkcert-v1.4.4-linux-amd64
sudo mv mkcert-v1.4.4-linux-amd64 /usr/local/bin/mkcert
```
### 2. Install the local CA
This installs a Certificate Authority into your system's trust store. All certificates generated by mkcert will be trusted.
```bash
mkcert -install
```
### 3. Generate certificates for the test domains
```bash
cd test/automated/activitypub
mkdir -p certs
mkcert -cert-file certs/cert.pem -key-file certs/key.pem owncast.local snac.local localhost 127.0.0.1
```
### 4. Add hosts entries
```bash
sudo sh -c 'echo "127.0.0.1 owncast.local snac.local" >> /etc/hosts'
```
### 5. Install snac2
```bash
# Ubuntu/Debian
sudo apt install snac2
# Or build from source
git clone https://codeberg.org/grunfink/snac2.git
cd snac2
make
sudo make install
```
### 6. Install Caddy
Caddy is used as the HTTPS reverse proxy for TLS termination. It will be installed automatically by `setup.sh`, or you can install it manually:
```bash
# Download binary directly
curl -sL "https://github.com/caddyserver/caddy/releases/download/v2.8.4/caddy_2.8.4_linux_amd64.tar.gz" | sudo tar -xz -C /usr/local/bin caddy
# Or see: https://caddyserver.com/docs/install
```
## Running the Test
```bash
# Run with default 100 users
# Run the federation test with default 100 users
./run.sh
# Run with fewer users for quick testing
USER_COUNT=10 ./run.sh
# Run the follower validation test
./run.sh test-follower-validation.sh
# Keep servers running after test for debugging
KEEP_RUNNING=true ./run.sh
# Adjust follow request throttling (default 0.1s)
FOLLOW_DELAY=0.2 ./run.sh
# Run in CI mode (skip interactive prompts)
CI=true ./run.sh
```
## Configuration Options
@@ -88,7 +34,7 @@ CI=true ./run.sh
| `USER_COUNT` | 100 | Number of test users to create |
| `FOLLOW_DELAY` | 0.1 | Delay in seconds between follow requests |
| `KEEP_RUNNING` | false | Keep servers running after test for debugging |
| `CI` | false | Skip interactive prompts for CI environments |
| `CI` | false | Always true inside the container |
| `PROXY_PORT` | 8443 | HTTPS proxy port |
| `SNAC_PORT` | 9080 | snac2 HTTP port |
| `OWNCAST_PORT` | 8080 | Owncast HTTP port |
@@ -111,23 +57,37 @@ The test reports:
- **Follow Success Rate**: Percentage of follow requests that succeeded
- **Delivery Rate**: Percentage of registered followers who received the message
## Docker Image Details
The Docker image (`owncast-ap-test`) bundles all dependencies:
- Go (for building Owncast)
- snac2 (built from source)
- Caddy (HTTPS reverse proxy)
- mkcert (TLS certificates trusted by the container)
- sqlite3, jq, curl
Go module and build caches are stored in named Docker volumes (`owncast-ap-test-gomod`, `owncast-ap-test-gobuild`) so repeated runs are faster.
## Troubleshooting
### Certificate errors from snac2
### Docker build fails
Make sure you ran `mkcert -install` and generated the certificates. The CA must be in the system trust store for snac2 to trust the certificates.
Make sure Docker is running. On macOS, Docker Desktop or a compatible runtime (colima, OrbStack, etc.) is required.
### Port already in use
Kill any leftover processes:
If a previous container didn't shut down cleanly:
```bash
pkill -f "snac httpd /tmp"
pkill -f "caddy run"
docker ps -a | grep owncast-ap-test
docker rm -f <container_id>
```
### Hosts file not configured
### Cleaning up Docker resources
Verify the entries exist:
```bash
grep -E 'owncast.local|snac.local' /etc/hosts
# Remove the image
docker rmi owncast-ap-test
# Remove Go caches
docker volume rm owncast-ap-test-gomod owncast-ap-test-gobuild
```