From 4735b4250cfebf1511f6ec8edbf1b2efe48186f6 Mon Sep 17 00:00:00 2001 From: DDlia Date: Sun, 22 Nov 2026 19:42:04 +0900 Subject: [PATCH 1/4] test: add a real moip-toolkit node as a container Builds the Go server and the Rust engine from the pinned submodule and runs avahi-daemon next to them, so that `moip web` advertises _moip._tcp as on utone-linux. No NDI runtime is included (not redistributable), so only the control plane is real. Co-Authored-By: Claude Sonnet 5.5 --- test/node/Dockerfile | 43 +++++++++++++++++++++++++++++++ test/node/Dockerfile.dockerignore | 8 ++++++ test/node/entrypoint.sh | 8 ++++++ 3 files changed, 59 insertions(+) create mode 100644 test/node/Dockerfile create mode 100644 test/node/Dockerfile.dockerignore create mode 100755 test/node/entrypoint.sh diff --git a/test/node/Dockerfile b/test/node/Dockerfile new file mode 100644 index 0000000..f15aeb1 --- /dev/null +++ b/test/node/Dockerfile @@ -0,0 +1,43 @@ +# syntax=docker/dockerfile:1 +# A real moip-toolkit node in a container, for testing moipctl without hardware: +# the Go server and the Rust engine are built from the submodule +# external/moip-toolkit (the commit moipctl pins), and avahi-daemon runs next to +# them so that `moip web` advertises _moip._tcp exactly as it does on utone-linux. +# +# Not included: the NDI runtime (libndi.so.6). Its licence does not allow +# redistributing it, so rx/tx/multiview fail in the engine, while the API, the +# state stream, node info and the mDNS advertisement are the real thing. +# +# Build from the repository root, with the submodules fetched: +# git submodule update --init --recursive external/moip-toolkit +# podman build -f test/node/Dockerfile -t moipctl-node-test . + +# ---- Engine (Rust) ---- +FROM docker.io/library/rust:1-trixie AS engine +RUN apt-get update \ + && apt-get install -y --no-install-recommends libsdl2-dev libasound2-dev pkg-config \ + && rm -rf /var/lib/apt/lists/* +WORKDIR /src +COPY external/moip-toolkit/engine/ ./ +RUN --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/src/target \ + cargo build --release --locked \ + && cp target/release/moip-engine /moip-engine + +# ---- Server (Go) ---- +FROM docker.io/library/golang:1.24-trixie AS server +WORKDIR /src +COPY external/moip-toolkit/server/ ./ +ARG VERSION=test +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ + CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" -o /moip ./cmd/moip + +# ---- Runtime ---- +FROM docker.io/library/debian:trixie-slim +RUN apt-get update \ + && apt-get install -y --no-install-recommends libsdl2-2.0-0 libasound2t64 avahi-daemon dbus \ + && rm -rf /var/lib/apt/lists/* +COPY --from=engine /moip-engine /opt/moip/bin/moip-engine +COPY --from=server /moip /opt/moip/bin/moip +COPY test/node/entrypoint.sh /entrypoint.sh +EXPOSE 8000 +ENTRYPOINT ["/entrypoint.sh"] diff --git a/test/node/Dockerfile.dockerignore b/test/node/Dockerfile.dockerignore new file mode 100644 index 0000000..e206a4e --- /dev/null +++ b/test/node/Dockerfile.dockerignore @@ -0,0 +1,8 @@ +# The build context for test/node/Dockerfile: only the toolkit sources it compiles. +.git +bin +external/utone-linux +external/moip-toolkit/frontend +external/moip-toolkit/engine/target +external/moip-toolkit/.git +**/.git diff --git a/test/node/entrypoint.sh b/test/node/entrypoint.sh new file mode 100755 index 0000000..3092408 --- /dev/null +++ b/test/node/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# dbus and avahi-daemon, then the node. The pod's hostname becomes the node ID. +set -e +mkdir -p /run/dbus +rm -f /run/dbus/pid /run/avahi-daemon/pid +dbus-daemon --system --fork +avahi-daemon -D --no-drop-root --no-chroot +exec /opt/moip/bin/moip web --host 0.0.0.0 --port 8000 "$@" From 9582cf62613bda4991d2c8944e534ddbfc45dc2c Mon Sep 17 00:00:00 2001 From: DDlia Date: Sun, 22 Nov 2026 19:42:04 +0900 Subject: [PATCH 2/4] ci: build the test node image and add a pod example Pushes ghcr.io/technotut/moipctl-node-test on main and on test/** branches. pod.yaml runs one node on VLAN 20 and one on VLAN 42. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/node-image.yml | 54 ++++++++++++++++++++++++++++++++ test/node/pod.yaml | 42 +++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 .github/workflows/node-image.yml create mode 100644 test/node/pod.yaml diff --git a/.github/workflows/node-image.yml b/.github/workflows/node-image.yml new file mode 100644 index 0000000..1c47f37 --- /dev/null +++ b/.github/workflows/node-image.yml @@ -0,0 +1,54 @@ +name: node-image + +# Builds test/node, a real moip-toolkit node in a container (avahi-daemon included, +# no NDI runtime), and pushes ghcr.io/technotut/moipctl-node-test. It is a test fixture +# for trying moipctl on a cluster without hardware, not something to run in production. +on: + workflow_dispatch: + push: + branches: [main, 'test/**'] + paths: + - test/node/** + - external/moip-toolkit + - .github/workflows/node-image.yml + pull_request: + paths: + - test/node/** + - external/moip-toolkit + - .github/workflows/node-image.yml + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + # Only the toolkit is compiled; the other submodule (utone-linux) is not needed. + - run: git submodule update --init --recursive external/moip-toolkit + - uses: docker/setup-buildx-action@v4 + - uses: docker/login-action@v4 + if: github.event_name != 'pull_request' + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: meta + uses: docker/metadata-action@v6 + with: + images: ghcr.io/${{ github.repository }}-node-test + tags: | + type=ref,event=branch + type=sha + type=raw,value=latest,enable={{is_default_branch}} + - uses: docker/build-push-action@v7 + with: + context: . + file: test/node/Dockerfile + platforms: linux/amd64 + build-args: VERSION=${{ steps.meta.outputs.version }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/test/node/pod.yaml b/test/node/pod.yaml new file mode 100644 index 0000000..2f7daa6 --- /dev/null +++ b/test/node/pod.yaml @@ -0,0 +1,42 @@ +# Two test nodes for a cluster that has vxlan-cni (kube-public/vxlan): one on VLAN 20 and one on +# VLAN 42. Each one advertises _moip._tcp from avahi-daemon inside the pod, so a moipctl scout on +# the same VLAN finds it. The pod name is the node ID. They stop by themselves after an hour. +# +# kubectl create namespace moipctl-verify +# kubectl -n moipctl-verify apply -f test/node/pod.yaml +# kubectl -n moipctl-verify delete -f test/node/pod.yaml +apiVersion: v1 +kind: Pod +metadata: + name: testnode-av + labels: { app: moipctl-testnode } + annotations: + k8s.v1.cni.cncf.io/networks: '[{ "name": "vxlan", "namespace": "kube-public", "interface": "av", "cni-args": { "vlan": 20 } }]' +spec: + activeDeadlineSeconds: 3600 + restartPolicy: Never + containers: + - name: node + image: ghcr.io/technotut/moipctl-node-test:main + ports: + - { name: http, containerPort: 8000 } + readinessProbe: + httpGet: { path: /api/node/info, port: http } +--- +apiVersion: v1 +kind: Pod +metadata: + name: testnode-ent + labels: { app: moipctl-testnode } + annotations: + k8s.v1.cni.cncf.io/networks: '[{ "name": "vxlan", "namespace": "kube-public", "interface": "ent", "cni-args": { "vlan": 42 } }]' +spec: + activeDeadlineSeconds: 3600 + restartPolicy: Never + containers: + - name: node + image: ghcr.io/technotut/moipctl-node-test:main + ports: + - { name: http, containerPort: 8000 } + readinessProbe: + httpGet: { path: /api/node/info, port: http } From 0d9f981b52ec0edaa2216813cdb5e8968f364676 Mon Sep 17 00:00:00 2001 From: DDlia Date: Sun, 22 Nov 2026 19:42:04 +0900 Subject: [PATCH 3/4] docs: describe the test node image Co-Authored-By: Claude Sonnet 5.5 --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index d6a21ac..ee8c8a5 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,20 @@ must only be reachable from the scouts (a separate port and a network policy). T Each node shows the scout that found it as `source`. +## Testing against a real node + +`test/node` builds a real moip-toolkit node into a container (the Go server and the Rust engine from the +`external/moip-toolkit` submodule, plus avahi-daemon so that it advertises `_moip._tcp` the way utone-linux does). +It has no NDI runtime (its licence does not allow redistributing it), so rx/tx/multiview fail in the engine, while +the API, the state stream, node info and the mDNS advertisement are real. CI publishes it as +`ghcr.io/technotut/moipctl-node-test`; `test/node/pod.yaml` runs one on VLAN 20 and one on VLAN 42. + +```bash +git submodule update --init --recursive external/moip-toolkit +podman build -f test/node/Dockerfile -t moipctl-node-test . +podman run -d --name node --hostname utone-test moipctl-node-test +``` + ## Container ```bash From 54d85c7202432f648fad70c5825d311e57cf0eed Mon Sep 17 00:00:00 2001 From: DDlia Date: Sun, 22 Nov 2026 19:56:00 +0900 Subject: [PATCH 4/4] test(node): answer from the VLAN interface so a routed controller gets its replies A pod's default route is eth0, so when a controller reached the test node through the router (source = the controller node's IP), the SYN arrived on the VLAN interface but the reply left by eth0 and the handshake never completed (SYN_RECV on the node). Give every non-eth0 interface its own routing table with the VLAN's gateway (network address + 1), selected by the interface's source address. Needs NET_ADMIN; utone-linux hosts, whose default gateway is the router, do not have this problem. Co-Authored-By: Claude Sonnet 5.5 --- test/node/Dockerfile | 2 +- test/node/entrypoint.sh | 31 +++++++++++++++++++++++++++++++ test/node/pod.yaml | 6 ++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/test/node/Dockerfile b/test/node/Dockerfile index f15aeb1..6e17f24 100644 --- a/test/node/Dockerfile +++ b/test/node/Dockerfile @@ -34,7 +34,7 @@ RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache # ---- Runtime ---- FROM docker.io/library/debian:trixie-slim RUN apt-get update \ - && apt-get install -y --no-install-recommends libsdl2-2.0-0 libasound2t64 avahi-daemon dbus \ + && apt-get install -y --no-install-recommends libsdl2-2.0-0 libasound2t64 avahi-daemon dbus iproute2 \ && rm -rf /var/lib/apt/lists/* COPY --from=engine /moip-engine /opt/moip/bin/moip-engine COPY --from=server /moip /opt/moip/bin/moip diff --git a/test/node/entrypoint.sh b/test/node/entrypoint.sh index 3092408..981376a 100755 --- a/test/node/entrypoint.sh +++ b/test/node/entrypoint.sh @@ -1,6 +1,37 @@ #!/bin/sh # dbus and avahi-daemon, then the node. The pod's hostname becomes the node ID. set -e + +# A pod's default route is eth0, but this node is meant to look like a host on a +# VLAN. A controller that reaches it through the router (the source address is the +# controller's node IP) would get its replies out of eth0 and never see them. So, +# for every other interface, answer from that interface's address through that +# VLAN's gateway. On these VLANs the gateway is the network address + 1. +gateway_for() { # 10.10.20.8/20 -> 10.10.16.1 + addr=${1%/*}; plen=${1#*/} + IFS=. read -r a b c d <> 24 & 255 )).$(( gw >> 16 & 255 )).$(( gw >> 8 & 255 )).$(( gw & 255 ))" +} + +if [ "${1:-}" = "--print-gateway" ]; then gateway_for "$2"; exit 0; fi + +table=100 +for dev in $(ls /sys/class/net); do + case "$dev" in lo | eth0) continue ;; esac + cidr=$(ip -4 -o addr show dev "$dev" | awk '{print $4}' | head -n 1) + [ -n "$cidr" ] || continue + gw=$(gateway_for "$cidr") + ip route add default via "$gw" dev "$dev" table $table + ip rule add from "${cidr%/*}" lookup $table + echo "entrypoint: replies from ${cidr%/*} leave through $dev via $gw" + table=$((table + 1)) +done + mkdir -p /run/dbus rm -f /run/dbus/pid /run/avahi-daemon/pid dbus-daemon --system --fork diff --git a/test/node/pod.yaml b/test/node/pod.yaml index 2f7daa6..2c77498 100644 --- a/test/node/pod.yaml +++ b/test/node/pod.yaml @@ -18,6 +18,9 @@ spec: containers: - name: node image: ghcr.io/technotut/moipctl-node-test:main + securityContext: + capabilities: + add: ["NET_ADMIN"] # the entrypoint sets up routing for the VLAN interface ports: - { name: http, containerPort: 8000 } readinessProbe: @@ -36,6 +39,9 @@ spec: containers: - name: node image: ghcr.io/technotut/moipctl-node-test:main + securityContext: + capabilities: + add: ["NET_ADMIN"] # the entrypoint sets up routing for the VLAN interface ports: - { name: http, containerPort: 8000 } readinessProbe: