Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Refuse ambiguous server service discovery during updates

pulse-triage[bot]3c9a102e83f5
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 51278df518..f28e79e9c6 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -15,6 +15,32 @@
## Purpose
+### Server service discovery cannot short-read or default after an unknown inventory
+
+The server installer consumes one bounded, complete `systemctl list-unit-files`
+read for the exact historical `pulse-backend.service` and `pulse.service` names,
+with paging and truncation disabled. It preserves legacy-backend precedence,
+including masked units, and explicit custom-instance selection. Successful
+absence (or a non-systemd installation) permits the default; failed, timed-out,
+partial, malformed, duplicate, impostor or unknown-state inventory does not.
+This avoids an early pipe close hiding an installed legacy service under
+`pipefail`. Discovery itself never stops, enables or unmasks a unit.
+
+Existing-install detection distinguishes an unavailable inventory from no
+installation. Main, archive/source replacement, unit creation, removal and
+reset propagate the refusal even when a caller disables Bash errexit: no
+default-based service operation, fresh-install fallback, live executable
+replacement or destructive removal follows that refusal. Admitted executable
+staging and existing stop/readback/recovery safeguards remain unchanged.
+
+`TestRootInstallServiceDiscoveryFailsClosedWithoutShortReads` executes the
+actual shell functions and callers with confined command doubles, a
+deterministic pipe-buffer control, fake versioned archive/build inputs and an
+optional real `systemctl --root` inventory. Only the unit-writer test relocates
+its fixed output path. It proves selection and refusal propagation, not release
+signature trust, real compilation, native systemd restart, an LXC stop cause or
+installed update/recovery. Those remain separate operational evidence.
+
### Core E2E images are built once and admitted in the same run
The secret-free Core E2E workflow builds its existing `e2e_runtime` server and
diff --git a/install.sh b/install.sh
index 52497d8dd4..d05155d758 100755
--- a/install.sh
+++ b/install.sh
@@ -762,12 +762,40 @@ detect_service_name() {
return
fi
- if systemctl list-unit-files --no-legend | grep -q "^pulse-backend.service"; then
+ local unit_files="" unit="" state="" preset="" extra=""
+ local seen_backend=false seen_pulse=false
+ # grep -q closes a full inventory early: systemctl can report Broken pipe,
+ # and pipefail then hides a real pulse-backend unit behind the default.
+ # Consume one bounded inventory of the two exact historical names instead.
+ if ! unit_files=$(LC_ALL=C timeout -k 1 5 systemctl list-unit-files --no-legend --no-pager --full -- pulse-backend.service pulse.service 2>/dev/null); then
+ print_error "Cannot identify the Pulse systemd service: unit inventory failed. Reconcile service state before retrying." >&2
+ return 1
+ fi
+ while read -r unit state preset extra; do
+ [[ -n "$unit" ]] || continue
+ if [[ "$unit" == pulse-backend.service && "$seen_backend" == false ]]; then
+ seen_backend=true
+ elif [[ "$unit" == pulse.service && "$seen_pulse" == false ]]; then
+ seen_pulse=true
+ else
+ print_error "Cannot identify the Pulse systemd service: unexpected unit inventory. No default service was selected." >&2
+ return 1
+ fi
+ case "$state" in
+ enabled|enabled-runtime|disabled|static|indirect|linked|linked-runtime|alias|generated|transient|masked|masked-runtime) ;;
+ *)
+ print_error "Cannot identify the Pulse systemd service: unknown unit state. No default service was selected." >&2
+ return 1 ;;
+ esac
+ if [[ -n "$extra" ]]; then
+ print_error "Cannot identify the Pulse systemd service: malformed unit inventory. No default service was selected." >&2
+ return 1
+ fi
+ done <<< "$unit_files"
+ if [[ "$seen_backend" == true ]]; then
echo "pulse-backend"
- elif systemctl list-unit-files --no-legend | grep -q "^pulse.service"; then
- echo "pulse"
else
- echo "pulse" # Default for new installations
+ echo "$DEFAULT_SERVICE_NAME" # A successful empty read permits a new installation.
fi
}
@@ -2958,7 +2986,9 @@ check_existing_installation() {
# Detect actual service name if systemd is available
if command -v systemctl >/dev/null 2>&1; then
if [[ "$SERVICE_NAME_EXPLICIT" != "true" ]]; then
- detected_service=$(detect_service_name)
+ # Status 1 below means no installation. Keep an unavailable
+ # inventory distinct so main cannot fall through to a fresh install.
+ detected_service=$(detect_service_name) || return 2
SERVICE_NAME="$detected_service"
fi
service_available=true
@@ -3544,7 +3574,10 @@ install_pulse_archive() {
return 1
fi
- service_name=$(detect_service_name)
+ if ! service_name=$(detect_service_name); then
+ rm -rf "$binary_stage" "$temp_extract"
+ return 1
+ fi
PULSE_WAS_ACTIVE="false"
if ! stop_pulse_for_replacement "$service_name"; then
rm -rf "$binary_stage" "$temp_extract"
@@ -3997,7 +4030,11 @@ build_from_source() {
return 1
fi
- service_name=$(detect_service_name)
+ if ! service_name=$(detect_service_name); then
+ cd "$original_dir" >/dev/null 2>&1 || true
+ rm -rf "$binary_stage" "$temp_build"
+ return 1
+ fi
PULSE_WAS_ACTIVE="false"
if ! stop_pulse_for_replacement "$service_name"; then
cd "$original_dir" >/dev/null 2>&1 || true
@@ -4802,7 +4839,7 @@ install_systemd_service() {
# Use existing service name if found, otherwise use default
local existing_service="$SERVICE_NAME"
if [[ "$SERVICE_NAME_EXPLICIT" != "true" ]]; then
- existing_service=$(detect_service_name)
+ existing_service=$(detect_service_name) || return 1
fi
if [[ "$existing_service" == "pulse-backend" ]] && [[ -f "/etc/systemd/system/pulse-backend.service" ]]; then
# Keep using pulse-backend for compatibility (ProxmoxVE)
@@ -4872,7 +4909,7 @@ ensure_systemd_service_installed() {
command -v systemctl >/dev/null 2>&1 || return 0
if [[ ! -f "/etc/systemd/system/${SERVICE_NAME}.service" ]]; then
print_warn "systemd unit ${SERVICE_NAME}.service is missing; recreating it"
- install_systemd_service
+ install_systemd_service || return 1
fi
}
@@ -5111,7 +5148,12 @@ main() {
check_docker_environment
# Check for existing installation FIRST before asking for configuration
- if check_existing_installation; then
+ local existing_install_status=0
+ check_existing_installation || existing_install_status=$?
+ if [[ "$existing_install_status" -gt 1 ]]; then
+ return "$existing_install_status"
+ fi
+ if [[ "$existing_install_status" -eq 0 ]]; then
# If building from source was requested, skip the update prompt
if [[ "$BUILD_FROM_SOURCE" == "true" ]]; then
create_user
@@ -5122,7 +5164,7 @@ main() {
fi
setup_update_command
- install_systemd_service
+ install_systemd_service || return 1
if [[ "$ENABLE_AUTO_UPDATES" == "true" ]]; then
setup_auto_updates
@@ -5154,7 +5196,7 @@ main() {
offer_existing_auto_updates
# Detect the actual service name before trying to stop it
- SERVICE_NAME=$(detect_service_name)
+ SERVICE_NAME=$(detect_service_name) || return 1
if ! run_upgrade_readiness_preflight "$CURRENT_VERSION" "$LATEST_RELEASE"; then
exit 1
@@ -5169,7 +5211,7 @@ main() {
# a missing config dir or reporting success over a missing unit.
setup_directories
setup_update_command
- ensure_systemd_service_installed
+ ensure_systemd_service_installed || return 1
# Setup auto-updates if requested
if [[ "$ENABLE_AUTO_UPDATES" == "true" ]]; then
@@ -5374,7 +5416,7 @@ main() {
# file back before auto-update setup and start.
setup_directories
setup_update_command
- ensure_systemd_service_installed
+ ensure_systemd_service_installed || return 1
# Setup auto-updates if requested during update; otherwise
# refresh assets a previous install already put in place so a
@@ -5403,7 +5445,7 @@ main() {
download_pulse
setup_directories
setup_update_command
- install_systemd_service
+ install_systemd_service || return 1
# Setup auto-updates if requested during reinstall; otherwise
# refresh assets a previous install already put in place
@@ -5526,7 +5568,7 @@ main() {
setup_directories
download_pulse
setup_update_command
- install_systemd_service
+ install_systemd_service || return 1
# Setup auto-updates if requested; a leftover timer from a previous
# install still gets its helper script and units refreshed
@@ -5641,7 +5683,7 @@ uninstall_pulse() {
# Detect service name
local service_name
- service_name=$(detect_service_name)
+ service_name=$(detect_service_name) || return 1
if ! quiesce_pulse_for_removal "$service_name"; then
print_error "Pulse removal is incomplete; no files have been removed. Previously stopped units are not automatically restarted."
@@ -5732,7 +5774,7 @@ reset_pulse() {
echo
local service_name unit i prior_enabled
- service_name=$(detect_service_name)
+ service_name=$(detect_service_name) || return 1
service_name="${service_name%.service}.service"
local units=("$UPDATE_TIMER_UNIT") roles=(timer)
# Historical default aliases share the same configuration. Custom instances
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index 77d5c2e096..39da655997 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -4556,6 +4556,19 @@ func TestRootInstallTimerDiscoveryReachesConsentPreservingRefresh(t *testing.T)
}
}
+// Execute bounded service discovery with every mutation-owning consumer,
+// including OR-list callers where Bash does not apply errexit to the function.
+func TestRootInstallServiceDiscoveryFailsClosedWithoutShortReads(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_server_service_discovery.py"), "-v")
+ cmd.Env = append(os.Environ(), "PULSE_INSTALLER_UNDER_TEST="+repoFile("install.sh"))
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("installer service discovery/caller controls: %v\n%s", err, out)
+ }
+}
+
func TestRootInstallStableReleaseTagRejectsPrereleaseShapes(t *testing.T) {
script := `
` + extractRootInstallShellFunction(t, "is_stable_release_tag") + `
diff --git a/scripts/tests/test_server_service_discovery.py b/scripts/tests/test_server_service_discovery.py
new file mode 100644
index 0000000000..080bad7247
--- /dev/null
+++ b/scripts/tests/test_server_service_discovery.py
@@ -0,0 +1,308 @@
+#!/usr/bin/env python3
+"""Execute server service discovery and its callers with confined manager doubles.
+
+Archive/source fixtures use fake versioned executables, not trusted releases or
+real builds. Only the unit-writer fixture relocates its fixed /etc destination.
+The optional real inventory uses systemctl --root, never the host unit manager.
+"""
+
+import io
+import json
+import os
+from pathlib import Path
+import shutil
+import subprocess
+import tarfile
+import tempfile
+import time
+import unittest
+
+
+ROOT = Path(__file__).resolve().parents[2]
+INSTALLER = Path(os.environ.get("PULSE_INSTALLER_UNDER_TEST", ROOT / "install.sh"))
+REAL_SYSTEMCTL = shutil.which("systemctl")
+QUERY = ["list-unit-files", "--no-legend", "--no-pager", "--full", "--",
+ "pulse-backend.service", "pulse.service"]
+
+SYSTEMCTL = r'''#!/usr/bin/env python3
+import json, os, sys, time
+from pathlib import Path
+f = Path(os.environ["FIXTURE"])
+args = sys.argv[1:]
+with (f / "calls").open("a") as stream:
+ stream.write(json.dumps(args) + "\n")
+if args[0] == "list-unit-files":
+ mode = os.environ["MODE"]
+ if mode == "real":
+ os.execv(os.environ["REAL_SYSTEMCTL"],
+ [os.environ["REAL_SYSTEMCTL"], "--root=" + str(f / "root")] + args)
+ if mode == "hang":
+ time.sleep(30)
+ if mode == "large":
+ # An early grep match followed by more than a pipe buffer makes the
+ # parent's short read fail deterministically, not just emit a warning.
+ os.write(1, b"pulse-backend.service enabled enabled\n")
+ if "--" not in args:
+ try:
+ for i in range(512):
+ os.write(1, b"unrelated.service disabled enabled\n" * 128)
+ except BrokenPipeError:
+ (f / "broken-pipe").write_text("producer failed after early close\n")
+ os.write(2, b"Failed to print table: Broken pipe\n")
+ os._exit(1)
+ sys.exit(0)
+ os.write(1, os.environ["ROWS"].encode())
+ sys.exit(int(os.environ["QUERY_EXIT"]))
+if args[0] == "show":
+ print("inactive" if (f / "stopped").exists() else "active")
+ sys.exit(0)
+if args[0] == "is-active":
+ sys.exit(1 if (f / "stopped").exists() else 0)
+if args[0] == "stop":
+ (f / "stopped").write_text(args[1])
+ sys.exit(0)
+if args[0] == "daemon-reload":
+ sys.exit(0)
+sys.exit(97)
+'''
+
+HARNESS = r'''
+source "$INSTALLER"
+print_header() { :; }
+print_info() { echo "$*" >&2; }
+print_warn() { echo "$*" >&2; }
+print_error() { echo "$*" >&2; }
+print_success() { echo "$*" >&2; }
+check_root() { :; }
+check_proxmox_host() { return 1; }
+detect_os() { :; }
+check_docker_environment() { :; }
+IN_CONTAINER=true
+IN_DOCKER=false
+mark_mutation() { echo "$*" >> "$FIXTURE/mutations"; return 97; }
+case "$FLOW" in
+ unavailable)
+ command() {
+ [[ "$*" != '-v systemctl' ]] || return 1
+ builtin command "$@"
+ }
+ ;;
+ main|late-main)
+ FORCE_VERSION=v6.6.0
+ offer_existing_auto_updates() { :; }
+ run_upgrade_readiness_preflight() { :; }
+ backup_existing() { mark_mutation backup; }
+ create_user() { mark_mutation user; }
+ install_dependencies() { mark_mutation packages; }
+ setup_directories() { mark_mutation directories; }
+ download_pulse() { mark_mutation download; }
+ install_systemd_service() { mark_mutation unit; }
+ ensure_systemd_service_installed() { mark_mutation unit; }
+ setup_update_command() { mark_mutation helper; }
+ setup_auto_updates() { mark_mutation timer; }
+ refresh_auto_updates() { mark_mutation refresh; }
+ start_pulse() { mark_mutation start; }
+ create_marker_file() { mark_mutation marker; }
+ print_completion() { :; }
+ if [[ "$FLOW" == late-main ]]; then
+ check_existing_installation() { CURRENT_VERSION=v6.5.0; return 0; }
+ fi
+ ;;
+ archive|build)
+ verify_release_signature() { :; }
+ validate_pulse_binary_architecture() { :; }
+ detect_pulse_architecture() { echo amd64; }
+ chown() { :; }
+ install_additional_agent_binaries() { :; }
+ deploy_agent_scripts() { :; }
+ if [[ "$FLOW" == build ]]; then
+ apt-get() { :; }
+ go() { echo 'go version go1.26.9 linux/amd64'; }
+ npm() { :; }
+ make() { cp "$FIXTURE/new-pulse" pulse; }
+ git() {
+ if [[ "$1" == clone ]]; then
+ mkdir -p "${@: -1}/frontend-modern"
+ else
+ echo abc1234
+ fi
+ }
+ fi
+ ;;
+ uninstall)
+ quiesce_pulse_for_removal() { mark_mutation "remove $*"; }
+ ;;
+ reset)
+ read_pulse_reset_unit_state() { mark_mutation "reset $*"; }
+ ;;
+ unit|ensure-unit)
+ # Only fixed path relocation; the function's discovery, branch and
+ # redirection remain production code. Never write the host's /etc.
+ source "$FIXTURE/unit-writer.sh"
+ ;;
+esac
+status=0
+# Deliberately invoke inside an OR-list: callers must handle discovery errors
+# explicitly, even when Bash disables errexit throughout the function.
+case "$FLOW" in
+ query|unavailable) selected=$(detect_service_name) || status=$?
+ [[ "$status" -ne 0 ]] || printf 'SERVICE=%s\n' "$selected" ;;
+ existing) check_existing_installation || status=$?
+ [[ "$status" -ne 0 ]] || printf 'SERVICE=%s\n' "$SERVICE_NAME" ;;
+ main|late-main) main || status=$? ;;
+ archive) install_pulse_archive "$FIXTURE/pulse-v6.6.0-linux-amd64.tar.gz" v6.6.0 || status=$? ;;
+ build) build_from_source main || status=$? ;;
+ uninstall) uninstall_pulse || status=$? ;;
+ reset) reset_pulse || status=$? ;;
+ unit) install_systemd_service || status=$? ;;
+ ensure-unit) ensure_systemd_service_installed || status=$? ;;
+ *) exit 98 ;;
+esac
+exit "$status"
+'''
+
+
+class ServiceDiscovery(unittest.TestCase):
+ def run_fixture(self, *, rows="", mode="rows", query_exit=0, flow="query", explicit=None):
+ with tempfile.TemporaryDirectory(prefix="pulse-service-discovery-") as directory:
+ f = Path(directory)
+ for name in ["bin", "install/bin", "config", "units", "root/etc/systemd/system"]:
+ (f / name).mkdir(parents=True)
+ (f / "bin/systemctl").write_text(SYSTEMCTL)
+ (f / "bin/systemctl").chmod(0o755)
+ old = b"#!/bin/sh\necho 'Pulse version v6.5.0'\n"
+ new = b"#!/bin/sh\necho 'Pulse version v6.6.0'\n"
+ (f / "install/bin/pulse").write_bytes(old)
+ (f / "install/bin/pulse").chmod(0o755)
+ (f / "new-pulse").write_bytes(new)
+ (f / "new-pulse").chmod(0o755)
+ archive = f / "pulse-v6.6.0-linux-amd64.tar.gz"
+ with tarfile.open(archive, "w:gz") as stream:
+ entry = tarfile.TarInfo("pulse")
+ entry.size, entry.mode = len(new), 0o755
+ stream.addfile(entry, io.BytesIO(new))
+ Path(str(archive) + ".sshsig").write_text("signature verification is a double\n")
+ source = INSTALLER.read_text()
+ start = source.index("install_systemd_service() {")
+ end = source.index("\n}\n", start) + 3
+ body = source[start:end].replace("/etc/systemd/system/", str(f / "units") + "/")
+ (f / "unit-writer.sh").write_text(body)
+ unit = "[Unit]\nDescription=Fixture only\n[Service]\nExecStart=/bin/true\n"
+ (f / "root/etc/systemd/system/pulse-backend.service").write_text(unit)
+ (f / "root/etc/systemd/system/pulse.service").write_text(unit)
+ env = {k: v for k, v in os.environ.items() if not k.startswith("PULSE_")}
+ env.update(FIXTURE=str(f), INSTALLER=str(INSTALLER), FLOW=flow, MODE=mode,
+ ROWS=rows, QUERY_EXIT=str(query_exit), REAL_SYSTEMCTL=REAL_SYSTEMCTL or "",
+ PATH=str(f / "bin") + os.pathsep + os.environ["PATH"],
+ PULSE_INSTALL_DIR=str(f / "install"), PULSE_CONFIG_DIR=str(f / "config"),
+ PULSE_BINARY_LINK_PATH=str(f / "pulse-link"))
+ if explicit is not None:
+ env["PULSE_SERVICE_NAME"] = explicit
+ start_time = time.monotonic()
+ result = subprocess.run(["bash", "-c", HARNESS], env=env, cwd=f,
+ text=True, capture_output=True, timeout=15)
+ return dict(result=result, seconds=time.monotonic() - start_time,
+ calls=[json.loads(line) for line in (f / "calls").read_text().splitlines()]
+ if (f / "calls").exists() else [],
+ mutations=(f / "mutations").read_text() if (f / "mutations").exists() else "",
+ binary=(f / "install/bin/pulse").read_bytes(), old=old, new=new,
+ units=[p.name for p in (f / "units").iterdir()],
+ broken_pipe=(f / "broken-pipe").exists())
+
+ def assert_refused(self, e):
+ self.assertNotEqual(e["result"].returncode, 0, e["result"])
+ self.assertIn("Cannot identify the Pulse systemd service", e["result"].stderr)
+ self.assertNotIn("SERVICE=", e["result"].stdout)
+ self.assertEqual(e["binary"], e["old"])
+ self.assertEqual(e["mutations"], "")
+ self.assertEqual(e["units"], [])
+ self.assertTrue(all(call == QUERY for call in e["calls"]), e["calls"])
+
+ def test_large_inventory_cannot_short_read_and_hide_legacy_service(self):
+ e = self.run_fixture(mode="large")
+ self.assertEqual(e["result"].returncode, 0, e["result"].stderr)
+ self.assertEqual(e["result"].stdout, "SERVICE=pulse-backend\n")
+ self.assertEqual(e["calls"], [QUERY])
+ self.assertFalse(e["broken_pipe"])
+
+ def test_exact_names_and_legacy_precedence_with_state_columns(self):
+ for rows, expected in [("", "pulse"), ("\n", "pulse"),
+ ("pulse.service disabled enabled\n", "pulse"),
+ ("pulse-backend.service disabled\n", "pulse-backend"),
+ ("pulse.service static -\npulse-backend.service masked-runtime enabled\n", "pulse-backend"),
+ ("pulse-backend.service enabled enabled\npulse.service alias -\n", "pulse-backend")]:
+ with self.subTest(rows=rows):
+ e = self.run_fixture(rows=rows)
+ self.assertEqual(e["result"].returncode, 0, e["result"].stderr)
+ self.assertEqual(e["result"].stdout, "SERVICE=" + expected + "\n")
+ self.assertEqual(e["calls"], [QUERY])
+
+ def test_explicit_instances_skip_default_inventory(self):
+ for service in ["pulse", "pulse-backend", "pulse.department" + "x" * 140]:
+ with self.subTest(service=service):
+ e = self.run_fixture(explicit=service, query_exit=1)
+ self.assertEqual(e["result"].returncode, 0)
+ self.assertEqual(e["result"].stdout, "SERVICE=" + service + "\n")
+ self.assertEqual(e["calls"], [])
+
+ def test_non_systemd_install_keeps_default(self):
+ e = self.run_fixture(flow="unavailable")
+ self.assertEqual(e["result"].returncode, 0)
+ self.assertEqual(e["result"].stdout, "SERVICE=pulse\n")
+ self.assertEqual(e["calls"], [])
+
+ def test_partial_failed_inventory_is_not_absence(self):
+ for rows in ["", "pulse-backend.service enabled enabled\n", "pulse.service disabled enabled\n"]:
+ with self.subTest(rows=rows):
+ self.assert_refused(self.run_fixture(rows=rows, query_exit=1))
+
+ def test_malformed_duplicate_impostor_and_unknown_inventory_stop(self):
+ for rows in ["pulse-backendXservice enabled\n", "pulse-backend.service.extra enabled\n",
+ "pulseXservice enabled\n", "unrelated.service enabled\n",
+ "pulse-backend.service\n", "pulse.service bad enabled\n",
+ "pulse.service future-state enabled\n", "pulse.service enabled enabled extra\n",
+ "pulse.service enabled\npulse.service disabled\n",
+ "pulse-backend.service enabled\npulse-backend.service enabled\n"]:
+ with self.subTest(rows=rows):
+ self.assert_refused(self.run_fixture(rows=rows))
+
+ def test_inventory_timeout_is_bounded_and_refuses(self):
+ e = self.run_fixture(mode="hang")
+ self.assert_refused(e)
+ self.assertLess(e["seconds"], 7)
+
+ def test_existing_install_retains_legacy_service(self):
+ e = self.run_fixture(flow="existing", mode="large")
+ self.assertEqual(e["result"].returncode, 0, e["result"].stderr)
+ self.assertEqual(e["result"].stdout, "SERVICE=pulse-backend\n")
+
+ def test_failed_discovery_is_distinct_from_no_installation(self):
+ e = self.run_fixture(flow="existing", query_exit=1)
+ self.assert_refused(e)
+ self.assertEqual(e["result"].returncode, 2)
+
+ def test_all_mutating_callers_refuse_when_errexit_is_disabled(self):
+ for flow in ["main", "late-main", "archive", "build", "uninstall", "reset", "unit", "ensure-unit"]:
+ with self.subTest(flow=flow):
+ self.assert_refused(self.run_fixture(flow=flow, query_exit=1))
+
+ def test_archive_and_source_paths_stop_only_the_selected_legacy_unit(self):
+ for flow in ["archive", "build"]:
+ with self.subTest(flow=flow):
+ e = self.run_fixture(flow=flow, mode="large")
+ self.assertEqual(e["result"].returncode, 0, e["result"].stderr)
+ self.assertEqual(e["binary"], e["new"])
+ self.assertIn(["stop", "pulse-backend"], e["calls"])
+ self.assertNotIn(["stop", "pulse"], e["calls"])
+ self.assertFalse(e["broken_pipe"])
+
+ @unittest.skipUnless(REAL_SYSTEMCTL, "systemctl unavailable")
+ def test_real_systemctl_fixture_inventory_has_compatible_rows(self):
+ e = self.run_fixture(mode="real")
+ self.assertEqual(e["result"].returncode, 0, e["result"].stderr)
+ self.assertEqual(e["result"].stdout, "SERVICE=pulse-backend\n")
+ self.assertEqual(e["calls"], [QUERY])
+
+
+if __name__ == "__main__":
+ unittest.main()