From 17e948e1f0a4c620a53acfebe2c87f9f71287eff Mon Sep 17 00:00:00 2001 From: John Ajera Date: Tue, 18 Aug 2026 11:11:23 +1200 Subject: [PATCH] fix: make lab prove.sh pass and add integration CI Use valid libmseed2 fixture data, MaxPacketSize 4096, and explicit stream selection with a time window so the feeder ingests scanned upstream data. Rewrite prove.sh to use datalink-client (DataLink framing) and stop the feeder before probing replica packet IDs. Add an integration workflow that runs docker compose + prove.sh on PRs. --- .github/workflows/integration.yml | 28 ++++++++ lab/config/replica.conf | 1 + lab/config/upstream.conf | 3 +- lab/docker-compose.yml | 2 + lab/miniseed/{test.mseed => test.mseed2} | Bin lab/prove.sh | 83 +++++++++++------------ 6 files changed, 74 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/integration.yml rename lab/miniseed/{test.mseed => test.mseed2} (100%) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..4bdaa0c --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,28 @@ +name: Integration + +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + lab: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build and start lab stack + working-directory: lab + run: | + docker compose up -d --build + sleep 20 + + - name: Verify replica packet IDs match + working-directory: lab + run: bash prove.sh + + - name: Tear down lab stack + if: always() + working-directory: lab + run: docker compose down -v diff --git a/lab/config/replica.conf b/lab/config/replica.conf index c6e61cb..7d9d482 100644 --- a/lab/config/replica.conf +++ b/lab/config/replica.conf @@ -1,3 +1,4 @@ RingDirectory /data/ring RingSize 32m +MaxPacketSize 4096 WriteIP 0.0.0.0/0 diff --git a/lab/config/upstream.conf b/lab/config/upstream.conf index d7201ab..a4d59e2 100644 --- a/lab/config/upstream.conf +++ b/lab/config/upstream.conf @@ -1,3 +1,4 @@ RingDirectory /data/ring RingSize 32m -MSeedScan /seed Match=.* Reject= InitCurrentState=y +MaxPacketSize 4096 +MSeedScan /seed Match=.*\.mseed2$ diff --git a/lab/docker-compose.yml b/lab/docker-compose.yml index c84355f..7d106f9 100644 --- a/lab/docker-compose.yml +++ b/lab/docker-compose.yml @@ -36,7 +36,9 @@ services: environment: FEEDER_SEEDLINK_HOST: upstream:18000 FEEDER_DATALINK_HOSTS: rs0:16000,rs1:16000 + FEEDER_STREAMS: XX_TEST FEEDER_VERBOSE: "1" + command: ["-tw", "2012,05,12,00,00,00:"] volumes: upstream-data: diff --git a/lab/miniseed/test.mseed b/lab/miniseed/test.mseed2 similarity index 100% rename from lab/miniseed/test.mseed rename to lab/miniseed/test.mseed2 diff --git a/lab/prove.sh b/lab/prove.sh index 47b4d67..c5698b1 100755 --- a/lab/prove.sh +++ b/lab/prove.sh @@ -2,49 +2,48 @@ set -euo pipefail cd "$(dirname "$0")" -NETWORK="$(docker compose ps -q feeder | xargs docker inspect -f '{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}' | head -1)" - -read_pktid() { - local host="$1" - docker run --rm --network "$NETWORK" python:3.12-slim python3 - <= 2 and parts[0] in ("OK", "ERROR"): - print(parts[1]) -else: - print("0") -PY -} -id0="$(read_pktid rs0)" -id1="$(read_pktid rs1)" +# Stop feeder so DataLink read probes are not blocked by open write connections. +docker compose stop feeder >/dev/null 2>&1 || true + +python3 - <<'PY' +import subprocess +import sys + +try: + from datalink_client import DataLink +except ImportError: + subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "datalink-client"]) + from datalink_client import DataLink + +compose_dir = "." +ids: dict[str, int] = {} -echo "rs0 latest pktid: $id0" -echo "rs1 latest pktid: $id1" +for service in ("rs0", "rs1"): + cid = subprocess.check_output( + ["docker", "compose", "ps", "-q", service], + cwd=compose_dir, + text=True, + ).strip() + if not cid: + print(f"FAIL: {service} container not running") + sys.exit(1) -if [[ -n "$id0" && -n "$id1" && "$id0" == "$id1" && "$id0" != "0" ]]; then - echo "PASS: replicas share packet IDs" - exit 0 -fi + ip = subprocess.check_output( + ["docker", "inspect", "-f", "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}", cid], + text=True, + ).strip() -echo "FAIL: packet IDs differ or ring is empty" -exit 1 + with DataLink(ip, 16000) as dl: + pktid = dl.set_position_latest() + ids[service] = int(pktid) + print(f"{service} latest pktid: {pktid}") + +id0, id1 = ids["rs0"], ids["rs1"] +if id0 > 0 and id1 > 0 and id0 == id1: + print("PASS: replicas share packet IDs") + sys.exit(0) + +print("FAIL: packet IDs differ or ring is empty") +sys.exit(1) +PY