ActivityPub integration test (#4761)
* feat(test): add an end-to-end ActivityPub integration test * chore(ci): run AP integration test under CI * feat(test): use caddy instead of home built reverse proxy * fix(test): fix linter warnings * chore(test): don't commit test self-signed certs I suppose * chore(test): more shellcheck linter warnings * fix: fix test setup under CI
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
# ActivityPub Federation Test
|
||||
|
||||
This test verifies Owncast's ActivityPub federation by having snac2 users follow the Owncast instance and confirming message delivery.
|
||||
|
||||
## One-Time Setup
|
||||
|
||||
### 1. Install mkcert
|
||||
|
||||
```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.sh
|
||||
|
||||
# Run with fewer users for quick testing
|
||||
USER_COUNT=10 ./run.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
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `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 |
|
||||
| `PROXY_PORT` | 8443 | HTTPS proxy port |
|
||||
| `SNAC_PORT` | 9080 | snac2 HTTP port |
|
||||
| `OWNCAST_PORT` | 8080 | Owncast HTTP port |
|
||||
|
||||
## What the Test Does
|
||||
|
||||
1. Creates a temporary snac2 instance with test users
|
||||
2. Starts an HTTPS reverse proxy for TLS termination
|
||||
3. Starts Owncast configured for federation
|
||||
4. Has all snac2 users follow Owncast
|
||||
5. Sends a message from Owncast
|
||||
6. Verifies all followers received the message
|
||||
|
||||
## Test Results
|
||||
|
||||
The test reports:
|
||||
- **Followers Registered**: Number of successful follow requests
|
||||
- **Messages Delivered**: Number of users who received the message
|
||||
- **Delivery Time**: Time to deliver to all followers
|
||||
- **Follow Success Rate**: Percentage of follow requests that succeeded
|
||||
- **Delivery Rate**: Percentage of registered followers who received the message
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Certificate errors from snac2
|
||||
|
||||
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.
|
||||
|
||||
### Port already in use
|
||||
|
||||
Kill any leftover processes:
|
||||
```bash
|
||||
pkill -f "snac httpd /tmp"
|
||||
pkill -f "caddy run"
|
||||
```
|
||||
|
||||
### Hosts file not configured
|
||||
|
||||
Verify the entries exist:
|
||||
```bash
|
||||
grep -E 'owncast.local|snac.local' /etc/hosts
|
||||
```
|
||||
Reference in New Issue
Block a user