Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lab/config/replica.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
RingDirectory /data/ring
RingSize 32m
MaxPacketSize 4096
WriteIP 0.0.0.0/0
3 changes: 2 additions & 1 deletion lab/config/upstream.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
RingDirectory /data/ring
RingSize 32m
MSeedScan /seed Match=.* Reject= InitCurrentState=y
MaxPacketSize 4096
MSeedScan /seed Match=.*\.mseed2$
2 changes: 2 additions & 0 deletions lab/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
File renamed without changes.
83 changes: 41 additions & 42 deletions lab/prove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 - <<PY
import socket

host = "${host}"
port = 16000
s = socket.create_connection((host, port), timeout=5)
s.sendall(b"ID ringserver-feeder-probe:probe:1:linux\\r")
buf = b""
while b"\\r" not in buf:
chunk = s.recv(4096)
if not chunk:
break
buf += chunk
s.sendall(b"POSITION SET LATEST\\r")
buf = b""
while b"\\r" not in buf:
chunk = s.recv(4096)
if not chunk:
break
buf += chunk
line = buf.decode("ascii", errors="replace").split("\\r")[0]
parts = line.split()
if len(parts) >= 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
Loading