- Options: VersionCommand, VersionTimeoutSeconds, MinimumVersion, EnforceMinimumVersion - Version probe service and parser; startup enforcement when EnforceMinimumVersion - Save flow: block save on probe failure (VersionProbeFailed) or version below minimum (UnsupportedVersion) - Status API and Dnsmasq page: show version with tooltip, link to CHANGELOG - Readiness: GET /healthz/ready (version + dnsmasq running when StatusCommand set) - MapReadyHealthCheck extension; Dockerfile HEALTHCHECK + curl; compose healthcheck and service_healthy - Docs: README and agents.md updated
4.3 KiB
Agent instructions: dnsmasq-webui
Test harness (Docker)
The test harness runs the app and dnsmasq in Docker with DHCP clients so you can test the UI and effective config against real dnsmasq.
Script: scripts/prepare-test-mount.sh
Compose file: docker-compose.test.yml
Start the harness
From the repo root:
./scripts/prepare-test-mount.sh
This will:
- Sync
testdata/totestdata-mount/(preserving existing contents unless you pass--clear) - Remove any
*dnsmasq-webui*.confin the mount so dnsmasq starts clean - Resolve the requested dnsmasq version (
latestby default) to a concrete value when needed - Run
docker compose -f docker-compose.test.yml up -d --build
- Quick restart (no image rebuild):
./scripts/prepare-test-mount.sh --no-build - Force a fresh image build:
./scripts/prepare-test-mount.sh --no-cache-build - Pin dnsmasq version:
./scripts/prepare-test-mount.sh --dnsmasq-version 2.91 --build - Use distro package:
./scripts/prepare-test-mount.sh --dnsmasq-version distro --build - Prepare mount only (no start):
./scripts/prepare-test-mount.sh --prepare-only
Then start manually with the version printed by the script:TESTDATA_MOUNT=./testdata-mount DNSMASQ_VERSION=<resolved-version> docker compose -f docker-compose.test.yml up -d [--build] - Preserve mount (e.g. keep leases):
./scripts/prepare-test-mount.sh --no-build(default mount behavior)
App is at http://localhost:8080. Main config path in the container is /data/dnsmasq-test.conf; managed file is zz-dnsmasq-webui.conf in the same directory. The app service has a healthcheck (GET /healthz/ready); DHCP client services use depends_on: app: condition: service_healthy so they start only after the app (and dnsmasq) is ready.
Stop the harness
./scripts/prepare-test-mount.sh --stop
Runs docker compose -f docker-compose.test.yml down (stops and removes containers/networks). Does not change the mount directory.
Clean (stop + clear mount)
./scripts/prepare-test-mount.sh --tidy
Stops the harness and deletes the contents of testdata-mount/ so the next run starts from a clean sync of testdata/.
Custom paths
--source DIR— Source to sync from (default:testdata)--mount DIR— Mount directory (default:testdata-mount). The script exportsTESTDATA_MOUNT=./DIRwhen you use--mount, so compose uses it.--dnsmasq-version V— Dnsmasq version for the harness image:latest(default),distro, or an exact upstream version like2.91.--no-cache-build— Force a fresh image build withdocker compose build --pull --no-cachebefore start.
Example: sync from a custom dir and start:
./scripts/prepare-test-mount.sh --source myfixtures --mount mymount
Help
./scripts/prepare-test-mount.sh -h
Unit tests
From the repo root:
dotnet test
Build only: dotnet build
Test data
- testdata/ — Source for the harness mount. Synced to
testdata-mount/byprepare-test-mount.sh. Unit tests read from the copy in the test output dir. See testdata/README for the full layout. - testdata/dnsmasq-test.conf — Harness main config (
/data/dnsmasq-test.conf). Richer config: multipleserver=,addn-hosts=,address=,listen-address=,conf-dir=/data/dnsmasq.d. - testdata/dnsmasq.d/ — Included configs (01-other.conf, 02-servers.conf, 03-more.conf, dhcp.conf). App creates
zz-dnsmasq-webui.confhere when running. - testdata/hosts, testdata/hosts.extra — Addn-hosts files so effective config has multiple addn-hosts; UI can show source per path.
When adding new effective-config options
When adding a new dnsmasq option to the Effective Config UI (new key in DnsmasqConfKeys, section, kind map, parser/write behavior, tooltip, etc.):
- Option help: Add the option key (lowercase, e.g.
no-round-robin) to theOPTION_KEYSlist inscripts/extract-option-help.sh(keep in sync withEffectiveConfigSections). Then run./scripts/extract-option-help.shsowwwroot/option-help/<key>.htmlis generated if the option exists in the dnsmasq man page. - Testdata (optional): To show the option in the UI when using the harness or testdata, add a line to e.g.
testdata/dnsmasq.d/03-more.confand updatetestdata/READMEif needed.