89 lines
3.2 KiB
Markdown
89 lines
3.2 KiB
Markdown
# Test Environment
|
|
|
|
This directory contains the Docker Compose setup and test data for local development.
|
|
|
|
> **LLM agents:** read [AGENTS.md](./AGENTS.md) first. All commands below
|
|
> are run from this `test/` directory. If you are working in a git
|
|
> worktree alongside other worktrees of this repo, you must run
|
|
> `./bootstrap-stack.sh` before `docker compose up` to avoid host port
|
|
> collisions.
|
|
|
|
## Quick Start
|
|
|
|
```sh
|
|
cd test
|
|
./bootstrap-stack.sh
|
|
docker compose up -d
|
|
set -a; . .env; set +a
|
|
go run .. start --config mc-config.yaml
|
|
```
|
|
|
|
## Running multiple isolated stacks (parallel worktrees)
|
|
|
|
`compose.yaml` accepts per-stack overrides via `.env`. The
|
|
`bootstrap-stack.sh` helper generates one with a deterministic, collision-free
|
|
port allocation derived from the worktree's directory name. Run the four
|
|
Quick Start commands above in worktree A and worktree B — the two stacks
|
|
coexist on disjoint host ports under separate `COMPOSE_PROJECT_NAME`
|
|
namespaces.
|
|
|
|
To return a worktree to a clean state (containers + volumes + `.env` +
|
|
`secrets/` + `testdata/`):
|
|
|
|
```sh
|
|
./teardown-stack.sh
|
|
```
|
|
|
|
See [AGENTS.md](./AGENTS.md) for the full contract, including the Stripe
|
|
webhook constraint when running stacks in parallel.
|
|
|
|
## Services
|
|
|
|
| Service | URL | Credentials |
|
|
|---------|-----|-------------|
|
|
| Member Console | http://localhost:8081 | (via Keycloak) |
|
|
| Keycloak | http://keycloak.localhost:8080 | admin / admin |
|
|
| Temporal UI | http://localhost:8233 | (via Keycloak) |
|
|
| FedWiki | http://admin.localtest.me | (see mc-config.yaml) |
|
|
| PostgreSQL | localhost:5432 | member_console / member_console |
|
|
| Valkey | localhost:6379 | — |
|
|
|
|
## Test Data
|
|
|
|
The `testdata/` directory is named like that so that gopls can ignore it by default. It contains sample data for testing the Member Console, such as:
|
|
|
|
### Keycloak
|
|
|
|
Keycloak state is managed declaratively via `data/keycloak/master-realm.json`. On every `docker compose up`, Keycloak imports this realm file into a fresh ephemeral H2 database — no persistent volume is needed.
|
|
|
|
The realm includes:
|
|
- **Clients:** fedwiki, member-console, temporal, temporal-ui
|
|
- **Users:** admin, litianmei, and service accounts
|
|
|
|
To update the realm config after making changes in the Keycloak admin UI:
|
|
|
|
```sh
|
|
docker compose stop keycloak
|
|
docker compose run --rm \
|
|
-v ./data/keycloak:/tmp/export \
|
|
keycloak export --dir /tmp/export --users realm_file
|
|
# This overwrites data/keycloak/master-realm.json
|
|
docker compose up -d keycloak
|
|
```
|
|
|
|
### FedWiki
|
|
|
|
FedWiki runtime data lives in `data/fedwiki/` (gitignored `status/` dirs). Seed data for owner files and access tokens is committed in `seed/fedwiki/`.
|
|
|
|
A `fedwiki-init` container automatically copies seed files into `data/fedwiki/` on `docker compose up` without overwriting existing files (`cp -rn`). This means:
|
|
- **Fresh clone:** seed data is copied in automatically, no manual steps needed.
|
|
- **Existing setup:** your local data is preserved.
|
|
|
|
To update seed data after making changes (e.g., new tokens or wiki sites):
|
|
|
|
```sh
|
|
# Copy the relevant files from data/fedwiki/ to seed/fedwiki/
|
|
cp data/fedwiki/<site>/status/owner.json seed/fedwiki/<site>/status/
|
|
cp data/fedwiki/<site>/status/user-access-tokens.json seed/fedwiki/<site>/status/
|
|
```
|