Skip to content

Commit 94da8fd

Browse files
committed
test: keep one mock Cloudflare DNS API, in tools/
There were two. `tools/mock-cf-dns-api` was 882 lines of Flask and gunicorn behind a published `kvin/mock-cf-dns-api:latest`, and after the gateway suite switched to a repo-built mock, nothing used it. The survivor is 354 lines of stdlib with no dependencies, and it is the only one that answers DNS, which is what lets an ACME server validate rather than be told to skip. Nothing is lost: certbot's Cloudflare client calls four endpoints -- list zones, list records, create, delete -- and the survivor implements exactly those. The dropped extras (PUT, single-record GET, a log buffer, a web UI) had no caller. Moved to tools/ because it is no longer one suite's fixture: both build it, and the gateway suite was reaching into the other suite's directory through four levels of `..` to find it.
1 parent 9fa8421 commit 94da8fd

10 files changed

Lines changed: 23 additions & 936 deletions

File tree

dstack/gateway/test-run/e2e/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ services:
3636
# Mock Cloudflare DNS API. Built from the repo rather than pulled, and the
3737
# same image the full-stack suite builds, so both suites answer DNS the same
3838
# way and neither depends on a prebuilt image nobody can rebuild.
39+
# Source: tools/mock-cf-dns.
3940
mock-cf-dns-api:
4041
build:
41-
context: ../../../../test-suites/full-stack-compose/mock-cf-dns
42+
context: ../../../../tools/mock-cf-dns
4243
image: dstack-e2e-mock-cf-dns:local
4344
container_name: mock-cf-dns-api
4445
networks:

dstack/gateway/test-run/e2e/run-e2e.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ log_info "Starting e2e test environment..."
136136

137137
export GATEWAY_IMAGE=dstack-gateway:test
138138

139+
# Build the mock rather than trusting whatever carries its tag. `image:` plus
140+
# `build:` means compose reuses a local tag if one exists, and this tag is
141+
# shared with the full-stack suite, so a stale copy from an older checkout
142+
# would be picked up silently -- and a mock that does not answer TCP fails
143+
# every challenge now that Pebble actually validates them.
144+
log_info "Building the mock DNS/Cloudflare API..."
145+
docker compose build mock-cf-dns-api
146+
139147
docker compose up -d mock-cf-dns-api pebble
140148
log_info "Waiting for mock services to be healthy..."
141149
sleep 5

test-suites/full-stack-compose/compose.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ services:
5757

5858
mock-cf-dns-api:
5959
build:
60-
context: ./mock-cf-dns
60+
context: ../../tools/mock-cf-dns
6161
image: dstack-e2e-mock-cf-dns:local
6262
networks:
6363
e2e-net:
@@ -76,9 +76,11 @@ services:
7676
retries: 10
7777

7878
pebble:
79-
# Custom Pebble build used by the existing gateway E2E suite. It supports
80-
# plain HTTP ACME URLs, which keeps the host-side Gateway bootstrap simple.
81-
image: ${DSTACK_E2E_PEBBLE_IMAGE:-kvin/pebble:latest}
79+
# Custom Pebble build shared with the gateway E2E suite: upstream plus a
80+
# `-http` flag, which keeps the host-side Gateway bootstrap simple.
81+
# github.com/kvinwang/pebble branch http-flag. Pinned rather than :latest,
82+
# so a rebuild of that tag cannot change what this suite validates against.
83+
image: ${DSTACK_E2E_PEBBLE_IMAGE:-kvin/pebble:v2.10.1-http}
8284
command: ["-http", "-dnsserver", "172.31.0.10:53"]
8385
networks:
8486
e2e-net:
@@ -88,7 +90,10 @@ services:
8890
- "0.0.0.0:${DSTACK_E2E_PEBBLE_MGMT_PORT:-35000}:15000"
8991
environment:
9092
PEBBLE_VA_NOSLEEP: "1"
91-
PEBBLE_VA_ALWAYS_VALID: "1"
93+
# No PEBBLE_VA_ALWAYS_VALID. It was needed because the mock answered only
94+
# UDP while Pebble queries a custom resolver over TCP, so nothing it was
95+
# pointed at could ever answer; the mock now serves both and challenges
96+
# are validated against the records certbot writes.
9297
depends_on:
9398
mock-cf-dns-api:
9499
condition: service_healthy

tools/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ This directory contains developer and operator utilities that do not belong to
44
one runtime component or one guest-OS backend.
55

66
- `add-spdx-attribution.py` updates SPDX attribution metadata.
7-
- `mock-cf-dns-api/` provides a local Cloudflare DNS API test double.
7+
- `mock-cf-dns/` is the Cloudflare DNS API test double both E2E suites build:
8+
the API endpoints certbot calls, plus TXT answers on 53 over UDP and TCP so
9+
an ACME server can validate against the records it writes.
810
- `sca/` builds self-contained application images.
911
- `dev-stack.sh` preserves the unsupported legacy all-in-one host, guest, and
1012
deployment helper.

tools/mock-cf-dns-api/Dockerfile

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)