From 8b6d69e13c357a9b26e1b055732596eaeb3ef906 Mon Sep 17 00:00:00 2001 From: acamilo Date: Thu, 1 Oct 2026 23:57:34 +0000 Subject: [PATCH] infra: fly-runtime session --bus; shadow of the bus topology fly-runtime session --bus (session-bus) writes FLY_SESSION_TRANSPORT=bus into the runtime drop-in and needs the release's fly-session worker; session --local takes it out; a flag-less session (05-deploy's refresh) keeps it. status prints the transport. 05-deploy refuses a release without fly-session while the drop-in says bus. fly-shadow-run start --bus runs the shadow's session on the bus (FLY_SHADOW_MODE=bus/process, forwarded to a remote box by the relay); check --bus requires a verdict that ran it. start refuses while the live fly runs the session runtime, which writes no trace to follow. Runbook and lint cover both. --- infra/05-deploy.sh | 5 +++ infra/bin/fly-runtime | 60 ++++++++++++++++++++++--- infra/bin/fly-shadow-run | 48 ++++++++++++++++++-- infra/docs/runbook.md | 26 +++++++++++ infra/tests/lint.sh | 97 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 226 insertions(+), 10 deletions(-) diff --git a/infra/05-deploy.sh b/infra/05-deploy.sh index af2d3fe..b51f59d 100644 --- a/infra/05-deploy.sh +++ b/infra/05-deploy.sh @@ -408,6 +408,11 @@ The 'current' symlink has NOT been moved; the running release is untouched." if ct_exec "$CTID" -- test -f /etc/systemd/system/flysim.service.d/10-runtime.conf; then ct_exec "$CTID" -- test -x "${release_path}/flysim-session" \ || die "05-deploy: REFUSING to deploy release ${version}: flysim.service runs the session runtime (fly-runtime session) and this release has no flysim-session. Run \`fly-runtime legacy\` in the container first, or deploy a release that ships it. The 'current' symlink has NOT been moved." + # BUS-01: on the bus transport flysim-session starts its participants from fly-session. + if ct_exec "$CTID" -- grep -qx 'Environment=FLY_SESSION_TRANSPORT=bus' /etc/systemd/system/flysim.service.d/10-runtime.conf; then + ct_exec "$CTID" -- test -x "${release_path}/fly-session" \ + || die "05-deploy: REFUSING to deploy release ${version}: flysim.service runs the session runtime on the bus (fly-runtime session --bus) and this release has no fly-session worker. Run \`fly-runtime session --local\` in the container first. The 'current' symlink has NOT been moved." + fi session_compat="$(ct_exec "$CTID" -- env \ "FLY_GAME=${GAME}" \ "FLY_DATASET=${release_path}/data/fafb-v783" \ diff --git a/infra/bin/fly-runtime b/infra/bin/fly-runtime index 5af9b41..3c41652 100755 --- a/infra/bin/fly-runtime +++ b/infra/bin/fly-runtime @@ -3,8 +3,10 @@ # session runtime (`flysim-session`, SERVE-01). # # Usage (INSIDE the container, as root): -# fly-runtime status print `legacy` or `session`, and what flysim.service runs -# fly-runtime session [--no-restart] [--no-fallback] [--no-probation] +# fly-runtime status print `legacy` or `session` (and the session's transport), and +# what flysim.service runs +# fly-runtime session [--local|--bus] [--no-restart] [--no-fallback] [--no-probation] +# fly-runtime session-bus [...] the same as `session --bus` # fly-runtime legacy [--no-restart] # fly-runtime fallback [reason] (run by fly-runtime-fallback.service, see below; idempotent) # @@ -12,6 +14,19 @@ # the one-command rollback (port decisions, 2026-09-23). Neither migrates any data: both # binaries read and write the same FLYSIM01 stores, event log, sugar journal and chat sidecar. # +# The session's transport (BUS-01). `--local` (the default for a first switch) runs the session's +# participants in flysim-session's own process over the local lane. `--bus` runs them on the flybus +# router over Unix sockets: flysim-session (the router, the coordinator, the listeners) starts the +# agent and the world as child processes of the same unit (`fly-session legacy-agent`, +# `fly-session legacy-environment`, from the same release), in flysim.slice, on flysim's cpuset. +# The drop-in then carries `Environment=FLY_SESSION_TRANSPORT=bus`. Without either flag `session` +# keeps the transport the drop-in already has, so 05-deploy's `session --no-restart` refresh never +# changes it; `session --local` is the way back from the bus. Results, traces, checkpoints and the +# compatibility string are the same in both: only where the participants run changes. A switch onto +# the bus needs a shadow that ran the bus (`fly-shadow-run check --bus`), which the coordinator runs +# before this command, as for the first cutover. Everything below applies to both transports: one +# unit, OnFailure= falls back to LEGACY, the probation judges the session runtime either way. +# # How the switch works. flysim.service stays the fly's one unit name, and the runtime it runs # is chosen by one drop-in, ${DROPIN}: # @@ -91,6 +106,7 @@ RUNTIME_LOG="$FLY_RUNTIME_LOG" FELLBACK_FILE="$FLY_RUNTIME_FELLBACK" FALLBACK_UNIT=fly-runtime-fallback.service SESSION_BIN="${FLY_RELEASE_DIR}/flysim-session" +WORKER_BIN="${FLY_RELEASE_DIR}/fly-session" LEGACY_BIN="${FLY_RELEASE_DIR}/flysim" SESSION_DIR=/run/fly/session SHADOW_RUN_BIN="${FLY_SHADOW_RUN_BIN:-$(dirname "$(readlink -f "$0")")/fly-shadow-run}" @@ -120,7 +136,7 @@ stop_shadow() { } usage() { - echo "usage: fly-runtime status | session [--no-restart] [--no-fallback] [--no-probation] | legacy [--no-restart] | fallback [reason]" >&2 + echo "usage: fly-runtime status | session [--local|--bus] [--no-restart] [--no-fallback] [--no-probation] | session-bus [...] | legacy [--no-restart] | fallback [reason]" >&2 exit 2 } @@ -128,6 +144,20 @@ current() { if [ -f "$DROPIN" ]; then echo session; else echo legacy; fi } +# The session's transport the drop-in selects: `bus` or `local` (also with no drop-in). +current_transport() { + if [ -f "$DROPIN" ] && grep -qx 'Environment=FLY_SESSION_TRANSPORT=bus' "$DROPIN"; then + echo bus + else + echo local + fi +} + +# `legacy`, `session` or `session-bus`, for the runtime log. +current_label() { + if [ "$(current)" = session ] && [ "$(current_transport)" = bus ]; then echo session-bus; else current; fi +} + record() { local line line="$(date -u '+%Y-%m-%dT%H:%M:%SZ') $*" @@ -176,6 +206,12 @@ ExecStart=${SESSION_BIN} Environment=FLY_SESSION_DIR=${SESSION_DIR} Environment=MALLOC_ARENA_MAX=2 EOF + if [ "$transport" = bus ]; then + cat >>"$tmp" </dev/null | sed 's/^/ /' || true; fi systemctl show -p ExecStart --value "$FLY_SERVICE" 2>/dev/null | sed -n 's/.*path=\([^ ;]*\).*/ flysim.service runs \1/p' || true exit 0 ;; - session|legacy) ;; + session|session-bus|legacy) ;; fallback) [ "$(id -u)" -eq 0 ] || die "run as root" do_fallback "${fallback_reason:-flysim.service failed on the session runtime (OnFailure=)}" @@ -372,6 +415,9 @@ esac if [ "$command" = session ]; then [ -x "$SESSION_BIN" ] || die "this release has no ${SESSION_BIN}; the session runtime ships from SERVE-01 on" [ -x "$LEGACY_BIN" ] || die "no ${LEGACY_BIN}" + if [ "$transport" = bus ] && [ ! -x "$WORKER_BIN" ]; then + die "this release has no ${WORKER_BIN}: the bus transport starts its participants from it" + fi legacy_compat="$(compat_of "$LEGACY_BIN")" session_compat="$(compat_of "$SESSION_BIN")" [ -n "$session_compat" ] || die "${SESSION_BIN} --print-compatibility printed nothing (see its stderr); not switching" @@ -381,7 +427,7 @@ if [ "$command" = session ]; then flysim-session: ${session_compat}" fi take_lock || die "another fly-runtime holds ${FLY_RUNTIME_LOCK}; not switching" - before="$(current)" + before="$(current_label)" if [ -f "$DROPIN" ]; then prev_dropin="$(mktemp "${DROPIN}.prev.XXXXXX")" cp -f "$DROPIN" "$prev_dropin" @@ -390,7 +436,7 @@ if [ "$command" = session ]; then switching=1 rm -f "$FELLBACK_FILE" write_dropin - record "session (was ${before}); compatibility ${session_compat}" + record "$(current_label) (was ${before}); compatibility ${session_compat}" if [ "$restart" -ne 1 ]; then systemctl daemon-reload switching=0 @@ -438,7 +484,7 @@ fi # legacy take_lock || die "another fly-runtime holds ${FLY_RUNTIME_LOCK}; not switching" -before="$(current)" +before="$(current_label)" switch_target=legacy switching=1 rm -f "$DROPIN" diff --git a/infra/bin/fly-shadow-run b/infra/bin/fly-shadow-run index dc7fd03..41c3f42 100755 --- a/infra/bin/fly-shadow-run +++ b/infra/bin/fly-shadow-run @@ -12,7 +12,8 @@ # restart; --restart-flysim restarts it now), remove trace and spool # fly-shadow-run status the verdict in one screen # fly-shadow-run check CUT-01's hook: exit 0 only if the verdict allows the automatic cutover -# into the release /opt/fly/current points to, onto flysim-session +# into the release /opt/fly/current points to, onto flysim-session. +# --bus also requires that the shadow ran the bus topology (BUS-01) # fly-shadow-run guard (flyshadow-guard.timer, every 60 s) stop everything and restart flysim # without the trace if the live fly pays for the shadow # fly-shadow-run simulate BASELINE.jsonl CHECKS.jsonl the guard's rule over recorded samples @@ -53,6 +54,17 @@ # ActiveState inactive or failed (systemctl show), never activating: the shadow's 10-s crash-restart # delay must not switch the guard off. `check` also requires the guard timer active and baseline.json. # +# THE BUS TOPOLOGY (BUS-01). `start --bus` runs the shadow's session the way `fly-runtime +# session --bus` runs the live one: the router, the coordinator and the task in the shadow's own +# process, the agent and the world as child processes (`fly-session legacy-agent`, +# `fly-session legacy-environment`, from the same release) on the router's Unix sockets. It sets +# FLY_SHADOW_MODE=bus/process in flyshadow.service's drop-in (mode.conf); a remote relay forwards it +# to the box (live.env), whose shadow reads it. The verdict records the topology +# (candidate.executionMode "process", candidate.transport "bus"), and `check --bus` refuses any +# verdict that did not run it. The live fly must run the LEGACY runtime while a shadow runs: only +# the legacy loop writes the trace (FLY_TRACE_DIR) the shadow follows, so `start` refuses while +# flysim.service runs the session runtime (fly-runtime status: session). +# # REMOTE (SHADOW-02). With /etc/fly/shadow-remote.env present (the operator's private file: # FLY_SHADOW_REMOTE=@, FLY_SHADOW_REMOTE_KEY, FLY_SHADOW_REMOTE_KNOWN_HOSTS, optional # FLY_SHADOW_REMOTE_PORT), `start` gives flyshadow.service a drop-in (remote.conf) that runs @@ -85,6 +97,8 @@ DROPIN="$DROPIN_DIR/shadow-trace.conf" REMOTE_ENV="${FLY_SHADOW_REMOTE_ENV:-/etc/fly/shadow-remote.env}" REMOTE_DROPIN_DIR="${FLY_SHADOW_REMOTE_DROPIN_DIR:-/etc/systemd/system/flyshadow.service.d}" REMOTE_DROPIN="$REMOTE_DROPIN_DIR/remote.conf" +MODE_DROPIN="$REMOTE_DROPIN_DIR/mode.conf" +RUNTIME_DROPIN="${FLY_RUNTIME_DROPIN:-$DROPIN_DIR/10-runtime.conf}" # How long start waits for the first heartbeat (remote: at least 300 s, because the box's shadow # restarts for the new run and the ingest hashes the release first). HEARTBEAT_WAIT="${FLY_SHADOW_HEARTBEAT_WAIT_SECONDS:-60}" @@ -275,14 +289,21 @@ check_remote() { start() { need_root - local mode=remote + local mode=remote arm="" for arg in "$@"; do case "$arg" in --local) mode=local ;; + --bus) arm=bus/process ;; *) die "start: unknown option $arg" ;; esac done [ -x "$BIN" ] || die "$BIN is missing: this release predates SHADOW-01" + # Only the legacy loop writes the trace the shadow follows (FLY_TRACE_DIR); the session runtime + # ignores it, and every process it ran would be a coverage divergence. + [ ! -f "$RUNTIME_DROPIN" ] || die "flysim.service runs the session runtime, which writes no trace for a shadow to follow. Switch the live fly to legacy for the shadow window first (fly-runtime legacy), then start the shadow" + if [ -n "$arm" ]; then + [ -x "$(dirname "$(readlink -f "$BIN")")/fly-session" ] || die "the bus topology needs fly-session beside $BIN" + fi systemctl is-active --quiet flyshadow.service && die "flyshadow.service is already running" if [ "$mode" = remote ]; then [ -f "$REMOTE_ENV" ] || die "no $REMOTE_ENV: the shadow runs on a build box (SHADOW-02; runbook). Pass --local to run it on this container instead, at the live fly's expense" @@ -311,6 +332,17 @@ start() { chown fly:fly "$SHADOW_DIR/baseline.json" "$samples" "$SHADOW_DIR/guard-state.json" log "baseline: $base" mkdir -p "$DROPIN_DIR" "$REMOTE_DROPIN_DIR" + if [ -n "$arm" ]; then + cat > "$MODE_DROPIN" </dev/null || true systemctl stop flyshadow.service 2>/dev/null || true - rm -f "$DROPIN" "$REMOTE_DROPIN" + rm -f "$DROPIN" "$REMOTE_DROPIN" "$MODE_DROPIN" systemctl daemon-reload log "stopped the shadow: $1" } @@ -476,6 +508,16 @@ PY } check() { + # `--bus` (BUS-01): the cutover goes onto the bus topology, so the shadow must have run it. + local -a pass=() + local arg + for arg in "$@"; do + case "$arg" in + --bus) pass+=(--require-arm bus/process) ;; + *) pass+=("$arg") ;; + esac + done + set -- "${pass[@]}" # A tripped guard, a shadow that is not running, or a run that no guard watched never allows a # cutover, whatever the verdict file says: the guard timer must be active and its baseline # present (G1-a). diff --git a/infra/docs/runbook.md b/infra/docs/runbook.md index ad0d9cc..3397d6c 100644 --- a/infra/docs/runbook.md +++ b/infra/docs/runbook.md @@ -518,6 +518,26 @@ pct exec $CTID -- /opt/fly/bin/fly-runtime legacy # the one-command rollback (flysim's limits, cpuset and environment; `Conflicts=flysim.service`; no `[Install]`, so it cannot be enabled). It is for a rehearsal or a soak on a container whose `flysim.service` is stopped, not for switching the stream. +- **The session on the bus (BUS-01).** `fly-runtime session --bus` (or `session-bus`) runs the + session's participants on the flybus router over Unix sockets: `flysim-session` (the router, the + coordinator, the listeners) starts `fly-session legacy-agent` and `fly-session legacy-environment` + as children of the same unit, in `flysim.slice`, on flysim's CPUs. The drop-in gains + `Environment=FLY_SESSION_TRANSPORT=bus`; `fly-runtime status` prints `session` and then + ` transport: bus`. `fly-runtime session` without a flag (05-deploy's refresh) keeps the transport + the drop-in has; `fly-runtime session --local` goes back to the in-process lane, and + `fly-runtime legacy` to legacy. The fallback, the probation, the watchdog and the unstick rule's + restart are the same on either transport: one unit, restarted as a whole, children included + (`ps -o pid,args --ppid $(systemctl show -p MainPID --value flysim)` lists them). A deploy + refuses a release without `fly-session` while the drop-in says `bus`. **Before switching onto the + bus, run a shadow of it** (Shadow run below): with the live fly on legacy (`fly-runtime legacy`), + `fly-shadow-run start --bus`, three hours, then `fly-shadow-run check --bus && fly-runtime + session --bus`. Watch `fly_frame_work_mean_ms` and `fly_frame_work_p99_ms` on `/metrics` (the + loop's compute time per frame, without its pacing sleep, over the last 3,600 frames; the budget + at real time is 16.74 ms): they show the headroom that a realtime factor of 1.0 hides. +- **Per-frame compute time, both runtimes.** `/metrics` exports `fly_frame_work_mean_ms`, + `fly_frame_work_p99_ms`, `fly_frame_work_max_ms` and `fly_frame_work_frames` for the legacy loop + and the session runtime alike: everything one running iteration does except the pacing sleep. + Headroom is `1 - mean / 16.74` at real time. ## Shadow run (SHADOW-01) @@ -533,6 +553,12 @@ pct exec -- /opt/fly/bin/fly-shadow-run check # CUT-01's hook: exit 0 pct exec -- /opt/fly/bin/fly-shadow-run stop --restart-flysim # shadow, guard and trace off ``` +- **A shadow of the bus topology (BUS-01).** `start --bus` runs the box's shadow session with its + agent and world as child processes on its router's sockets (`FLY_SHADOW_MODE=bus/process`, which + the relay forwards); `check --bus` also requires that the verdict ran that topology + (`candidate.transport` `bus`, `executionMode` `process`). The live fly must be on the legacy + runtime for any shadow: only the legacy loop writes the trace, and `start` refuses otherwise. + - **Where it runs (SHADOW-02).** On a build box, not on the release container: there it cost the live fly real time (2026-09-30: the realtime factor fell from 0.9998 to 0.93-0.98 and came back to 0.999-1.0 the moment the shadow stopped), and at about 27 ms a frame on shared CPUs it fell diff --git a/infra/tests/lint.sh b/infra/tests/lint.sh index b8ad3d5..ffc8782 100755 --- a/infra/tests/lint.sh +++ b/infra/tests/lint.sh @@ -735,7 +735,60 @@ rs_start "no remote file (the shadow runs on a build box; --local to override)" rs_start "a remote file without its key" "FLY_SHADOW_REMOTE=user@box FLY_SHADOW_REMOTE_KEY=$cs_tmp/missing-key FLY_SHADOW_REMOTE_KNOWN_HOSTS=$cs_tmp/missing-known" +# BUS-01: only the legacy loop writes the trace, so `start` refuses while flysim.service runs the +# session runtime; `--bus` needs the release's fly-session worker beside fly-shadow. +bs_start() { # name, expect (refuse|proceed), runtime drop-in (yes|no), worker (yes|no), args... + local name="$1" expect="$2" rt="$3" worker="$4" rc=0 out + shift 4 + : > "$cs_tmp/systemctl.log" + rm -f "$cs_tmp/10-runtime.conf" "$cs_tmp/fly-session" + [ "$rt" = yes ] && printf '[Service]\nExecStart=/opt/fly/current/flysim-session\n' > "$cs_tmp/10-runtime.conf" + [ "$worker" = yes ] && { printf '#!/bin/sh\nexit 0\n' > "$cs_tmp/fly-session"; chmod +x "$cs_tmp/fly-session"; } + out="$(PATH="$cs_tmp/bin:$PATH" CS_DIR="$cs_tmp" CS_SHADOW_CPUS="0 2" CS_SIM_CPUS="1 3" \ + FLY_SHADOW_DIR="$cs_tmp/shadow" FLY_SHADOW_BIN="$cs_tmp/fly-shadow" \ + FLY_SHADOW_CPUSET_DROPIN="$cs_tmp/dropin.conf" FLY_SHADOW_REMOTE_ENV="$cs_tmp/no-remote.env" \ + FLY_SHADOW_REMOTE_DROPIN_DIR="$cs_tmp/flyshadow.d" FLY_RUNTIME_DROPIN="$cs_tmp/10-runtime.conf" \ + FLY_SHADOW_BASELINE_SECONDS=30 FLY_METRICS_URL=http://127.0.0.1:1 \ + "$INFRA_DIR/bin/fly-shadow-run" start "$@" 2>&1)" || rc=$? + case "$expect" in + refuse) + if [ "$rc" -ne 0 ] && ! grep -qE '^(start|restart|daemon-reload)' "$cs_tmp/systemctl.log" \ + && [ ! -e "$cs_tmp/flyshadow.d/mode.conf" ]; then + pass "fly-shadow-run start refuses, $name: ${out#fly-shadow-run: }" + else + fail "fly-shadow-run start must refuse and start nothing, $name (rc=$rc): $out" + fi ;; + proceed) + if echo "$out" | grep -q 'stub install reached'; then + pass "fly-shadow-run start proceeds, $name" + else + fail "fly-shadow-run start must proceed, $name (rc=$rc): $out" + fi ;; + esac +} +bs_start "the live fly on the session runtime (no trace to follow)" refuse yes yes --local +bs_start "--bus without fly-session in the release" refuse no no --local --bus +bs_start "--bus with fly-session, live on legacy" proceed no yes --local --bus rm -rf "$cs_tmp" +# BUS-01: `check --bus` asks fly-shadow for a verdict that ran the bus topology. +if command -v python3 >/dev/null 2>&1; then + cb_tmp="$(mktemp -d "${TMPDIR:-/tmp}/fly-lint-checkbus.XXXXXX")" + mkdir -p "$cb_tmp/bin" "$cb_tmp/shadow" + printf '#!/bin/sh\ncase "$1" in is-active) exit 0 ;; esac\nexit 0\n' > "$cb_tmp/bin/systemctl" + printf '#!/bin/sh\necho "$*" > "%s/args"\n' "$cb_tmp" > "$cb_tmp/fly-shadow" + chmod +x "$cb_tmp/bin/systemctl" "$cb_tmp/fly-shadow" + printf '{"rtfMean":1,"rtfSd":0,"lagRate":0,"samples":60,"margin":0.05}\n' > "$cb_tmp/shadow/baseline.json" + printf '{"status":"pass"}\n' > "$cb_tmp/shadow/verdict.json" + PATH="$cb_tmp/bin:$PATH" FLY_SHADOW_DIR="$cb_tmp/shadow" FLY_SHADOW_BIN="$cb_tmp/fly-shadow" \ + FLY_SHADOW_REMOTE_DROPIN_DIR="$cb_tmp/none.d" FLY_ENV_FILE="$cb_tmp/none.env" \ + "$INFRA_DIR/bin/fly-shadow-run" check --bus >/dev/null 2>&1 || true + if grep -q -- '--binary flysim-session --require-arm bus/process$' "$cb_tmp/args" 2>/dev/null; then + pass "fly-shadow-run check --bus requires a verdict that ran bus/process (fly-shadow check --require-arm)" + else + fail "fly-shadow-run check --bus must pass --require-arm bus/process to fly-shadow check ($(cat "$cb_tmp/args" 2>/dev/null))" + fi + rm -rf "$cb_tmp" +fi # SHADOW-02: `check` in remote mode also needs the relay healthy now (relay.json under a minute # old), of this run (the drop-in's id, the verdict's too), without coverageLost (review B1: flysim # stopped its trace for want of a consumer) and with a live trace written in the last 90 s. @@ -1005,6 +1058,50 @@ if fly_runtime && [ ! -f "$rt_dropin" ]; then else fail "fly-runtime legacy must remove the drop-in and succeed" fi +# BUS-01: the bus transport. `session-bus` (= `session --bus`) adds FLY_SESSION_TRANSPORT=bus to +# the drop-in and needs the release's fly-session worker; a flag-less `session` (05-deploy's +# refresh) keeps the transport; `session --local` is the way back; status says which. +rt_status() { env RT_DIR="$rt_dir" PATH="$rt_dir/bin:$PATH" FLY_SYSTEMD_DIR="$rt_dir/systemd" bash "$INFRA_DIR/bin/fly-runtime" status 2>/dev/null; } +RT_ARGS=(session-bus) +if ! fly_runtime && [ ! -f "$rt_dropin" ]; then + pass "fly-runtime session-bus refuses a release without the fly-session worker" +else + fail "fly-runtime session-bus must refuse without \$FLY_RELEASE_DIR/fly-session and write nothing" +fi +printf '#!/usr/bin/env bash\nexit 0\n' > "$rt_dir/release/fly-session" +chmod +x "$rt_dir/release/fly-session" +if fly_runtime && grep -qx 'Environment=FLY_SESSION_TRANSPORT=bus' "$rt_dropin" \ + && grep -qx "ExecStart=$rt_dir/release/flysim-session" "$rt_dropin" \ + && grep -qx 'OnFailure=fly-runtime-fallback.service' "$rt_dropin" \ + && [ "$(rt_status | head -n1)" = session ] \ + && rt_status | grep -qx ' transport: bus' \ + && tail -n1 "$rt_dir/runtime.log" | grep -q 'session-bus (was legacy)'; then + pass "fly-runtime session-bus: the drop-in adds FLY_SESSION_TRANSPORT=bus (fallback and probation unchanged); status: session, transport bus" +else + fail "fly-runtime session-bus: drop-in/status/log wrong ($(tr '\n' ' ' < "$rt_dropin" 2>/dev/null); $(tail -n1 "$rt_dir/runtime.log"))" +fi +RT_ARGS=(session --no-restart) +if fly_runtime && grep -qx 'Environment=FLY_SESSION_TRANSPORT=bus' "$rt_dropin"; then + pass "fly-runtime session --no-restart (05-deploy's refresh) keeps the bus transport" +else + fail "fly-runtime session --no-restart must keep the drop-in's transport" +fi +RT_ARGS=(session --local) +if fly_runtime && [ -f "$rt_dropin" ] && ! grep -q 'FLY_SESSION_TRANSPORT' "$rt_dropin" \ + && rt_status | grep -qx ' transport: local' \ + && tail -n1 "$rt_dir/runtime.log" | grep -q 'session (was session-bus)'; then + pass "fly-runtime session --local takes the session off the bus (status: transport local)" +else + fail "fly-runtime session --local must drop FLY_SESSION_TRANSPORT from the drop-in" +fi +RT_ARGS=(legacy --bus) +if ! fly_runtime && [ -f "$rt_dropin" ]; then + pass "fly-runtime legacy --bus is refused (usage)" +else + fail "fly-runtime legacy --bus must be refused" +fi +rm -f "$rt_dir/release/fly-session" +RT_ARGS=(legacy); fly_runtime || fail "fly-runtime legacy after the bus tests failed" RT_ARGS=(session) if ! fly_runtime RT_COMPAT_FLYSIM_SESSION=other && [ ! -f "$rt_dropin" ]; then pass "fly-runtime session refuses when the two compatibility strings differ"