Skip to content

eBPF-based security platform

testing: run the keepalive pipeline end to end on fresh nodes

John Fastabend31557cbbb3fa
diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.md
index 4ba812e4..4333e9c2 100644
--- a/.agents/skills/testing/SKILL.md
+++ b/.agents/skills/testing/SKILL.md
@@ -26,15 +26,19 @@ make -C testing help
The end2end tier runs t9107 against the keepalive backend that
`BACKEND_DIR` names, a checkout or a git URL, `../backend` by default;
-without one t9107 skips, so say so when reporting the tier. The tier
-boots two VMs at once, each with its own swtpm: node A runs the tests,
-node B (`make -C testing vm-node-end2end`, node mode of `vm/run.sh`)
-takes `role=core` from `config-core` and waits; a test in node A reaches
-it with `node_b` of `testing/end2end/node-b-lib.sh`. Node B's boot log is
-`build/test-vm/end2end/node-b.log`, its state
-`build/test-vm/vms/<name>-end2end-b/`. Both nodes declare the image of
-`testing/vm/files/end2end.os-release` without a root hash, so the
-backend binds them `declared`.
+without one t9107 skips and t9109 does not run, so say so when reporting
+the tier. The tier boots two VMs at once, each with its own swtpm: node A
+runs the tests, node B (`make -C testing vm-node-end2end`, node mode of
+`vm/run.sh`) takes `role=core` from `config-core` and waits. With a
+backend, a fresh edge node (`END2END_NODE=edge`, `role=edge` from
+`config-edge`) boots once node A has stopped, and `host.sh` runs t9109
+on the host against it and node B; its output is
+`build/test-vm/end2end/t9109.log`. A test reaches the nodes with
+`node_sh b` or `node_sh edge` of `testing/end2end/node-lib.sh`. Their boot
+logs are `build/test-vm/end2end/node-b.log` and `node-edge.log`, their
+state `build/test-vm/vms/<name>-end2end-b/` and `-edge/`. Every node
+declares the image of `testing/vm/files/end2end.os-release` without a
+root hash, so the backend binds them `declared`.
Host tests run as they are. A target test, `t?1??`, runs in a fresh VM
per family, which needs KVM, an unlimited `ulimit -l`, the test kernel
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index 12b7d370..53d00e76 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -96,8 +96,8 @@ signed config image.
``--dry-run`` plan
* - ``t1007-test-vm-cli``
- Test VM scripts: kernel selection, host dependencies, arm64
- boot settings, the bundle stamp, node mode only for the second
- end-to-end node
+ boot settings, the bundle stamp, node mode only for a core or
+ edge node of the end-to-end tier
* - ``t1008-kernel-ami-config``
- The slim kernel configuration for NitroTPM CRB, EC2, EFI and SSM
* - ``t1009-upatch-isa``
@@ -625,6 +625,15 @@ signed config image.
``node_status`` gives the example's results; a body altered in
transit is ``body_mismatch``, a replayed record collapses and an
older one does not become the latest
+ * - ``t9109-pipeline``
+ - The whole keepalive pipeline on a fresh edge node and node B, run
+ by ``host.sh`` on the host: ``bpm build`` and ``bpm tree append``
+ of an upatch with ``fixes``, tree sync on both nodes, quoted
+ keepalives through the backend's collector and checker, its tree
+ ingest and sbom-scan jobs, ``node_status`` with the masks ``VA==``
+ and ``qA==``, each node's records against the backend's rows,
+ every SBOM state, ``node_vulns`` exposure and a body altered in
+ transit
Unit suites and fuzz targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -785,7 +794,7 @@ Coverage by area
* - upatch tree
- ``t3011``, ``t5004``, ``t7005``, ``t7007``, ``t7008``, ``t7101``,
``t7102``, ``t7103``, ``t7104``, ``t7105``, ``t7106``,
- ``t7107``, ``t7109``, ``t9105``. Fuzz: ``tree``,
+ ``t7107``, ``t7109``, ``t9105``, ``t9109``. Fuzz: ``tree``,
``tree-state``, ``kconfig``. Unit: ``bpm_tree``,
``bpm_tree_overlap``, ``bpm_tree_state``, ``kernel_build_id``,
``kernel_release``
@@ -796,7 +805,7 @@ Coverage by area
* - Telemetry
- ``t4006``, ``t4104``, ``t6139``, ``t7109``, ``t8001`` to
``t8007``, ``t8101`` to ``t8106``, ``t9101`` to ``t9105``,
- ``t9107``. Fuzz: ``otel``, ``quote-check``, ``serializer``.
+ ``t9107``, ``t9109``. Fuzz: ``otel``, ``quote-check``, ``serializer``.
Unit: ``keepalive``, ``keepalive_quote``, ``sysinfo``
* - Decoders
- ``t3002``, ``t8102``, ``t9101``. Fuzz: ``decoder``
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 41924257..45ab511c 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -170,6 +170,11 @@ a Python companion with the same stem, such as
before ``init``. They skip on the build host and run in a separate VM
that the ``tpm`` family boots without the production initrd.
+``t9109`` carries a target number but runs on the host:
+:src:`testing/end2end/host.sh` runs it after node A's suite, against two
+other nodes (see :ref:`testing-two-nodes`), and node A's runner leaves it
+out.
+
Run the tests
-------------
@@ -606,9 +611,9 @@ Run the end-to-end tests
------------------------
``make -C testing end2end`` runs ``t9001`` on the host, then
-:src:`testing/end2end/host.sh` plays the operator around two VMs, node A,
-which runs the target tests, and node B beside it (see
-:ref:`testing-two-nodes`). It starts
+:src:`testing/end2end/host.sh` plays the operator around node A, which
+runs the target tests, node B beside it, and with a keepalive backend a
+fresh edge node after node A (see :ref:`testing-two-nodes`). It starts
an OCI registry, an OpenTelemetry Collector and ClickHouse in Docker
containers pinned by digest. The registry and collector use a throwaway
CA. It builds ``kernel-obs`` into a package with ``bpm build``, pushes
@@ -651,8 +656,10 @@ the example tree of :src:`testing/fixtures/keepalive/` signed with the
operator key and loads it with the backend's tree ingest job, which runs
``bpm tree show``. In the guest, ``t9107`` sends the example keepalives
with their recorded quotes through that collector and queries
-ClickHouse, both through QEMU's address for the host. Without
-``BACKEND_DIR`` and without ``../backend``, ``t9107`` skips:
+ClickHouse, both through QEMU's address for the host. After node A,
+``host.sh`` runs ``t9109`` against the same backend, see
+:ref:`testing-pipeline`. Without ``BACKEND_DIR`` and without
+``../backend``, ``t9107`` skips and ``t9109`` does not run:
.. code-block:: console
@@ -660,17 +667,20 @@ ClickHouse, both through QEMU's address for the host. Without
.. _testing-two-nodes:
-The two nodes
-~~~~~~~~~~~~~
-
-The tier boots two targets at once, each with its own software TPM and
-so its own attestation key. Node A is the family's VM, named
-``<name>-end2end``, and runs the target tests in number order. Node B,
-``<name>-end2end-b``, boots beside it with ``make -C testing
-vm-node-end2end``: the runner's node mode prepares it as it prepares node
-A, runs no tests, starts no timers and leaves it running until ``host.sh``
-stops it after node A. Each takes its role from a signed config image, as
-``t9105`` configures node A:
+The nodes
+~~~~~~~~~
+
+The tier boots up to three targets, at most two at once, each with its
+own software TPM and so its own attestation key. Node A is the family's
+VM, named ``<name>-end2end``, and runs the target tests in number order.
+Node B, ``<name>-end2end-b``, boots beside it. With a keepalive backend,
+the fresh edge node, ``<name>-end2end-edge``, boots once node A has
+stopped, and ``t9109`` runs against it and node B. Both boot with ``make
+-C testing vm-node-end2end``, ``END2END_NODE=b`` or ``edge``: the runner's
+node mode prepares a node as it prepares node A, activates the config
+image of its role, runs no tests, starts no timers and leaves it running
+until ``host.sh`` stops it at the end. Each takes its role from a signed
+config image, as ``t9105`` configures node A:
.. list-table::
:header-rows: 1
@@ -687,62 +697,118 @@ stops it after node A. Each takes its role from a signed config image, as
* - ``config-edge``
- ``role=edge``
- The tree ``shirudo/pipeline-tree`` on the test's registry and the
- keepalive backend's collector, for a test that moves node A to
- that tree.
+ keepalive backend's collector. The fresh edge node activates it
+ while it is prepared.
* - ``config-core``
- ``role=core``
- The same as ``config-edge``. Node B activates it while it is
prepared.
-Both nodes declare an image: :src:`testing/vm/files/end2end.os-release`,
+``t9109`` needs a node that has run nothing else. By the time it runs,
+node A has loaded ``kernel-obs`` and ``policy-exec-graph``, counted
+denied execs, and followed ``shirudo/end2end-tree``, none of which a fleet
+node has, and its register and eventlog keep all of it. So the fresh edge
+node takes node A's place rather than node A moving to the pipeline
+tree. Booting it after node A keeps two guests at most.
+
+All nodes declare an image: :src:`testing/vm/files/end2end.os-release`,
``IMAGE_ID=fleet-os`` and ``IMAGE_VERSION=end2end-1``, is added to their
-``/etc/os-release``. Neither binds the image as ``verified``. Their root
-is the stock cloud image in a writable overlay, not a dm-verity image,
-and their kernel command line names no ``roothash=`` or ``usrhash=``, so
-``image_root`` is ``null`` and the keepalive backend binds both nodes as
-``declared``. Giving node A a root hash would mean building its root as a
+``/etc/os-release``. None binds the image as ``verified``. Their root is
+the stock cloud image in a writable overlay, not a dm-verity image, and
+their kernel command line names no ``roothash=`` or ``usrhash=``, so
+``image_root`` is ``null`` and the keepalive backend binds every node as
+``declared``. Giving a node a root hash would mean building its root as a
verity image; the backend's own tests cover ``verified`` and
``root_mismatch`` with rows they insert.
After node A, ``host.sh`` checks node B: its evidence verifies, its
-attestation key differs from node A's, its labels are ``role=core``, and
+attestation key differs from node A's and its labels are ``role=core``.
+It checks that the fresh edge node is labelled ``role=edge``, and that
the keepalive body each node printed while it was prepared, in
``result/keepalive.json`` of its state directory, names the image above
and no root.
-A test in node A reaches node B as root over SSH through
-:src:`testing/end2end/node-b-lib.sh`. ``node_b_wait`` waits for node B to
-be prepared and fails when it did not boot; ``node_b`` runs a command line
-in node B's shell, with the test's standard input and output:
+A test reaches node B and the fresh edge node as root over SSH through
+:src:`testing/end2end/node-lib.sh`, by the names ``b`` and ``edge``.
+``node_wait`` waits for a node to be prepared and fails when it did not
+boot; ``node_sh`` runs a command line in its shell, with the test's
+standard input and output:
.. code-block:: sh
- . ./end2end/node-b-lib.sh
- node_b_wait || test_skip_all "node B did not boot"
- node_b /usr/local/bin/shirudo-runtime status --keepalive >"$W/node-b.json"
- node_b cat /var/lib/shirudo/bpm/upatch-tree/state.json
- node_b "cat >/etc/shirudo/end2end-ca.pem" <"$E2E/ca.pem"
-
-``host.sh`` records the SSH port and key in
-``build/test-vm/end2end/node-b/``, which node A reads through the
-read-only checkout. Node B reaches the registry and the collectors through
-QEMU's address for the host, as node A does, and has the checkout at
-``/workspace/shirudo`` too. A tree at ``127.0.0.1:15443`` names its
-packages there, so a test that syncs node B starts
-``end2end/tcp_forward.py`` in it, as ``t9105`` does in node A, detached
-from the SSH session:
+ . ./end2end/node-lib.sh
+ node_wait b || test_skip_all "node B did not boot"
+ node_sh b /usr/local/bin/shirudo-runtime status --keepalive >"$W/node-b.json"
+ node_sh b cat /var/lib/shirudo/bpm/upatch-tree/state.json
+ node_sh b "cat >/etc/shirudo/end2end-ca.pem" <"$E2E/ca.pem"
+
+``host.sh`` records each node's SSH port and key in
+``build/test-vm/end2end/node-b/`` and ``node-edge/``, which node A reads
+through the read-only checkout; on the host, ``NODES_DIR`` names that
+directory and ``NODES_HOST`` is ``127.0.0.1``. The nodes reach the
+registry and the collectors through QEMU's address for the host, as node
+A does, and have the checkout at ``/workspace/shirudo`` too. A tree at
+``127.0.0.1:15443`` names its packages there, so a test that syncs a node
+starts ``end2end/tcp_forward.py`` in it, as ``t9105`` does in node A,
+detached from the SSH session:
.. code-block:: sh
- node_b "cd /workspace/shirudo/testing &&
- python3 end2end/tcp_forward.py 127.0.0.1:15443 10.0.2.2:15443 \
- /tmp/forward-ready </dev/null >/dev/null 2>&1 &"
-
-Node B has 2 CPUs and ``TEST_VM_NODE_MEMORY``, ``2G`` by default; node A
-keeps ``TEST_VM_CPUS`` and ``TEST_VM_MEMORY``. With the defaults the
-guests take 6 GiB of host memory, and the registry, the two collectors
-and the two ClickHouse servers come on top. ``host.sh`` prints node B's
-memory use, and its boot log is ``build/test-vm/end2end/node-b.log``.
+ node_sh b "cd /workspace/shirudo/testing &&
+ setsid -f python3 end2end/tcp_forward.py 127.0.0.1:15443 \
+ 10.0.2.2:15443 /tmp/forward-ready </dev/null >/dev/null 2>&1"
+
+The other nodes have 2 CPUs and ``TEST_VM_NODE_MEMORY``, ``2G`` by
+default; node A keeps ``TEST_VM_CPUS`` and ``TEST_VM_MEMORY``. With the
+defaults the guests take 6 GiB of host memory at most, while node A and
+node B run, and the registry, the two collectors and the two ClickHouse
+servers come on top. ``host.sh`` prints each node's memory use, and their
+boot logs are ``build/test-vm/end2end/node-b.log`` and
+``node-edge.log``.
+
+.. _testing-pipeline:
+
+The full chain
+~~~~~~~~~~~~~~
+
+``t9109`` runs the whole keepalive pipeline on real data, with no
+fixture at a seam between two stages. ``host.sh`` runs it on the host as
+root, after node A, with ``E2E``, the backend directory, the operator key
+and the nodes' directory in its environment; its output is
+``build/test-vm/end2end/t9109.log``. It:
+
+#. empties the keepalive backend that ``t9107`` used and loads its
+ schema again;
+#. builds ``xfs-fix`` 1.0.0 and 1.1.0 from
+ :src:`testing/fixtures/pipeline/xfs-fix/`, whose Beefile names
+ ``fixes = ["EXAMPLE-0101"]`` and selects ``role=edge``, and appends
+ add 1.0.0, delete 1.0.0 and add 1.1.0 to ``shirudo/pipeline-tree``;
+#. loads the publication with the backend's tree ingest job;
+#. syncs the fresh edge node, which applies all three operations, and
+ node B, which passes over all three, with ``shirudo-bpm-tree-sync``,
+ and sends two keepalives from each a few seconds apart with
+ ``shirudo-keepalive``;
+#. writes the SBOM store of the nodes' image, and one image for each
+ other state of an SBOM, and runs the backend's sbom-scan job with the
+ stub ``trivy`` of the fixtures, which prints one ``openssl`` finding;
+#. seeds the kernel advisory of the fixtures, whose range holds every test
+ kernel, and the nodes' build, and refreshes ``node_status`` and
+ ``node_vulns``.
+
+It then checks the tree, the stored records and their quotes,
+``node_status`` with the masks ``VA==`` and ``qA==``, each node's
+``state.json``, ``outcomes``, ``tree-eventlog`` and loaded set against
+the backend's rows, the state of every SBOM, and the exposure of each
+node: the kernel advisory ``shielded`` by ``xfs-fix`` on the edge node and
+``shield_excludes_node`` on node B, and the ``openssl`` finding
+``exposed_no_shield`` on both. A record replayed through the collector
+with one byte of its body changed lands in ``rejected`` as
+``body_mismatch`` and changes no row of ``node_status``.
+
+``t9109`` takes nothing from :src:`testing/fixtures/keepalive/`.
+:src:`testing/end2end/pipeline_checks.py` recomputes the roots, the mask,
+the loaded set and each quote's qualifying data from the formats' own
+definitions.
Select test scripts
~~~~~~~~~~~~~~~~~~~
diff --git a/testing/Makefile b/testing/Makefile
index 7a780913..81a0d70c 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -315,11 +315,15 @@ end2end: build-operator
MAKE="$(MAKE)" \
$(ROOT)/testing/end2end/host.sh $(MAKE) -C $(ROOT)/testing vm-test-end2end)
-# Node B of the end-to-end run, which end2end/host.sh boots beside the
-# suite's VM and stops after it: prepared like that VM, but it runs no
-# tests and stays up until it is stopped.
+# A node of the end-to-end run that end2end/host.sh boots and stops,
+# prepared like the suite's VM, but it runs no tests and stays up until it
+# is stopped. END2END_NODE=b is node B, with the core role, beside the
+# suite's VM; edge is a fresh node with the edge role, after it.
+END2END_NODE ?= b
vm-node-end2end: $(VM_KERNEL_DEP) test-vm-bundle
- $(Q)$(call run-target-vm,end2end,$(if $(VM_NAME),$(VM_NAME)-end2end-b),1,node)
+ $(Q)$(if $(filter-out b edge,$(END2END_NODE)),$(error END2END_NODE must be b or edge))
+ $(Q)TEST_VM_NODE_ROLE=$(if $(filter edge,$(END2END_NODE)),edge,core) \
+ $(call run-target-vm,end2end,$(if $(VM_NAME),$(VM_NAME)-end2end-$(END2END_NODE)),1,node)
vm-test-tpm: vm-test-register
diff --git a/testing/end2end/host.sh b/testing/end2end/host.sh
index cab2df33..3b196ffe 100755
--- a/testing/end2end/host.sh
+++ b/testing/end2end/host.sh
@@ -3,7 +3,9 @@
# Copyright (c) 2026 Authors of shirudo
# testing/end2end/host.sh -- run the operator side of the end-to-end VM test.
# Its arguments are the command that runs the suite in node A; node B, a
-# second target with a TPM of its own, boots beside it.
+# second target with a TPM of its own, boots beside it. After node A, a
+# fresh edge node boots in its place and t9109 runs here against it and
+# node B.
set -eu
@@ -31,48 +33,70 @@ RESULT=$REPO/build/test-vm/vms/$VM_NAME-end2end/result/end2end
POLICY_FIXTURE=$TEST_VM_HOST_BUNDLE/fixtures/shirudo-test-policy-exec-graph.upatch
CHECKER=$REPO/tools/quote-check/shirudo-quote-check
KEEPALIVE=$REPO/testing/fixtures/keepalive
-NODE_B_DIR=$W/node-b
-NODE_B_HOST=127.0.0.1
-NODE_B_VM=$VM_NAME-end2end-b
-NODE_B_RUN=$REPO/build/test-vm/vms/$NODE_B_VM
+NODES_DIR=$W
+NODES_HOST=127.0.0.1
NODE_B_PID=
-. "$REPO/testing/end2end/node-b-lib.sh"
+NODE_EDGE_PID=
+. "$REPO/testing/end2end/node-lib.sh"
say() { printf 'end2end: %s\n' "$*"; }
die() { printf 'end2end: %s\n' "$*" >&2; exit 1; }
down() {
- node_b_down
+ node_down edge "$NODE_EDGE_PID"
+ NODE_EDGE_PID=
+ node_down b "$NODE_B_PID"
+ NODE_B_PID=
stack_down
rm -rf -- "$TLS_DIR"
}
-# Boot node B beside node A, prepared like it but with the core role and no
-# tests, and record in $NODE_B_DIR how to reach it.
-node_b_boot() {
- mkdir -p "$NODE_B_DIR"
- if "${MAKE:-make}" -C "$REPO/testing" vm-node-end2end TEST_VM_CPUS=2 \
- TEST_VM_MEMORY="${TEST_VM_NODE_MEMORY:-2G}" >"$W/node-b.log" 2>&1 &&
- cp "$NODE_B_RUN/ssh.port" "$NODE_B_DIR/port" &&
- install -m 0600 "$NODE_B_RUN/ssh/id_ed25519" "$NODE_B_DIR/key"; then
- : >"$NODE_B_DIR/ready"
+# The state directory of node $1's VM.
+node_run_dir() {
+ printf '%s/build/test-vm/vms/%s-end2end-%s\n' "$REPO" "$VM_NAME" "$1"
+}
+
+# Boot node $1, b with the core role or edge with the edge role, prepared
+# like node A but without tests, and record in $NODES_DIR/node-$1 how to
+# reach it.
+node_boot() {
+ run=$(node_run_dir "$1")
+ mkdir -p "$NODES_DIR/node-$1"
+ if "${MAKE:-make}" -C "$REPO/testing" vm-node-end2end END2END_NODE="$1" \
+ TEST_VM_CPUS=2 TEST_VM_MEMORY="${TEST_VM_NODE_MEMORY:-2G}" \
+ >"$W/node-$1.log" 2>&1 &&
+ cp "$run/ssh.port" "$NODES_DIR/node-$1/port" &&
+ install -m 0600 "$run/ssh/id_ed25519" "$NODES_DIR/node-$1/key"; then
+ : >"$NODES_DIR/node-$1/ready"
else
- : >"$NODE_B_DIR/failed"
+ : >"$NODES_DIR/node-$1/failed"
fi
}
-# Stop node B. A boot still under way ends when its VM stops, or comes up
-# after the first stop and meets the second.
-node_b_down() {
- node_b_stop
- [ -z "$NODE_B_PID" ] || wait "$NODE_B_PID" || :
- NODE_B_PID=
- node_b_stop
+# Stop node $1, whose boot runs as process $2 if it is still under way. A
+# boot under way ends when its VM stops, or comes up after the first stop
+# and meets the second.
+node_down() {
+ node_stop "$1"
+ [ -z "$2" ] || wait "$2" || :
+ node_stop "$1"
+}
+
+node_stop() {
+ [ ! -d "$(node_run_dir "$1")" ] ||
+ VM_NAME=$VM_NAME-end2end-$1 "$REPO/testing/vm/run.sh" --stop \
+ >/dev/null 2>&1 || :
}
-node_b_stop() {
- [ ! -d "$NODE_B_RUN" ] ||
- VM_NAME=$NODE_B_VM "$REPO/testing/vm/run.sh" --stop >/dev/null 2>&1 || :
+# Print the memory node $1 used, and remove the disks of its stopped VM.
+node_clean() {
+ run=$(node_run_dir "$1")
+ for report in boot-memory host-memory; do
+ [ ! -s "$run/result/$report" ] ||
+ say "node $1 $report: $(tr '\n' ' ' <"$run/result/$report")"
+ done
+ rm -rf -- "$run/rootfs.qcow2" "$run/initrd.img" "$run/seed.img" \
+ "$run/initrd-seed"
}
# Check the keepalive body that node $1 printed at boot, file $2: the image
@@ -235,11 +259,18 @@ else
say "no keepalive backend at ../backend and no BACKEND_DIR: t9107 skips"
fi
-say "node A, in $VM_NAME-end2end, and node B, in $NODE_B_VM"
-node_b_boot &
+say "node A, in $VM_NAME-end2end, and node B, in $VM_NAME-end2end-b"
+node_boot b &
NODE_B_PID=$!
"$@"
+# The fresh edge node takes node A's place, so that two guests run at most.
+if [ -s "$W/backend-tree.digest" ]; then
+ say "the fresh edge node, in $VM_NAME-end2end-edge"
+ node_boot edge &
+ NODE_EDGE_PID=$!
+fi
+
say "the evidence verifies and records what was published"
[ -s "$RESULT/evidence.json" ] || die "the target left no evidence in $RESULT"
ak=$(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["ak"]["name"])' \
@@ -300,11 +331,11 @@ python3 "$REPO/testing/end2end/check-otlp.py" \
say "node B booted with an attestation key and a role of its own"
wait "$NODE_B_PID" || :
NODE_B_PID=
-node_b_wait 0 || {
+node_wait b 0 || {
tail -n 40 "$W/node-b.log" >&2
die "node B did not boot; see $W/node-b.log"
}
-node_b "/usr/local/bin/shirudo-runtime attest --nonce=$(cat "$W/nonce")" \
+node_sh b "/usr/local/bin/shirudo-runtime attest --nonce=$(cat "$W/nonce")" \
>"$W/node-b-evidence.json" || die "node B gave no evidence"
# Node B loads nothing of its own: a test gives it only what a tree holds.
ak_b=$(python3 -c 'import json, sys
@@ -320,17 +351,35 @@ print(evidence["ak"]["name"])' "$W/node-b-evidence.json") ||
die "the evidence of node B does not verify"
}
[ "$ak_b" != "$ak" ] || die "node A and node B share an attestation key"
-[ "$(node_b cat /run/shirudo/config/etc/shirudo/node.labels)" = role=core ] ||
+[ "$(node_sh b cat /run/shirudo/config/etc/shirudo/node.labels)" = role=core ] ||
die "node B is not labelled role=core"
image_identity A "$REPO/build/test-vm/vms/$VM_NAME-end2end/result/keepalive.json"
-image_identity B "$NODE_B_RUN/result/keepalive.json" \
+image_identity B "$(node_run_dir b)/result/keepalive.json" \
"$(cat "$TEST_VM_HOST_BUNDLE/verity/config-core.root")"
-for report in boot-memory host-memory; do
- [ ! -s "$NODE_B_RUN/result/$report" ] ||
- say "node B $report: $(tr '\n' ' ' <"$NODE_B_RUN/result/$report")"
-done
-node_b_down
-rm -rf -- "$NODE_B_RUN/rootfs.qcow2" "$NODE_B_RUN/initrd.img" \
- "$NODE_B_RUN/seed.img" "$NODE_B_RUN/initrd-seed"
+
+if [ -n "$NODE_EDGE_PID" ]; then
+ wait "$NODE_EDGE_PID" || :
+ NODE_EDGE_PID=
+ node_wait edge 0 || {
+ tail -n 40 "$W/node-edge.log" >&2
+ die "the fresh edge node did not boot; see $W/node-edge.log"
+ }
+ [ "$(node_sh edge cat /run/shirudo/config/etc/shirudo/node.labels)" = role=edge ] ||
+ die "the fresh edge node is not labelled role=edge"
+ image_identity edge "$(node_run_dir edge)/result/keepalive.json" \
+ "$(cat "$TEST_VM_HOST_BUNDLE/verity/config-edge.root")"
+ say "t9109, on the host, against the fresh edge node and node B"
+ rc=0
+ (cd testing && E2E=$W END2END_BACKEND=$BACKEND END2END_KEYS=$KEYS \
+ NODES_DIR=$NODES_DIR NODES_HOST=$NODES_HOST \
+ sh end2end/t9109-pipeline.sh) >"$W/t9109.log" 2>&1 || rc=$?
+ cat "$W/t9109.log"
+ [ "$rc" -eq 0 ] || die "t9109 failed; see $W/t9109.log"
+ ! grep -q '^1\.\.0 # SKIP' "$W/t9109.log" || die "t9109 was skipped"
+ node_down edge ""
+ node_clean edge
+fi
+node_down b ""
+node_clean b
say "ok"
diff --git a/testing/end2end/node-b-lib.sh b/testing/end2end/node-b-lib.sh
deleted file mode 100644
index 0256b071..00000000
--- a/testing/end2end/node-b-lib.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: BSD-2-Clause
-# Copyright (c) 2026 Authors of shirudo
-#
-# testing/end2end/node-b-lib.sh -- reach node B, the second target that
-# end2end/host.sh boots beside the suite's VM, as root over SSH. A test in
-# node A sources it as it is; host.sh sets NODE_B_DIR and NODE_B_HOST first.
-
-# What host.sh records of node B: port, the host port of its SSH server,
-# key, the key of its root, and ready once it is prepared, else failed.
-: "${NODE_B_DIR:=/mnt/shirudo-src/build/test-vm/end2end/node-b}"
-# Where node B's SSH port is forwarded: QEMU's address for the host, as
-# node A sees it.
-: "${NODE_B_HOST:=10.0.2.2}"
-
-# Wait up to $1 seconds, 600 by default, for node B to be prepared. Fails
-# at once when it did not boot.
-node_b_wait() {
- node_b_tries=0
- until [ -e "$NODE_B_DIR/ready" ]; do
- [ ! -e "$NODE_B_DIR/failed" ] || return 1
- node_b_tries=$((node_b_tries + 1))
- [ "$node_b_tries" -le "${1:-600}" ] || return 1
- sleep 1
- done
-}
-
-# Run the command line $* in node B's root shell, with this standard input
-# and output. The words are joined and parsed again there, as by ssh.
-node_b() {
- ssh -F /dev/null -i "$NODE_B_DIR/key" -o IdentitiesOnly=yes \
- -o BatchMode=yes -o ConnectTimeout=10 -o LogLevel=ERROR \
- -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
- -p "$(cat "$NODE_B_DIR/port")" "root@$NODE_B_HOST" "$@"
-}
diff --git a/testing/end2end/node-lib.sh b/testing/end2end/node-lib.sh
new file mode 100644
index 00000000..bb576487
--- /dev/null
+++ b/testing/end2end/node-lib.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# testing/end2end/node-lib.sh -- reach the other nodes of the end-to-end
+# tier as root over SSH: node B (b), which end2end/host.sh boots beside the
+# suite's VM, and the fresh edge node (edge), which it boots after. A test
+# in node A sources it as it is; on the host, NODES_DIR and NODES_HOST are
+# set first.
+
+# Where host.sh records each node, in node-<name>/: port, the host port of
+# its SSH server, key, the key of its root, and ready once it is
+# prepared, else failed.
+: "${NODES_DIR:=/mnt/shirudo-src/build/test-vm/end2end}"
+# Where the nodes' SSH ports are forwarded: QEMU's address for the host,
+# as node A sees it.
+: "${NODES_HOST:=10.0.2.2}"
+
+# Wait up to $2 seconds, 600 by default, for node $1 to be prepared.
+# Fails at once when it did not boot.
+node_wait() {
+ node_tries=0
+ until [ -e "$NODES_DIR/node-$1/ready" ]; do
+ [ ! -e "$NODES_DIR/node-$1/failed" ] || return 1
+ node_tries=$((node_tries + 1))
+ [ "$node_tries" -le "${2:-600}" ] || return 1
+ sleep 1
+ done
+}
+
+# Run the command line ${2...} in node $1's root shell, with this standard
+# input and output. The words are joined and parsed again there, as by ssh.
+node_sh() {
+ node_dir=$NODES_DIR/node-$1
+ shift
+ ssh -F /dev/null -i "$node_dir/key" -o IdentitiesOnly=yes \
+ -o BatchMode=yes -o ConnectTimeout=10 -o LogLevel=ERROR \
+ -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
+ -p "$(cat "$node_dir/port")" "root@$NODES_HOST" "$@"
+}
diff --git a/testing/end2end/pipeline_checks.py b/testing/end2end/pipeline_checks.py
new file mode 100644
index 00000000..fe623072
--- /dev/null
+++ b/testing/end2end/pipeline_checks.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+"""What t9109 recomputes from a node's records and the backend's rows, each
+from the format's own definition, so that neither side is taken on trust."""
+
+import base64
+import hashlib
+import json
+import sys
+
+ZERO = bytes(32)
+HISTORY_TAG = b"shirudo-tree-history\0"
+
+
+def hexdigest(value):
+ return value.removeprefix("sha256:")
+
+
+def lines(path):
+ with open(path, encoding="utf-8") as f:
+ return [json.loads(line) for line in f if line.strip()]
+
+
+def roots(digests):
+ """projection_root with every operation applied, and history_root."""
+ projection = history = ZERO
+ for digest in digests:
+ raw = bytes.fromhex(hexdigest(digest))
+ projection = hashlib.sha256(projection + raw).digest()
+ history = hashlib.sha256(HISTORY_TAG + history + raw).digest()
+ return projection.hex(), history.hex()
+
+
+def mask(outcomes, head_seq):
+ """The keepalive mask of a node whose window starts at seq 1."""
+ codes = {line["seq"]: line["outcome"] for line in outcomes}
+ pairs = [codes.get(seq, 0) for seq in range(1, head_seq + 1)]
+ raw = bytearray((len(pairs) + 3) // 4)
+ for i, code in enumerate(pairs):
+ raw[i // 4] |= code << (6 - 2 * (i % 4))
+ return base64.b64encode(bytes(raw)).decode()
+
+
+def loaded_set(upatch_list):
+ """set_sha256 over the loaded upatches of `upatch list --json`."""
+ with open(upatch_list, encoding="utf-8") as f:
+ upatches = json.load(f)["upatches"]
+ loaded = sorted((u["name"], u["payload_sha256"]) for u in upatches
+ if u["loaded"] and u.get("type") == "load")
+ text = "".join(f"{payload} {name}\n" for name, payload in loaded)
+ return hashlib.sha256(text.encode()).hexdigest()
+
+
+def quote_extra(quote):
+ """The qualifying data of the TPMS_ATTEST in a shirudo.quote value."""
+ fields = dict(part.split("=", 1) for part in quote.split(";"))
+ attest = base64.b64decode(fields["attest"])
+ offset = 6
+ signer = int.from_bytes(attest[offset:offset + 2], "big")
+ offset += 2 + signer
+ size = int.from_bytes(attest[offset:offset + 2], "big")
+ return attest[offset + 2:offset + 2 + size].hex()
+
+
+def node(state_path, outcomes_path, eventlog_path):
+ """A node's view: its roots, its mask, and the digests it chained."""
+ with open(state_path, encoding="utf-8") as f:
+ state = json.load(f)
+ outcomes = lines(outcomes_path)
+ seqs = [line["seq"] for line in outcomes]
+ assert seqs == list(range(1, state["last_seq"] + 1)), seqs
+ return {
+ "last_seq": state["last_seq"],
+ "generation": state["generation"],
+ "projection_root": hexdigest(state["projection_root"]),
+ "outcomes": [line["outcome"] for line in outcomes],
+ "history_root": hexdigest(outcomes[-1]["history_root"]),
+ "outcome_root": hexdigest(outcomes[-1]["projection_root"]),
+ "mask": mask(outcomes, state["head_seq"]),
+ "chained": [hexdigest(line["digest"]) for line in lines(eventlog_path)],
+ }
+
+
+def main():
+ command, args = sys.argv[1], sys.argv[2:]
+ if command == "roots":
+ print(*roots(args))
+ elif command == "node":
+ print(json.dumps(node(*args), sort_keys=True))
+ elif command == "set":
+ print(loaded_set(args[0]))
+ elif command == "quotes":
+ # Every stored record: its body's SHA-256 is what the TPM quoted.
+ for record in lines(args[0]):
+ body = hashlib.sha256(record["body"].encode()).hexdigest()
+ assert quote_extra(record["quote"]) == body, record["clock"]
+ print(record["ak_name"], record["clock"])
+ elif command == "replay":
+ # The newest stored record of a node with one byte of its body
+ # changed: its quote in $2, the body in $3.
+ record = max(lines(args[0]), key=lambda r: r["clock"])
+ body = bytearray(record["body"].encode())
+ at = body.index(b'"boot_id":"') + len(b'"boot_id":"')
+ body[at] = ord("0") if body[at] != ord("0") else ord("1")
+ with open(args[1], "w", encoding="ascii") as f:
+ f.write(record["quote"])
+ with open(args[2], "wb") as f:
+ f.write(body)
+ else:
+ raise SystemExit(f"pipeline_checks.py: no command {command}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/testing/end2end/t9109-pipeline.sh b/testing/end2end/t9109-pipeline.sh
new file mode 100755
index 00000000..10150d88
--- /dev/null
+++ b/testing/end2end/t9109-pipeline.sh
@@ -0,0 +1,399 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# t9109 -- the whole keepalive pipeline on real data, with no fixture at a
+# seam. The operator builds xfs-fix 1.0.0 and 1.1.0 and appends add,
+# delete and add to a tree; the fresh edge node (role=edge) and node B
+# (role=core) sync it and send quoted keepalives through the backend's
+# collector; the backend's tree ingest and sbom-scan jobs load the tree
+# and the SBOM of the nodes' image; and node_status and node_vulns give
+# each node's health and exposure. A body altered in transit is refused.
+#
+# end2end/host.sh runs it on the host after node A's suite, as root, with
+# the keepalive backend it started, the operator key and the two nodes.
+# Both nodes run the stock cloud image, so they bind it as declared.
+
+cd "$(dirname "$0")/.."
+. ./test-lib.sh
+
+REPO=$(cd .. && pwd)
+E2E=${E2E:-$REPO/build/test-vm/end2end}
+FIX=$PWD/fixtures/pipeline
+S=$REPO/shirudo
+H=$PWD/helper/test-otel-map
+CHECKS=$PWD/end2end/pipeline_checks.py
+REGISTRY=${REGISTRY:-127.0.0.1:15443}
+COLLECTOR=${BACKEND_COLLECTOR:-127.0.0.1:14320}
+STACK_NAME=${STACK_NAME:-shirudo-end2end}
+TREE=oci://$REGISTRY/shirudo/pipeline-tree
+RUNTIME=/usr/local/bin/shirudo-runtime
+STATE=/var/lib/shirudo/bpm/upatch-tree
+CLICKHOUSE_CLIENT="docker exec -i $STACK_NAME-backend-clickhouse clickhouse-client"
+export CLICKHOUSE_CLIENT
+
+[ -n "${END2END_BACKEND-}" ] && [ -n "${END2END_KEYS-}" ] ||
+ test_skip_all "end2end/host.sh runs it after node A's suite, with a keepalive backend"
+BACKEND=$END2END_BACKEND
+KEYS=$END2END_KEYS
+command -v docker >/dev/null 2>&1 || test_skip_all "no docker"
+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
+[ -x "$H" ] || test_skip_all "test-otel-map helper not built"
+[ -s "$E2E/ca.pem" ] || test_skip_all "no registry and collector CA in $E2E"
+. ./vm/stack-lib.sh
+. ./end2end/node-lib.sh
+node_wait edge 0 && node_wait b 0 ||
+ test_skip_all "the fresh edge node and node B are not up"
+W=$(mktemp -d)
+trap 'rm -rf "$W"' EXIT
+
+# Run the query $1 on the backend's ClickHouse and print its result.
+ch() {
+ stack_backend_client --query "$1" </dev/null
+}
+
+# Wait up to 60 seconds for the query $1 to print $2.
+ch_wait() {
+ i=0
+ until [ "$(ch "$1")" = "$2" ]; do
+ i=$((i + 1))
+ [ "$i" -lt 120 ] || return 1
+ sleep 0.5
+ done
+}
+
+# Compare the query $1's result with file $2.
+ch_cmp() {
+ ch "$1" >"$2.out" && diff -u "$2" "$2.out" >&2
+}
+
+refresh() {
+ for view in node_status_mv node_vulns_mv; do
+ ch "SYSTEM REFRESH VIEW shirudo.$view" &&
+ ch "SYSTEM WAIT VIEW shirudo.$view" || return 1
+ done
+}
+
+# Run the command line ${2...} as root in node $1, edge or b, with no
+# standard input.
+on() {
+ node_sh "$@" </dev/null
+}
+
+# Start the unit $2 in node $1 and wait for it; its journal is what a
+# failure needs.
+unit_ok() {
+ on "$1" "systemctl start $2 ||
+ { journalctl -u $2 --no-pager | tail -n 30 >&2; exit 1; }"
+}
+
+# Copy node $1's tree records to $W/<name>-$1, and print its view of them.
+# A node that applied nothing has no tree-eventlog.
+node_view() {
+ on "$1" cat "$STATE/state.json" >"$W/state.json-$1" &&
+ on "$1" cat "$STATE/outcomes" >"$W/outcomes-$1" &&
+ on "$1" "[ ! -e $STATE/tree-eventlog ] || cat $STATE/tree-eventlog" \
+ >"$W/tree-eventlog-$1" || return 1
+ python3 "$CHECKS" node "$W/state.json-$1" "$W/outcomes-$1" \
+ "$W/tree-eventlog-$1"
+}
+
+# The attestation key name of node $1, found by its boot_id in the records.
+ak() {
+ cat "$W/ak-$1"
+}
+
+# The payload_sha256 of the upatch xfs-fix in the package of release $1.
+payload() {
+ tar -xzf "$W/pkg/$1/xfs-fix-$1.bee" -C "$W/pkg/$1" &&
+ "$S" upatch info --json "$W/pkg/$1/xfs-fix-$1/upatches/xfs-fix.upatch" |
+ python3 -c 'import json, sys; print(json.load(sys.stdin)["payload_sha256"])'
+}
+
+# Print the rows of node_status, the age of the record aside.
+status_rows() {
+ ch "SELECT ak_name, status, trust, failed_check,
+ arrayMap(l -> replaceRegexpOne(l, 'last record -?[0-9]+ s ago', 'last record'), log),
+ last_seen, generation, last_seq, head_seq, loaded, set_sha256
+ FROM shirudo.node_status ORDER BY ak_name"
+}
+
+Q_KEEPALIVE="SELECT ak_name, clock, quote, body FROM shirudo.keepalive FINAL
+ ORDER BY ak_name, clock FORMAT JSONEachRow"
+
+test_expect_success 'the backend starts empty, with its schema loaded' '
+ ch "DROP DATABASE IF EXISTS shirudo SYNC" &&
+ ch "DROP DATABASE IF EXISTS otel SYNC" &&
+ stack_backend_schema "$BACKEND" &&
+ test "$(ch "SELECT count() FROM shirudo.keepalive")" = 0 &&
+ test "$(ch "SELECT count() FROM shirudo.tree_ops")" = 0
+'
+
+# 1.1.0 differs from 1.0.0 in its program name, so that the two payloads
+# differ and the backend has to pick the one the node loaded.
+test_expect_success 'the operator builds xfs-fix 1.0.0 and 1.1.0' '
+ for v in 1.0.0 1.1.0; do
+ mkdir -p "$W/pkg/$v" &&
+ cp -R "$FIX/xfs-fix" "$W/pkg/$v/xfs-fix" &&
+ ln -s "$REPO/vendor" "$W/pkg/$v/xfs-fix/vendor" &&
+ ln -s "$REPO/bpf" "$W/pkg/$v/xfs-fix/bpf" || exit 1
+ done &&
+ sed -i "s/BPF_PROG(xfs_fix)/BPF_PROG(xfs_fix_1_1)/" \
+ "$W/pkg/1.1.0/xfs-fix/xfs-fix.bpf.c" &&
+ for v in 1.0.0 1.1.0; do
+ (cd "$W/pkg/$v" && "$S" bpm build xfs-fix --version "$v" \
+ --keys-dir "$KEYS") >&2 &&
+ payload "$v" >"$W/payload-$v" || exit 1
+ done &&
+ ! cmp -s "$W/payload-1.0.0" "$W/payload-1.1.0"
+'
+
+test_expect_success 'the operator appends add 1.0.0, delete 1.0.0 and add 1.1.0' '
+ "$S" bpm tree append "$W/pkg/1.0.0/xfs-fix-1.0.0.bee" "$TREE" \
+ --keys-dir "$KEYS" --tree-id pipeline >&2 &&
+ "$S" bpm tree append "$W/pkg/1.0.0/xfs-fix-1.0.0.bee" "$TREE" \
+ --keys-dir "$KEYS" --tree-id pipeline --op delete >&2 &&
+ "$S" bpm tree append "$W/pkg/1.1.0/xfs-fix-1.1.0.bee" "$TREE" \
+ --keys-dir "$KEYS" --tree-id pipeline >&2 &&
+ "$S" bpm tree show "$TREE" --cert "$KEYS/cert.der" >"$W/show.json"
+'
+
+test_expect_success 'the ingest job loads the publication with its fixes' '
+ "$BACKEND/jobs/tree-ingest" --shirudo "$S" --cert "$KEYS/cert.der" \
+ "$TREE" >&2 &&
+ test "$(ch "SELECT tree_id, generation, head_seq FROM shirudo.tree_pubs FINAL")" = \
+ "$(printf "pipeline\t3\t3")" &&
+ printf "1\tadd\txfs-fix\n2\tdelete\txfs-fix\n3\tadd\txfs-fix\n" >"$W/ops" &&
+ ch_cmp "SELECT seq, op, id FROM shirudo.tree_ops FINAL
+ WHERE tree_id = '\''pipeline'\'' ORDER BY seq" "$W/ops" &&
+ printf "%s\txfs-fix\tEXAMPLE-0101\tfixes\n" 1 3 >"$W/fixes" &&
+ ch_cmp "SELECT seq, id, advisory, source FROM shirudo.upatch_fixes FINAL
+ ORDER BY seq" "$W/fixes" &&
+ ch "SELECT operation_digest FROM shirudo.tree_ops FINAL
+ WHERE tree_id = '\''pipeline'\'' ORDER BY seq" >"$W/digests" &&
+ python3 -c "import json, sys
+show = json.load(open(sys.argv[1]))
+ops = show[\"document\"][\"operations\"]
+print(\"\\n\".join(op[\"operation_digest\"].removeprefix(\"sha256:\") for op in ops))
+" "$W/show.json" >"$W/published" &&
+ diff -u "$W/published" "$W/digests" >&2
+'
+
+test_expect_success 'both nodes trust the CA and reach the registry' '
+ for n in edge b; do
+ node_sh "$n" "cat >/etc/shirudo/end2end-ca.pem" <"$E2E/ca.pem" &&
+ on "$n" "install -d /etc/shirudo/bpm &&
+ echo BPM_OCI_CA_FILE=/etc/shirudo/end2end-ca.pem \
+ >/etc/shirudo/bpm/environment &&
+ echo OTEL_EXPORTER_OTLP_CERTIFICATE=/etc/shirudo/end2end-ca.pem \
+ >/etc/shirudo/map-export.env &&
+ cd /workspace/shirudo/testing && rm -f /tmp/forward-ready &&
+ setsid -f python3 end2end/tcp_forward.py 127.0.0.1:15443 \
+ 10.0.2.2:15443 /tmp/forward-ready \
+ </dev/null >/dev/null 2>&1 &&
+ i=0 && until [ -e /tmp/forward-ready ]; do
+ i=\$((i + 1)); [ \$i -lt 50 ] || exit 1; sleep 0.1
+ done" || exit 1
+ done
+'
+
+test_expect_success 'the sync applies 01 01 01 on the edge node and 10 10 10 on node B' '
+ unit_ok edge shirudo-bpm-tree-sync.service &&
+ unit_ok b shirudo-bpm-tree-sync.service &&
+ node_view edge >"$W/view-edge" &&
+ node_view b >"$W/view-b" &&
+ python3 - "$W/view-edge" "$W/view-b" <<-\PY
+ import json, sys
+ edge, b = (json.load(open(path)) for path in sys.argv[1:3])
+ for view in edge, b:
+ assert view["last_seq"] == 3 and view["generation"] == 3, view
+ assert edge["outcomes"] == [1, 1, 1], edge
+ assert b["outcomes"] == [2, 2, 2], b
+ assert b["projection_root"] == "0" * 64, b
+ PY
+'
+
+test_expect_success 'each node sends two quoted keepalives, a few seconds apart' '
+ unit_ok edge shirudo-keepalive.service &&
+ unit_ok b shirudo-keepalive.service &&
+ sleep 3 &&
+ unit_ok edge shirudo-keepalive.service &&
+ unit_ok b shirudo-keepalive.service &&
+ ch_wait "SELECT count() FROM shirudo.keepalive FINAL" 4 &&
+ for n in edge b; do
+ boot=$(on "$n" cat /proc/sys/kernel/random/boot_id) &&
+ ch "SELECT DISTINCT ak_name FROM shirudo.keepalive
+ WHERE boot_id = '\''$boot'\''" >"$W/ak-$n" &&
+ test "$(wc -l <"$W/ak-$n")" = 1 || exit 1
+ done &&
+ test "$(ak edge)" != "$(ak b)"
+'
+
+test_expect_success 'the backend keeps both nodes, untrusted, and every record' '
+ printf "%s\tuntrusted\n" "$(ak b)" "$(ak edge)" | sort >"$W/nodes" &&
+ ch_cmp "SELECT ak_name, max(trust) FROM shirudo.nodes
+ GROUP BY ak_name ORDER BY ak_name" "$W/nodes" &&
+ test "$(ch "SELECT count() FROM shirudo.rejected")" = 0 &&
+ ch "$Q_KEEPALIVE" >"$W/records" &&
+ python3 "$CHECKS" quotes "$W/records" | cut -d " " -f 1 | uniq -c |
+ awk "{ print \$1 }" >"$W/per-node" &&
+ test "$(cat "$W/per-node")" = "$(printf "2\n2")" &&
+ test "$(ch "SELECT count() FROM shirudo.keepalive_latest AS l FINAL
+ INNER JOIN (SELECT ak_name, max(clock) AS newest, argMax(body, clock) AS newest_body
+ FROM shirudo.keepalive FINAL GROUP BY ak_name) AS k
+ ON k.ak_name = l.ak_name AND k.newest = l.clock AND k.newest_body = l.body")" = 2
+'
+
+test_expect_success 'node_status shows both nodes healthy with the masks VA== and qA==' '
+ version=$(on edge "$RUNTIME version --version-id") &&
+ test "$version" = "$(on b "$RUNTIME version --version-id")" &&
+ ch "INSERT INTO shirudo.expected_builds (version_id, note)
+ VALUES ('\''$version'\'', '\''t9109'\'')" &&
+ refresh &&
+ printf "%s\thealthy\tuntrusted\t0\n" "$(ak b)" "$(ak edge)" | sort >"$W/status" &&
+ ch_cmp "SELECT ak_name, status, trust, failed_check FROM shirudo.node_status
+ ORDER BY ak_name" "$W/status" &&
+ ch "SELECT line FROM shirudo.node_status ARRAY JOIN log AS line
+ WHERE ak_name = '\''$(ak edge)'\''" >"$W/log-edge" &&
+ ch "SELECT line FROM shirudo.node_status ARRAY JOIN log AS line
+ WHERE ak_name = '\''$(ak b)'\''" >"$W/log-b" &&
+ root=$(python3 -c "import json, sys; print(json.load(open(sys.argv[1]))[\"projection_root\"][:8])" \
+ "$W/view-edge") &&
+ grep -qx "4 chain: pass, root $root" "$W/log-edge" &&
+ grep -qx "5 head: pass, seq 3 of 3, generation 3" "$W/log-edge" &&
+ grep -qx "6 set: pass, 1 loaded" "$W/log-edge" &&
+ grep -qx "4 chain: pass, root 00000000" "$W/log-b" &&
+ grep -qx "5 head: pass, seq 3 of 3, generation 3" "$W/log-b" &&
+ grep -qx "6 set: pass, 0 loaded" "$W/log-b" &&
+ test "$(ch "SELECT mask FROM shirudo.keepalive_latest FINAL
+ WHERE ak_name = '\''$(ak edge)'\''")" = VA== &&
+ test "$(ch "SELECT mask FROM shirudo.keepalive_latest FINAL
+ WHERE ak_name = '\''$(ak b)'\''")" = qA==
+'
+
+test_expect_success 'the backend holds what each node recorded and loaded' '
+ ch "SELECT operation_digest FROM shirudo.tree_ops FINAL
+ WHERE tree_id = '\''pipeline'\'' ORDER BY seq" >"$W/digests" &&
+ python3 "$CHECKS" roots $(cat "$W/digests") >"$W/roots" &&
+ for n in edge b; do
+ on "$n" "$RUNTIME status --keepalive" >"$W/keepalive-$n" &&
+ on "$n" "$RUNTIME upatch list --json" >"$W/upatches-$n" &&
+ python3 "$CHECKS" set "$W/upatches-$n" >"$W/set-$n" &&
+ ch "SELECT projection_root, set_sha256, mask, last_seq, generation
+ FROM shirudo.keepalive_latest FINAL
+ WHERE ak_name = '\''$(ak "$n")'\'' FORMAT JSONEachRow" >"$W/latest-$n" &&
+ python3 - "$n" "$W/latest-$n" "$W/view-$n" "$W/keepalive-$n" \
+ "$W/set-$n" "$W/roots" "$W/digests" \
+ "$(cat "$W/payload-1.1.0")" <<-\PY || exit 1
+ import hashlib, json, sys
+ n = sys.argv[1]
+ latest, view, body = (json.load(open(p)) for p in sys.argv[2:5])
+ listed = open(sys.argv[5]).read().strip()
+ projection, history = open(sys.argv[6]).read().split()
+ digests = open(sys.argv[7]).read().split()
+ payload = sys.argv[8]
+ assert latest["projection_root"] == view["projection_root"], (latest, view)
+ assert view["outcome_root"] == view["projection_root"], view
+ assert latest["mask"] == view["mask"], (latest, view)
+ assert latest["set_sha256"] == body["set_sha256"] == listed, (latest, body, listed)
+ assert (latest["last_seq"], latest["generation"]) == (3, 3), latest
+ assert view["history_root"] == history, (view, history)
+ if n == "edge":
+ assert view["chained"] == digests, (view, digests)
+ assert view["projection_root"] == projection, (view, projection)
+ text = f"{payload} xfs-fix\n".encode()
+ assert listed == hashlib.sha256(text).hexdigest(), listed
+ else:
+ assert view["chained"] == [], view
+ assert listed == hashlib.sha256(b"").hexdigest(), listed
+ PY
+ done
+'
+
+# The image.json of the nodes' image names no sbom_format, so that its ok
+# says the job read it as cyclonedx-json. Each other image is of another
+# version, which no node runs.
+test_expect_success 'the sbom-scan job reads every state of the SBOM store' '
+ image_id=$(sed -n "s/^IMAGE_ID=//p" vm/files/end2end.os-release) &&
+ image_version=$(sed -n "s/^IMAGE_VERSION=//p" vm/files/end2end.os-release) &&
+ test "$(ch "SELECT DISTINCT image_id, image_version, image_root
+ FROM shirudo.keepalive_latest FINAL")" = \
+ "$(printf "%s\t%s\t\\\\N" "$image_id" "$image_version")" &&
+ python3 - "$W/store" "$FIX/sbom.cdx.json" "$image_id" "$image_version" <<-\PY &&
+ import hashlib, json, os, sys
+ store, sbom, image_id, version = sys.argv[1:5]
+ data = open(sbom, "rb").read()
+ sha = hashlib.sha256(data).hexdigest()
+ not_cdx = b"{\"spdxVersion\": \"SPDX-2.3\"}\n"
+ images = {
+ version: (data, sha, None),
+ "end2end-hash": (data, "0" * 64, "cyclonedx-json"),
+ "end2end-missing": (None, sha, "cyclonedx-json"),
+ "end2end-parse": (not_cdx, hashlib.sha256(not_cdx).hexdigest(), "cyclonedx-json"),
+ "end2end-spdx": (data, sha, "spdx-json"),
+ }
+ for name, (body, digest, sbom_format) in images.items():
+ where = os.path.join(store, image_id, name, "-")
+ os.makedirs(where)
+ meta = {"image_id": image_id, "image_version": name, "image_root": "",
+ "sbom_sha256": digest, "built_at": "2026-11-12T08:00:00Z"}
+ if sbom_format:
+ meta["sbom_format"] = sbom_format
+ with open(os.path.join(where, "image.json"), "w") as f:
+ json.dump(meta, f)
+ if body is not None:
+ with open(os.path.join(where, "sbom.cdx.json"), "wb") as f:
+ f.write(body)
+ PY
+ "$BACKEND/jobs/sbom-scan" --store "file://$W/store" --trivy "$FIX/trivy" >&2 &&
+ sha=$(sha256sum "$FIX/sbom.cdx.json" | cut -d " " -f 1) &&
+ cat >"$W/images" <<-EOF &&
+ $image_version cyclonedx-json ok $sha
+ end2end-hash cyclonedx-json hash_mismatch -
+ end2end-missing cyclonedx-json missing -
+ end2end-parse cyclonedx-json parse_error -
+ end2end-spdx spdx-json unsupported_format -
+ EOF
+ ch_cmp "SELECT image_version, sbom_format, state,
+ if(empty(sbom_sha256), '\''-'\'', sbom_sha256)
+ FROM shirudo.sbom_images FINAL ORDER BY image_version" "$W/images" &&
+ test "$(ch "SELECT sbom_sha256, vuln_id, package FROM shirudo.sbom_vulns")" = \
+ "$(printf "%s\tEXAMPLE-0202\topenssl" "$sha")"
+'
+
+test_expect_success 'node_vulns shields the edge node and excludes node B' '
+ stack_backend_client --query "INSERT INTO shirudo.kernel_vulns FORMAT JSONEachRow" \
+ <"$FIX/kernel-vulns.json" &&
+ test "$(ch "SELECT countIf(kver(kernel_release) >= [7, 0])
+ FROM shirudo.keepalive_latest FINAL")" = 2 &&
+ refresh &&
+ cat >"$W/vulns" <<-EOF &&
+ b declared kernel EXAMPLE-0101 linux shield_excludes_node xfs-fix 3 add fixes
+ b declared sbom EXAMPLE-0202 openssl exposed_no_shield 0 none
+ edge declared kernel EXAMPLE-0101 linux shielded xfs-fix 3 add fixes
+ edge declared sbom EXAMPLE-0202 openssl exposed_no_shield 0 none
+ EOF
+ ch_cmp "SELECT if(ak_name = '\''$(ak edge)'\'', '\''edge'\'', '\''b'\'') AS node,
+ binding, source, vuln_id, package, exposure, upatch_id, applied_seq,
+ applied_op, shield_link
+ FROM shirudo.node_vulns ORDER BY node, vuln_id" "$W/vulns"
+'
+
+test_expect_success 'a record replayed with one body byte changed is body_mismatch' '
+ status_rows >"$W/status-before" &&
+ ch "$Q_KEEPALIVE" >"$W/records" &&
+ grep "\"ak_name\":\"$(ak edge)\"" "$W/records" >"$W/records-edge" &&
+ python3 "$CHECKS" replay "$W/records-edge" "$W/quote" "$W/altered" &&
+ OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE="$E2E/ca.pem" \
+ "$H" send-keepalive "https://$COLLECTOR" ok "$W/altered" \
+ "$(cat "$W/quote")" &&
+ ch_wait "SELECT count() FROM shirudo.rejected" 1 &&
+ test "$(ch "SELECT reason, lower(hex(SHA256(body))) FROM shirudo.rejected")" = \
+ "$(printf "body_mismatch\t%s" "$(sha256sum "$W/altered" | cut -d " " -f 1)")" &&
+ test "$(ch "SELECT count() FROM shirudo.keepalive FINAL")" = 4 &&
+ refresh &&
+ status_rows >"$W/status-after" &&
+ diff -u "$W/status-before" "$W/status-after" >&2
+'
+
+test_done
diff --git a/testing/fixtures/pipeline/kernel-vulns.json b/testing/fixtures/pipeline/kernel-vulns.json
new file mode 100644
index 00000000..e89f8d5a
--- /dev/null
+++ b/testing/fixtures/pipeline/kernel-vulns.json
@@ -0,0 +1 @@
+{"vuln_id":"EXAMPLE-0101","introduced":[7,0],"fixed":[],"severity":"HIGH"}
diff --git a/testing/fixtures/pipeline/sbom.cdx.json b/testing/fixtures/pipeline/sbom.cdx.json
new file mode 100644
index 00000000..ad026931
--- /dev/null
+++ b/testing/fixtures/pipeline/sbom.cdx.json
@@ -0,0 +1,16 @@
+{
+ "bomFormat": "CycloneDX",
+ "specVersion": "1.6",
+ "version": 1,
+ "metadata": {
+ "component": {"type": "operating-system", "name": "fleet-os", "version": "end2end-1"}
+ },
+ "components": [
+ {
+ "type": "library",
+ "name": "openssl",
+ "version": "3.0.13-0ubuntu3",
+ "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64"
+ }
+ ]
+}
diff --git a/testing/fixtures/pipeline/trivy b/testing/fixtures/pipeline/trivy
new file mode 100755
index 00000000..25d99fa6
--- /dev/null
+++ b/testing/fixtures/pipeline/trivy
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# testing/fixtures/pipeline/trivy -- stand in for Trivy in t9109, which
+# runs no vulnerability database. `version` prints a made-up database and
+# `sbom <options> <file>` the report trivy-report.json, one finding of
+# openssl. It fails for any SBOM but sbom.cdx.json beside it.
+
+set -eu
+
+here=$(cd "$(dirname "$0")" && pwd)
+
+case "${1:-}" in
+version)
+ printf '%s\n' '{"Version":"0.0.0-t9109","VulnerabilityDB":{"Version":2,"UpdatedAt":"2026-11-12T06:00:00Z"}}' ;;
+sbom)
+ for file; do :; done
+ cmp -s "$file" "$here/sbom.cdx.json" || {
+ echo "stub trivy: $file is not the fixture SBOM" >&2
+ exit 1
+ }
+ cat "$here/trivy-report.json" ;;
+*)
+ echo "stub trivy: no command $*" >&2
+ exit 2 ;;
+esac
diff --git a/testing/fixtures/pipeline/trivy-report.json b/testing/fixtures/pipeline/trivy-report.json
new file mode 100644
index 00000000..307ae4aa
--- /dev/null
+++ b/testing/fixtures/pipeline/trivy-report.json
@@ -0,0 +1 @@
+{"SchemaVersion":2,"ArtifactName":"sbom.cdx.json","ArtifactType":"cyclonedx","Results":[{"Target":"sbom.cdx.json","Class":"os-pkgs","Type":"ubuntu","Vulnerabilities":[{"VulnerabilityID":"EXAMPLE-0202","PkgName":"openssl","InstalledVersion":"3.0.13-0ubuntu3","FixedVersion":"3.0.13-0ubuntu3.1","Severity":"HIGH"}]}]}
diff --git a/testing/fixtures/pipeline/xfs-fix/Beefile b/testing/fixtures/pipeline/xfs-fix/Beefile
new file mode 100644
index 00000000..0298d9b6
--- /dev/null
+++ b/testing/fixtures/pipeline/xfs-fix/Beefile
@@ -0,0 +1,15 @@
+[package]
+name = "xfs-fix"
+description = "The upatch of the full-chain end-to-end test, linked to EXAMPLE-0101"
+license = "GPL-2.0 OR BSD-2-Clause"
+authors = ["Authors of shirudo"]
+
+[[upatches]]
+source = "xfs-fix.bpf.c"
+
+[upatches.tree]
+id = "xfs-fix"
+fixes = ["EXAMPLE-0101"]
+
+[upatches.tree.selector.labels]
+role = ["edge"]
diff --git a/testing/fixtures/pipeline/xfs-fix/xfs-fix.bpf.c b/testing/fixtures/pipeline/xfs-fix/xfs-fix.bpf.c
new file mode 100644
index 00000000..985e6821
--- /dev/null
+++ b/testing/fixtures/pipeline/xfs-fix/xfs-fix.bpf.c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+/*
+ * Copyright (c) 2026 Authors of shirudo
+ *
+ * The stand-in for a fix in the full-chain end-to-end test. It attaches to
+ * a function every test kernel has, not to XFS, so that it always loads.
+ */
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+
+char _license[] SEC("license") = "Dual BSD/GPL";
+
+SEC("fentry/do_nanosleep")
+int BPF_PROG(xfs_fix)
+{
+ return 0;
+}
diff --git a/testing/functional/build/t1007-test-vm-cli.sh b/testing/functional/build/t1007-test-vm-cli.sh
index ca52e9c1..72442133 100755
--- a/testing/functional/build/t1007-test-vm-cli.sh
+++ b/testing/functional/build/t1007-test-vm-cli.sh
@@ -32,19 +32,28 @@ test_expect_success 'register protocols run only in an isolated pre-init test VM
grep -q "register suite requires test mode" "$WORK/register-initrd.out"
'
-test_expect_success 'node mode boots only the second node of the end2end suite' '
+test_expect_success 'node mode boots only a core or edge node of the end2end suite' '
! VM_MODE=node TEST_VM_WORK_DIR="$WORK/node" \
"$RUNNER" >"$WORK/node-upatch.out" 2>&1 &&
- grep -q "node mode boots the second node of the end2end suite only" \
+ grep -q "node mode boots a node of the end2end suite only" \
"$WORK/node-upatch.out" &&
- ! TEST_VM_SUITE=end2end VM_MODE=node TEST_VM_WORK_DIR="$WORK/node" \
+ ! TEST_VM_SUITE=end2end VM_MODE=node TEST_VM_NODE_ROLE=gateway \
+ TEST_VM_WORK_DIR="$WORK/node" "$RUNNER" \
+ >"$WORK/node-role.out" 2>&1 &&
+ grep -q "TEST_VM_NODE_ROLE must be .core. or .edge." "$WORK/node-role.out" &&
+ ! TEST_VM_SUITE=end2end VM_MODE=node TEST_VM_NODE_ROLE=edge \
+ TEST_VM_WORK_DIR="$WORK/node" \
TEST_VM_KERNEL="$WORK/no-bzImage" "$RUNNER" \
>"$WORK/node-end2end.out" 2>&1 &&
grep -q "kernel image not found" "$WORK/node-end2end.out" &&
- grep -Fq "\$(call run-target-vm,end2end,\$(if \$(VM_NAME),\$(VM_NAME)-end2end-b),1,node)" \
+ grep -Fq "\$(call run-target-vm,end2end,\$(if \$(VM_NAME),\$(VM_NAME)-end2end-\$(END2END_NODE)),1,node)" \
../testing/Makefile &&
+ grep -Fq "TEST_VM_NODE_ROLE=\$(if \$(filter edge,\$(END2END_NODE)),edge,core)" \
+ ../testing/Makefile &&
+ grep -Fq "export TEST_VM_NODE_ROLE=" vm/run.sh &&
grep -Fq "if [[ \"\$VM_MODE\" == node ]]" vm/guest.sh &&
- grep -Fq "image update /var/lib/shirudo/images/config-core" vm/guest.sh
+ grep -Fq "image update \"/var/lib/shirudo/images/config-\${TEST_VM_NODE_ROLE}\"" \
+ vm/guest.sh
'
test_expect_success 'test-vm requires a SHA-256 for a remote kernel' '
@@ -954,7 +963,11 @@ test_expect_success 'the runners split the tests by number' '
case " $families " in *" ${f%/} "*) ;; *) return 1 ;; esac
done &&
! sh run-tests.sh nosuch >"$WORK/nosuch.out" 2>&1 &&
- grep -q "no tests nosuch" "$WORK/nosuch.out"
+ grep -q "no tests nosuch" "$WORK/nosuch.out" &&
+ test -e end2end/t9109-pipeline.sh &&
+ grep -Fqx " [ \"\$t\" != end2end/t9109-pipeline.sh ] || continue" \
+ run-target-tests.sh &&
+ grep -Fq "sh end2end/t9109-pipeline.sh" end2end/host.sh
'
test_expect_success 'test-vm rejects unknown policy modes before boot' '
diff --git a/testing/run-target-tests.sh b/testing/run-target-tests.sh
index 2b4f8dd3..16cf67a1 100755
--- a/testing/run-target-tests.sh
+++ b/testing/run-target-tests.sh
@@ -72,6 +72,9 @@ for t in "$dir"/t[0-9]1[0-9][0-9]-*.sh; do
[ -e "$t" ] || continue
found=1
test_matches "$t" || continue
+ # end2end/host.sh runs t9109 itself, on the host after node A's suite,
+ # against the fresh edge node and node B.
+ [ "$t" != end2end/t9109-pipeline.sh ] || continue
log="$SHIRUDO_TEST_RESULTS/$(basename "$t").log"
rc=0
sh "$t" >"$log" 2>&1 || rc=$?
diff --git a/testing/vm/guest.sh b/testing/vm/guest.sh
index 16d2795c..801a1038 100755
--- a/testing/vm/guest.sh
+++ b/testing/vm/guest.sh
@@ -430,8 +430,8 @@ if tpm.get("chain_matches_eventlog") is not True:
PY
if [[ "$VM_MODE" == node ]]; then
- log "node B of the end2end suite takes the core role"
- "$SHIRUDO_BIN" image update /var/lib/shirudo/images/config-core
+ log "this node of the end2end suite takes the ${TEST_VM_NODE_ROLE} role"
+ "$SHIRUDO_BIN" image update "/var/lib/shirudo/images/config-${TEST_VM_NODE_ROLE}"
fi
if [[ "${TEST_VM_SUITE:-}" == end2end ]]; then
"$SHIRUDO_BIN" status --keepalive >/mnt/shirudo-out/keepalive.json
diff --git a/testing/vm/run.sh b/testing/vm/run.sh
index 32c59b7a..c0a6ac48 100755
--- a/testing/vm/run.sh
+++ b/testing/vm/run.sh
@@ -5,9 +5,10 @@
# Boot an Ubuntu guest with a selected Linux kernel and an swtpm vTPM.
# In test mode it runs the target tests of the family TEST_VM_SUITE names,
# or the TPM register tests for "register"; in interactive mode it prepares
-# the guest and leaves QEMU and swtpm running. Node mode boots the second
-# node of the end2end suite: prepared like the suite's VM, with no tests
-# and no timers, and left running until TEST_VM_TIMEOUT or a --stop.
+# the guest and leaves QEMU and swtpm running. Node mode boots another
+# node of the end2end suite, with the role TEST_VM_NODE_ROLE names, core
+# by default or edge: prepared like the suite's VM, with no tests and no
+# timers, and left running until TEST_VM_TIMEOUT or a --stop.
#
# VM_MODE=test|interactive|node selects the mode. VM_NAME optionally selects a
# stable state directory; if omitted, a unique name is allocated atomically.
@@ -71,6 +72,7 @@ DISK_SIZE="${TEST_VM_DISK_SIZE:-30G}"
VM_TIMEOUT="${TEST_VM_TIMEOUT:-3600}"
VM_MODE="${VM_MODE:-test}"
VM_SUITE="${TEST_VM_SUITE:-}"
+NODE_ROLE="${TEST_VM_NODE_ROLE:-core}"
TEST_MODE="${TEST_VM_MODE:-verity}"
SKIP_SEAL="${TEST_VM_SKIP_SEAL:-0}"
VM_INITRD="${TEST_VM_INITRD:-1}"
@@ -173,7 +175,9 @@ validate_mode()
interactive|test) ;;
node)
[[ "$VM_SUITE" == end2end ]] ||
- die "node mode boots the second node of the end2end suite only"
+ die "node mode boots a node of the end2end suite only"
+ [[ "$NODE_ROLE" == core || "$NODE_ROLE" == edge ]] ||
+ die "TEST_VM_NODE_ROLE must be 'core' or 'edge'"
;;
*) die "VM_MODE must be 'interactive', 'test' or 'node'" ;;
esac
@@ -1479,6 +1483,7 @@ printf ' export VM_MODE=%q\n' "$VM_MODE" >>"$USER_DATA"
printf ' export TEST_VM_MODE=%q\n' "$TEST_MODE" >>"$USER_DATA"
printf ' export TEST_VM_SUITE=%q\n' "$VM_SUITE" >>"$USER_DATA"
printf ' export TEST_FILTER=%q\n' "${TEST_FILTER:-}" >>"$USER_DATA"
+printf ' export TEST_VM_NODE_ROLE=%q\n' "$NODE_ROLE" >>"$USER_DATA"
printf ' export TEST_VM_SKIP_SEAL=%q\n' "$SKIP_SEAL" >>"$USER_DATA"
printf ' export TEST_VM_INITRD=%q\n' "$VM_INITRD" >>"$USER_DATA"
printf ' export TEST_VM_SSH_PUBLIC_KEY=%q\n' "$SSH_PUBLIC_KEY" >>"$USER_DATA"
diff --git a/testing/vm/stack-lib.sh b/testing/vm/stack-lib.sh
index 200622ea..7c606331 100644
--- a/testing/vm/stack-lib.sh
+++ b/testing/vm/stack-lib.sh
@@ -132,11 +132,7 @@ stack_backend()
[ "$attempt" -lt 150 ] || return 1
sleep 0.2
done
- for file in "$backend"/sql/*.sql; do
- stack_backend_client <"$file" || return 1
- done
- "$backend/sql/apply-retention.sh" docker exec -i "$container" \
- clickhouse-client >/dev/null || return 1
+ stack_backend_schema "$backend" || return 1
stack_run "$STACK_NAME-backend-collector" --network "$STACK_NAME" \
-p "$BACKEND_COLLECTOR:4318" -v "$TLS_DIR:/certs:ro" \
-e CLICKHOUSE_ENDPOINT=tcp://backend-clickhouse:9000 \
@@ -146,6 +142,17 @@ stack_backend()
"https://$BACKEND_COLLECTOR/v1/logs"
}
+# Load the schema of the backend in directory $1, with the retention its
+# settings name, into the backend's ClickHouse.
+stack_backend_schema()
+{
+ for file in "$1"/sql/*.sql; do
+ stack_backend_client <"$file" || return 1
+ done
+ "$1/sql/apply-retention.sh" docker exec -i \
+ "$STACK_NAME-backend-clickhouse" clickhouse-client >/dev/null
+}
+
stack_down()
{
docker logs "$STACK_NAME-collector" >"$W/collector.log" 2>&1 || true