mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 01:32:00 +01:00
Parallelize isolated scripts/installtests race tests
Enable top-level t.Parallel() across 19 unclaimed scripts/installtests files (and subtest-level t.Parallel() on isolated subtest loops using per-subtest temp dirs and loopback servers), plus isolate the local configErr variable inside TestManualUpdateChannelAdmission's subtests so parallel subtests do not share the outer err variable under -race. No production code, installer scripts, assertions, or timeout budgets changed. Contract-Neutral: test-only parallelism in isolated scripts/installtests suites without production or contract changes Change-source: pulse-maintainer
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAgentInstallerARMv6SavedStateRepairPreflight(t *testing.T) {
|
||||
t.Parallel()
|
||||
var requests []string
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
requests = append(requests, r.Method+" "+r.URL.RequestURI())
|
||||
@@ -76,6 +77,7 @@ func TestAgentInstallerARMv6SavedStateRepairPreflight(t *testing.T) {
|
||||
// a release/device qualification boundary. ARM target selection is covered by
|
||||
// the full installer preflight above and ARM execution by the updater proof.
|
||||
func TestAgentInstallerSavedStateRepairVerifiedReplacement(t *testing.T) {
|
||||
t.Parallel()
|
||||
assets := os.Getenv("PULSE_AGENT_RELEASE_TEST_DIR")
|
||||
if assets == "" {
|
||||
t.Skip("requires canonical native release executable packet")
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
// service inventory is doubled; no binary is downloaded, installed or run.
|
||||
// Stalls use the production ten-second budget, not an accelerated curl double.
|
||||
func TestAgentInstallerPreflightHealthDeadline(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, mode := range []string{"healthy", "redirect", "http-error", "untrusted-ca", "stalled-headers", "stalled-body", "redirect-budget", "metadata-http-error", "configured-url", "explicit-insecure", "typed-artifacts", "environment-proxy"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -533,6 +533,7 @@ func TestPulseAgentStateDirLifecycleIntegration(t *testing.T) {
|
||||
{name: "custom_state_commands_enabled", commandsEnabled: true, customState: true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
stateName := "default-state"
|
||||
if tc.customState {
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
// boot, so the installer must stage, install, and run the agent from the
|
||||
// data volume instead. Refs #1617.
|
||||
func TestInstallSHRelocatesQNAPInstallToDataVolume(t *testing.T) {
|
||||
t.Parallel()
|
||||
content, err := os.ReadFile(repoFile("scripts", "install.sh"))
|
||||
if err != nil {
|
||||
t.Fatalf("read install.sh: %v", err)
|
||||
@@ -37,6 +38,7 @@ func TestInstallSHRelocatesQNAPInstallToDataVolume(t *testing.T) {
|
||||
// With the data-volume layout the stored and runtime binaries are one file;
|
||||
// the rendered watchdog must start the agent without a boot-time self-copy.
|
||||
func TestRenderedQNAPWatchdogRunsUnifiedStoredRuntimeBinary(t *testing.T) {
|
||||
t.Parallel()
|
||||
content, err := os.ReadFile(repoFile("scripts", "install.sh"))
|
||||
if err != nil {
|
||||
t.Fatalf("read install.sh: %v", err)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@ import (
|
||||
// Exercise the generated helper, not a second copy of its channel parser. The
|
||||
// transport is local-only, but the installer and sidecar use real SSH signatures.
|
||||
func TestManualUpdateChannelAdmission(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tool := range []string{"bash", "jq", "ssh-keygen"} {
|
||||
if _, err := exec.LookPath(tool); err != nil {
|
||||
t.Fatalf("manual update proof requires %s: %v", tool, err)
|
||||
@@ -155,22 +156,24 @@ exit "$MANUAL_UPDATE_EXIT"
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
configDir := filepath.Join(dir, "config")
|
||||
if err := os.Mkdir(configDir, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
configPath := filepath.Join(configDir, "system.json")
|
||||
var configErr error
|
||||
switch {
|
||||
case tc.directory:
|
||||
err = os.Mkdir(configPath, 0700)
|
||||
configErr = os.Mkdir(configPath, 0700)
|
||||
case tc.brokenLink:
|
||||
err = os.Symlink(filepath.Join(dir, "absent"), configPath)
|
||||
configErr = os.Symlink(filepath.Join(dir, "absent"), configPath)
|
||||
case !tc.missingConfig:
|
||||
err = os.WriteFile(configPath, []byte(tc.config), 0600)
|
||||
configErr = os.WriteFile(configPath, []byte(tc.config), 0600)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
if configErr != nil {
|
||||
t.Fatal(configErr)
|
||||
}
|
||||
if tc.marker != "" {
|
||||
if err := os.WriteFile(filepath.Join(dir, "BUILD_FROM_SOURCE"), []byte(tc.marker), 0600); err != nil {
|
||||
|
||||
@@ -99,6 +99,7 @@ func nativeInstallerFixtureSteps(t *testing.T) (nativeGuidanceStep, nativeGuidan
|
||||
}
|
||||
|
||||
func TestNativeInstallerPhasesKeepNASBeforeFrontendAndAllChecksGating(t *testing.T) {
|
||||
t.Parallel()
|
||||
content, err := os.ReadFile(repoFile(".github", "workflows", "unified-agent-native.yml"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -121,6 +122,7 @@ func TestNativeInstallerPhasesKeepNASBeforeFrontendAndAllChecksGating(t *testing
|
||||
remaining := indices["Test native Unix installer contracts"]
|
||||
for _, scenario := range []string{"missing preflight", "missing remaining", "duplicate preflight", "after Node", "before tools", "Linux only", "hidden early failure", "hidden remaining failure", "all checks repeated", "no remaining checks", "nonlocal tools", "wrong directory"} {
|
||||
t.Run(scenario, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
changed := append([]nativeGuidanceStep(nil), steps...)
|
||||
switch scenario {
|
||||
case "missing preflight":
|
||||
@@ -201,6 +203,7 @@ func runNativeInstallerFixtureCommand(t *testing.T, limit time.Duration, env []s
|
||||
}
|
||||
|
||||
func TestNativeInstallerFixtureToolsAreRealAndStepLocal(t *testing.T) {
|
||||
t.Parallel()
|
||||
supply, preflight, installer := nativeInstallerFixtureSteps(t)
|
||||
for _, scenario := range []string{"real tools", "symlinked fixture root", "streamed version output", "failed version producer", "install failure", "missing bash", "legacy bash", "missing stat", "non-GNU chmod", "missing cp", "non-GNU cp", "missing mv", "non-GNU mv", "missing ln", "non-GNU ln", "missing readlink", "non-GNU readlink", "missing sha256sum", "non-GNU sha256sum", "missing tar", "non-GNU tar", "missing awk", "non-GNU awk", "missing flock", "missing sed", "non-GNU sed"} {
|
||||
t.Run(scenario, func(t *testing.T) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
// without recursively running the installer suite. Native CI supplies the
|
||||
// platform timing proof; these controls reject lost checks and false passes.
|
||||
func TestNativeUnixContractRunnerPartitionsWithoutDroppingChecks(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, "python3", "-I", "-S", repoFile("scripts", "tests", "test_native_installer_contract_runner.py"))
|
||||
@@ -71,6 +72,7 @@ func TestInstallMCPTransport(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
tools, downloads, destination := filepath.Join(root, "tools"), filepath.Join(root, "downloads"), filepath.Join(root, "install with spaces")
|
||||
for _, path := range []string{tools, downloads, destination} {
|
||||
|
||||
@@ -12,9 +12,11 @@ import (
|
||||
)
|
||||
|
||||
func TestProviderMSPStartupFixturesStayLinuxOnly(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, platform := range []string{"linux", "windows", "darwin"} {
|
||||
for _, name := range []string{"provider_msp_startup_test.go", "provider_msp_startup_command_test.go"} {
|
||||
t.Run(platform+"/"+name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := build.Default
|
||||
ctx.GOOS, ctx.GOARCH = platform, "amd64"
|
||||
included, err := ctx.MatchFile(repoFile("scripts", "installtests"), name)
|
||||
@@ -32,6 +34,7 @@ func TestProviderMSPStartupFixturesStayLinuxOnly(t *testing.T) {
|
||||
// Exercise the real command helper with separate child-process output streams.
|
||||
// Compose emits unset-variable warnings on stderr even when a read succeeds.
|
||||
func TestProviderMSPStartupCommandReadbackSeparatesStderr(t *testing.T) {
|
||||
t.Parallel()
|
||||
binary, err := os.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -47,6 +50,7 @@ func TestProviderMSPStartupCommandReadbackSeparatesStderr(t *testing.T) {
|
||||
{"no_owned_resources", ""},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := append(os.Environ(),
|
||||
"PULSE_TEST_MSP_COMMAND_HELPER=emit",
|
||||
"PULSE_TEST_MSP_COMMAND_STDOUT="+tc.stdout,
|
||||
@@ -61,6 +65,7 @@ func TestProviderMSPStartupCommandReadbackSeparatesStderr(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProviderMSPStartupCommandFailureRetainsBothStreams(t *testing.T) {
|
||||
t.Parallel()
|
||||
binary, err := os.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -62,6 +62,7 @@ exit "$PULSE_TEST_TIMER_EXIT"
|
||||
}
|
||||
|
||||
func TestAutoUpdateRequiresVerifiedCommunityEdition(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
name, body, legacy string
|
||||
status int // Pro=0, verified community=1, unknown=2.
|
||||
@@ -89,6 +90,7 @@ func TestAutoUpdateRequiresVerifiedCommunityEdition(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "bin"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -132,6 +134,7 @@ printf 'STATUS=%s\n' "$status"
|
||||
}
|
||||
|
||||
func TestAutoUpdateEditionProbeHasHardDeadline(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "bin"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -155,6 +158,7 @@ printf 'STATUS=%s\n' "$status"
|
||||
}
|
||||
|
||||
func TestAutoUpdateEditionGateStopsMainBeforeDownloads(t *testing.T) {
|
||||
t.Parallel()
|
||||
if _, err := os.Stat("/.dockerenv"); err == nil {
|
||||
t.Fatal("edition main-flow proof requires a non-Docker environment")
|
||||
}
|
||||
@@ -175,6 +179,7 @@ func TestAutoUpdateEditionGateStopsMainBeforeDownloads(t *testing.T) {
|
||||
{"missing_binary", "", 1, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "bin"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -217,6 +222,7 @@ main
|
||||
}
|
||||
|
||||
func TestAutoUpdateRequiresCompleteTopLevelConsent(t *testing.T) {
|
||||
t.Parallel()
|
||||
if _, err := exec.LookPath("jq"); err != nil {
|
||||
t.Fatal("jq is required to execute the unattended-update consent checks")
|
||||
}
|
||||
@@ -250,6 +256,7 @@ func TestAutoUpdateRequiresCompleteTopLevelConsent(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "system.json"), []byte(tc.config), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -283,8 +290,10 @@ echo ADMITTED
|
||||
}
|
||||
|
||||
func TestAutoUpdateConsentKeepsTimerAndParserBoundaries(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, scenario := range []string{"missing_config_enabled_timer", "disabled_timer", "missing_jq", "nonregular_config"} {
|
||||
t.Run(scenario, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
script := `set -eu
|
||||
log() { printf '%s\n' "$*"; }
|
||||
@@ -328,6 +337,7 @@ log() { printf '%s\n' "$*"; }
|
||||
}
|
||||
|
||||
func TestAutoUpdateTimerEnablementNeedsConfirmedRead(t *testing.T) {
|
||||
t.Parallel()
|
||||
updater, err := filepath.Abs(filepath.Join("..", "pulse-auto-update.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -428,6 +438,7 @@ curl() { echo UNEXPECTED_NETWORK; exit 99; }
|
||||
}
|
||||
|
||||
func TestAutoUpdateTimerEnablementHasHardDeadline(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
@@ -501,6 +512,7 @@ func waitForAutoUpdateTimerExit(readStat func() ([]byte, error), deadline time.T
|
||||
}
|
||||
|
||||
func TestAutoUpdateTimerExitObservation(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
states []string
|
||||
@@ -516,6 +528,7 @@ func TestAutoUpdateTimerExitObservation(t *testing.T) {
|
||||
{name: "missing_state", states: []string{"42 (sleep) "}, want: "invalid manager state"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
reads := 0
|
||||
err := waitForAutoUpdateTimerExit(func() ([]byte, error) {
|
||||
reads++
|
||||
@@ -533,6 +546,7 @@ func TestAutoUpdateTimerExitObservation(t *testing.T) {
|
||||
})
|
||||
}
|
||||
t.Run("expired_deadline", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := waitForAutoUpdateTimerExit(func() ([]byte, error) {
|
||||
t.Fatal("must not accept a late observation")
|
||||
return nil, os.ErrNotExist
|
||||
@@ -542,6 +556,7 @@ func TestAutoUpdateTimerExitObservation(t *testing.T) {
|
||||
}
|
||||
})
|
||||
t.Run("late_terminal_observation", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := waitForAutoUpdateTimerExit(func() ([]byte, error) {
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
return nil, os.ErrNotExist
|
||||
@@ -553,6 +568,7 @@ func TestAutoUpdateTimerExitObservation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAutoUpdateTimerExitRejectsLiveManager(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("live-process state control requires Linux /proc")
|
||||
}
|
||||
@@ -582,6 +598,7 @@ func TestAutoUpdateTimerExitRejectsLiveManager(t *testing.T) {
|
||||
// VERSION is deliberately plausible in every fixture. Neither it nor a legacy
|
||||
// executable can rescue a present primary whose own version evidence is bad.
|
||||
func TestAutoUpdateVersionNeedsSuccessfulExecutable(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tc := range []struct {
|
||||
name, body, legacy, want string
|
||||
nonExecutable, directory bool
|
||||
@@ -603,6 +620,7 @@ func TestAutoUpdateVersionNeedsSuccessfulExecutable(t *testing.T) {
|
||||
{name: "primary_directory", directory: true, legacy: "echo 'Pulse v6.5.0'"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "bin"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -644,6 +662,7 @@ func TestAutoUpdateVersionNeedsSuccessfulExecutable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAutoUpdateVersionProbeHasHardDeadline(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "bin"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -124,6 +124,7 @@ exit "$status"
|
||||
}
|
||||
|
||||
func TestAutoUpdateAssetWriterFailures(t *testing.T) {
|
||||
t.Parallel()
|
||||
updater, err := filepath.Abs(repoFile("scripts", "pulse-auto-update.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -131,6 +132,7 @@ func TestAutoUpdateAssetWriterFailures(t *testing.T) {
|
||||
for _, pipefail := range []string{"on", "off"} {
|
||||
for _, fault := range []string{"writer", "destination", "size-read"} {
|
||||
t.Run(pipefail+"/"+fault, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
dir := t.TempDir()
|
||||
|
||||
@@ -21,6 +21,7 @@ sleep() { SECONDS=$((SECONDS + $1)); }
|
||||
`
|
||||
|
||||
func TestAutoUpdateFixtureClockExcludesWallTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
cmd := exec.Command("bash", "-c", autoUpdateFixtureClock+`
|
||||
set -eu
|
||||
before=$SECONDS
|
||||
@@ -117,6 +118,7 @@ func nativeHarnessControlResults(output string) (map[string]string, error) {
|
||||
}
|
||||
|
||||
func TestAutoUpdateNativeControlResultsRetainInterleavedPhaseVerdicts(t *testing.T) {
|
||||
t.Parallel()
|
||||
const header = "test_fixture (__main__.NativeContracts.test_fixture) ... "
|
||||
for _, verdict := range []string{"ok", "skipped 'Linux-only fixture'"} {
|
||||
for _, phases := range []string{"", "NATIVE_UPDATER_PHASE=forward\nNATIVE_UPDATER_PHASE=manual-reverse\n"} {
|
||||
@@ -142,6 +144,7 @@ func TestAutoUpdateNativeControlResultsRetainInterleavedPhaseVerdicts(t *testing
|
||||
// The standalone helper passes an explicit name to the installer. Exercise
|
||||
// that producer and its real entry/handoff, not just installer discovery.
|
||||
func TestAutoUpdateServiceDiscoveryAndInstallerHandoff(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_server_service_discovery.py"), "-v",
|
||||
@@ -167,6 +170,7 @@ func TestAutoUpdateServiceDiscoveryAndInstallerHandoff(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAutoUpdateDownloadFailures(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_auto_update_service_state.py"), "-v", "UpdateDownloads")
|
||||
@@ -189,6 +193,7 @@ func TestAutoUpdateDownloadFailures(t *testing.T) {
|
||||
// Competing invocations use the same real installation-directory lock, even
|
||||
// through an alias. No host manager, network or published installer is used.
|
||||
func TestAutoUpdateTransactionLock(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_auto_update_service_state.py"), "-v", "UpdateTransactionLock")
|
||||
@@ -224,6 +229,7 @@ func TestAutoUpdateTransactionLock(t *testing.T) {
|
||||
// Service-state admission is independent of the signed/metadata transaction
|
||||
// matrix below; no native service or published input is used by this fixture.
|
||||
func TestAutoUpdateServiceStateFailsClosed(t *testing.T) {
|
||||
t.Parallel()
|
||||
runParallelPythonFixtureControls(t, repoFile("scripts", "tests", "test_auto_update_service_state.py"), "UpdateServiceState", []string{
|
||||
"test_manager_double_retains_exact_calls_phases_and_state",
|
||||
"test_fixture_timeout_retains_partial_output_and_owned_cleanup",
|
||||
@@ -242,6 +248,7 @@ func TestAutoUpdateServiceStateFailsClosed(t *testing.T) {
|
||||
// Real timeout/elapsed-clock controls operate only an ordinary-user manager
|
||||
// and its owned pipe-holding child, not systemd or an installed Pulse instance.
|
||||
func TestAutoUpdateServiceDeadlines(t *testing.T) {
|
||||
t.Parallel()
|
||||
runParallelPythonFixtureControls(t, repoFile("scripts", "tests", "test_auto_update_service_state.py"), "UpdateServiceDeadlines", []string{
|
||||
"test_slow_reads_count_toward_one_polling_budget",
|
||||
"test_complete_active_response_after_deadline_is_uncertain",
|
||||
@@ -260,6 +267,7 @@ func TestAutoUpdateServiceDeadlines(t *testing.T) {
|
||||
// on native platforms. Keep the full stream and all cases mandatory; discovery
|
||||
// still admits at most Go's existing parallel budget and rejects skips.
|
||||
func TestAutoUpdateLogSinkFailures(t *testing.T) {
|
||||
t.Parallel()
|
||||
required := []string{
|
||||
"test_fixture_protocol_keeps_missing_empty_partial_and_complete_counter_distinct",
|
||||
"test_fixture_timeout_cannot_be_hidden_by_interrupted_protocol_writes",
|
||||
@@ -285,6 +293,7 @@ func TestAutoUpdateLogSinkFailures(t *testing.T) {
|
||||
// transactions must not spend one cumulative watchdog. Discovery admits future
|
||||
// controls too, while the required inventory prevents losing an existing case.
|
||||
func TestAutoUpdateRunningExecutableIdentity(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("Linux /proc executable identity; portable transaction controls remain required")
|
||||
}
|
||||
@@ -332,6 +341,7 @@ func extractAutoUpdateServiceFunctions(t *testing.T) string {
|
||||
// pattern used for Pulse RCs (`-rc.N`), betas (`-beta.N`), alphas, nightlies,
|
||||
// etc. The unattended updater must refuse these on the stable channel.
|
||||
func TestIsPrereleaseTagRecognizesPrereleases(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []string{
|
||||
"v6.0.0-rc.2",
|
||||
"v5.1.28-rc.3",
|
||||
@@ -365,6 +375,7 @@ echo $?
|
||||
// tags - the only thing the unattended stable updater should ever accept -
|
||||
// are not flagged.
|
||||
func TestIsPrereleaseTagAcceptsStableTags(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []string{
|
||||
"v5.1.28",
|
||||
"v5.1.27",
|
||||
@@ -396,6 +407,7 @@ echo $?
|
||||
// treated as a prerelease - callers should refuse to act on it rather than
|
||||
// proceed with an unrecognized tag.
|
||||
func TestIsPrereleaseTagFailsClosed(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []string{
|
||||
"",
|
||||
"latest",
|
||||
@@ -433,6 +445,7 @@ echo $?
|
||||
// before touching the installer. This is the last line of defense against
|
||||
// the 2026-04-16 incident recurring.
|
||||
func TestPerformUpdateRefusesPrereleaseTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -u
|
||||
GITHUB_REPO="rcourtman/Pulse"
|
||||
@@ -479,6 +492,7 @@ fi
|
||||
// causes the function to return empty. This was the suspected trigger for
|
||||
// the 2026-04-16 jump from 5.1.27 to 6.0.0-rc.2.
|
||||
func TestGetLatestStableVersionRefusesPrereleaseFlag(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -u
|
||||
GITHUB_REPO="rcourtman/Pulse"
|
||||
@@ -517,6 +531,7 @@ echo "RESULT=[$result]"
|
||||
// prerelease (e.g. during a brief window where the flag was miswritten),
|
||||
// the function still refuses.
|
||||
func TestGetLatestStableVersionRefusesPrereleaseShapedTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -u
|
||||
GITHUB_REPO="rcourtman/Pulse"
|
||||
@@ -551,6 +566,7 @@ echo "RESULT=[$result]"
|
||||
// TestGetLatestStableVersionAcceptsStable asserts the happy path: a stable
|
||||
// tag with prerelease=false flows through unchanged.
|
||||
func TestGetLatestStableVersionAcceptsStable(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -u
|
||||
GITHUB_REPO="rcourtman/Pulse"
|
||||
@@ -592,6 +608,7 @@ echo "RESULT=[$result]"
|
||||
// release ships. Draft releases, metadata-flagged prereleases, and
|
||||
// prerelease- or non-semver-shaped tags (helm-chart-*) must all be ignored.
|
||||
func TestGetLatestStableVersionPrefersHighestVersion(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -u
|
||||
GITHUB_REPO="rcourtman/Pulse"
|
||||
@@ -659,6 +676,7 @@ echo "RESULT=[$result]"
|
||||
// "Pulse vX" binary is not flagged. The community auto-update flow must never
|
||||
// reinstall the public build over a paid Pro runtime.
|
||||
func TestInstalledBinaryIsPulseProGuard(t *testing.T) {
|
||||
t.Parallel()
|
||||
fn := extractAutoUpdateFunction(t, "installed_binary_is_pulse_pro")
|
||||
|
||||
cases := []struct {
|
||||
@@ -719,6 +737,7 @@ func TestInstalledBinaryIsPulseProGuard(t *testing.T) {
|
||||
// ExecCondition=systemctl is-active, so a service left stopped would also
|
||||
// disable every future unattended run.
|
||||
func TestPerformUpdateRestartsServiceWhenInstallerFails(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -uo pipefail
|
||||
TMP=$(mktemp -d)
|
||||
@@ -819,6 +838,7 @@ echo "VERSION:$(tr -d '\r\n' < "$INSTALL_DIR/VERSION")"
|
||||
// backstop behind the #1630 fix: a service that was inactive before the
|
||||
// update is left alone, and a service that was active is started again.
|
||||
func TestEnsureServiceRestartedHonorsPriorServiceState(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -uo pipefail
|
||||
SERVICE_UP="no"
|
||||
@@ -869,6 +889,7 @@ echo "SERVICE:$SERVICE_UP"
|
||||
// aborts with "installer_tmp: unbound variable" after a *successful* update,
|
||||
// leaving pulse-update.service failed even though the install worked.
|
||||
func TestPerformUpdateDoesNotLeakReturnTrap(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -uo pipefail
|
||||
TMP=$(mktemp -d)
|
||||
@@ -1121,19 +1142,23 @@ func TestAutoUpdateBackupTransaction(t *testing.T) {
|
||||
{name: "successful_update", success: true},
|
||||
}
|
||||
t.Run("new_service_failure", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runAutoUpdateTransactionScenario(t, fixture, "", "service_failure", "", "true", false, false, false, false)
|
||||
})
|
||||
for _, tc := range cases {
|
||||
for _, active := range []string{"true", "false"} {
|
||||
t.Run(tc.name+"/prior_active_"+active, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runAutoUpdateTransactionScenario(t, fixture, tc.fault, tc.outcome, tc.layout, active, tc.noVersion, tc.preflight, tc.retained, tc.success)
|
||||
})
|
||||
}
|
||||
}
|
||||
t.Run("restored_service_start_failure", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runAutoUpdateTransactionScenario(t, fixture, "restart", "failure", "", "true", false, false, true, false)
|
||||
})
|
||||
t.Run("restored_service_liveness_failure", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
runAutoUpdateTransactionScenario(t, fixture, "restart_liveness", "failure", "", "true", false, false, true, false)
|
||||
})
|
||||
}
|
||||
@@ -1410,6 +1435,7 @@ printf 'TRANSACTION_ASSERTIONS_PASSED\n'
|
||||
// Stable admission is object-bound, not a line-oriented tag/flag accumulator.
|
||||
// Each fixture runs the real selector with local transport stubs only.
|
||||
func TestAutoUpdateReleaseMetadataAdmission(t *testing.T) {
|
||||
t.Parallel()
|
||||
const stable = `{"tag_name":"v6.5.0","draft":false,"prerelease":false}`
|
||||
cases := []struct {
|
||||
name, list, latest, want string
|
||||
@@ -1438,6 +1464,7 @@ func TestAutoUpdateReleaseMetadataAdmission(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
for name, data := range map[string]string{"list": tc.list, "latest": tc.latest} {
|
||||
if err := os.WriteFile(filepath.Join(dir, name), []byte(data), 0o600); err != nil {
|
||||
@@ -1493,6 +1520,7 @@ get_latest_stable_version
|
||||
}
|
||||
|
||||
func TestAutoUpdateReleaseMetadataRequiresParserBeforeTransport(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `set -euo pipefail
|
||||
command() { if [[ "$*" == '-v jq' ]]; then return 1; fi; builtin command "$@"; }
|
||||
log() { printf '%s\n' "$*" >&2; }
|
||||
@@ -1510,6 +1538,7 @@ result=$(get_latest_stable_version)
|
||||
// These controls exercise actual same-directory writes with no manager or
|
||||
// production access. Both real optional callers retain their nonfatal policy.
|
||||
func TestInstallAutoUpdateAssetPublication(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix server installer filesystem controls")
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ func renderedInstallPowerShellFunction(t *testing.T, script, name string) string
|
||||
// pinned-key check compares it with: a rendered installer that compares the
|
||||
// key with itself skips every signature check.
|
||||
func TestRenderInstallersKeepSignatureVerificationEnabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("rendered install.sh verification requires bash and ssh-keygen")
|
||||
}
|
||||
@@ -239,6 +240,7 @@ $InstallerSignatureNamespace = "pulse-install"
|
||||
}
|
||||
|
||||
func TestRenderInstallersRefuseChangedSignaturePinTemplate(t *testing.T) {
|
||||
t.Parallel()
|
||||
installSH, err := os.ReadFile(repoFile("scripts", "install.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -260,6 +262,7 @@ func TestRenderInstallersRefuseChangedSignaturePinTemplate(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
changed := change(string(installSH))
|
||||
if changed == string(installSH) {
|
||||
t.Fatal("fixture did not change install.sh")
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
// qualification without repeating minutes of wall-clock waiting per case.
|
||||
// Unscaled 15s/60s transport timing is separate retained one-off evidence.
|
||||
func TestRootInstallerRegistrationTransferDeadlines(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, phase := range []string{"smoke", "setup", "register"} {
|
||||
for _, mode := range []string{"healthy", "transient-503", "stalled-headers", "stalled-body", "registered-response-stall"} {
|
||||
if mode == "registered-response-stall" && phase != "register" {
|
||||
@@ -164,8 +165,10 @@ func TestRootInstallerRegistrationTransferDeadlines(t *testing.T) {
|
||||
// substring or reaching a provider. This fails on the old unbounded source;
|
||||
// real transfers above establish that curl enforces the arguments too.
|
||||
func TestRootInstallerRegistrationDeadlineArguments(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, phase := range []string{"smoke", "setup", "register"} {
|
||||
t.Run(phase, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
script := `curl() { printf '%s\n' "$@" > "$FIXTURE_ROOT/argv"; cat >/dev/null; printf '{}'; }
|
||||
` + rootRegistrationDeadlineScript(t, phase)
|
||||
@@ -189,9 +192,11 @@ func TestRootInstallerRegistrationDeadlineArguments(t *testing.T) {
|
||||
// The acceleration boundary must reject drift rather than silently restoring
|
||||
// expected flags and allowing a broken production invocation to pass.
|
||||
func TestRootInstallerRegistrationDeadlineShimRefusesChangedArguments(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, phase := range []string{"smoke", "setup", "register"} {
|
||||
for _, fault := range []string{"missing-max-time", "changed-max-time", "duplicate-max-time", "changed-retries", "changed-backoff", "changed-connect-timeout", "missing-config-isolation", "extra-header"} {
|
||||
t.Run(phase+"/"+fault, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
env := rootRegistrationDeadlineEnvironment(t, root, "http://fixture.invalid", phase, "{}")
|
||||
args := rootRegistrationDeadlineArguments(phase, "http://fixture.invalid", "{}")
|
||||
|
||||
@@ -62,6 +62,7 @@ func safeProfileEffectiveSystemdFunctions(t *testing.T) string {
|
||||
}
|
||||
|
||||
func TestSafeProfileInspectIsReadOnlyAndReportsDifferences(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
binDir := filepath.Join(root, "bin")
|
||||
unitDir := filepath.Join(root, "systemd")
|
||||
@@ -121,7 +122,9 @@ safe_profile_inspect
|
||||
}
|
||||
|
||||
func TestSafeProfileTransactionCommitAndFailureRollback(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("commit", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileHarness(t, root, false) + `
|
||||
safe_profile_begin_transaction
|
||||
@@ -139,6 +142,7 @@ test "$SAFE_PROFILE_TRANSACTION_COMMITTED" = true
|
||||
})
|
||||
|
||||
t.Run("failure rollback", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileHarness(t, root, true) + `
|
||||
printf 'transient-wal\n' > "$STATE_DIR/cache/runtime.db-wal"
|
||||
@@ -211,6 +215,7 @@ grep -q '^gpasswd -a pulse-agent docker$' "$CALL_LOG"
|
||||
// restored service that runs as another account, and must be gone before
|
||||
// rollback writes the saved credentials and identity back by name.
|
||||
func TestSafeProfileRollbackDiscardsStateOfAnotherAccount(t *testing.T) {
|
||||
t.Parallel()
|
||||
if os.Geteuid() != 0 {
|
||||
t.Skip("handing state to another account requires root")
|
||||
}
|
||||
@@ -227,6 +232,7 @@ plant_collector_state() {
|
||||
}
|
||||
`
|
||||
t.Run("root profile", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
harness := safeProfileHarness(t, t.TempDir(), false) + collector + `
|
||||
safe_profile_begin_transaction
|
||||
plant_collector_state
|
||||
@@ -258,6 +264,7 @@ test "$(stat -c '%u' "$EXPECTED_DIR/outside-target")" = 0
|
||||
})
|
||||
|
||||
t.Run("same collector account", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
harness := safeProfileHarness(t, t.TempDir(), false) + collector + `
|
||||
chown -R "$COLLECTOR_UID:$COLLECTOR_UID" "$STATE_DIR"
|
||||
chown 0:0 "$STATE_DIR/connection.env"
|
||||
@@ -314,6 +321,7 @@ func safeProfileFixtureSnapshot(t *testing.T, root string) map[string]struct {
|
||||
}
|
||||
|
||||
func TestSafeProfileRefusesUnconfirmedRecoveryStateBeforeSnapshot(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, unit := range []string{"pulse-agent.service", "pulse-agent-helper.socket"} {
|
||||
for _, fault := range []struct {
|
||||
name, output, diagnostic string
|
||||
@@ -337,6 +345,7 @@ func TestSafeProfileRefusesUnconfirmedRecoveryStateBeforeSnapshot(t *testing.T)
|
||||
{name: "static", output: "LoadState=loaded\nActiveState=inactive\nUnitFileState=static\n"},
|
||||
} {
|
||||
t.Run(unit+"/"+fault.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileHarness(t, root, true)
|
||||
before := safeProfileFixtureSnapshot(t, root)
|
||||
@@ -375,6 +384,7 @@ grep -E '^(COLLECTOR|HELPER)_(ACTIVE|ENABLED)=' "$SAFE_PROFILE_TRANSACTION_DIR/m
|
||||
}
|
||||
|
||||
func TestSafeProfileCapturesConfirmedRecoveryFlagsAndRestoresIntent(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, state := range []struct {
|
||||
name, active, enabled, wantActive, wantEnabled string
|
||||
}{
|
||||
@@ -435,6 +445,7 @@ safe_profile_restore_transaction "$SAFE_PROFILE_TRANSACTION_DIR" recovery-contro
|
||||
}
|
||||
|
||||
func TestSafeProfileRefusesMissingInstalledCollector(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileHarness(t, root, false) + `
|
||||
STATE_FAULT_UNIT=pulse-agent.service
|
||||
@@ -448,6 +459,7 @@ safe_profile_begin_transaction
|
||||
}
|
||||
|
||||
func TestSafeProfileMigrationIsExplicitAndRunnerIndependent(t *testing.T) {
|
||||
t.Parallel()
|
||||
content, err := os.ReadFile(repoFile("scripts", "install.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -474,6 +486,7 @@ func TestSafeProfileMigrationIsExplicitAndRunnerIndependent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSafeProfileApplyRequiresReadinessHelperAndRegistration(t *testing.T) {
|
||||
t.Parallel()
|
||||
gate := extractInstallShellFunction(t, "safe_profile_verify_declared_health")
|
||||
script := `
|
||||
set -euo pipefail
|
||||
@@ -520,6 +533,7 @@ fi
|
||||
}
|
||||
|
||||
func TestSafeProfileFailsClosedOnEffectiveSystemdOverrides(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tc := range []struct {
|
||||
name, property, value string
|
||||
}{
|
||||
@@ -527,6 +541,7 @@ func TestSafeProfileFailsClosedOnEffectiveSystemdOverrides(t *testing.T) {
|
||||
{name: "different fragment", property: "FragmentPath", value: "/usr/lib/systemd/system/pulse-agent.service"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileHarness(t, root, false)
|
||||
old := tc.property + `) printf '%s\n' "$SAFE_PROFILE_COLLECTOR_UNIT" ;;`
|
||||
@@ -544,6 +559,7 @@ func TestSafeProfileFailsClosedOnEffectiveSystemdOverrides(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSafeProfileValidatesEveryEffectiveSystemdBoundary(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := []struct {
|
||||
name, unit, property, value string
|
||||
}{
|
||||
@@ -578,6 +594,7 @@ func TestSafeProfileValidatesEveryEffectiveSystemdBoundary(t *testing.T) {
|
||||
functions := safeProfileEffectiveSystemdFunctions(t)
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := effectiveSystemdHarness(t, testCase.unit, testCase.property, testCase.value) + "\n" + functions + `
|
||||
if safe_profile_verify_effective_target; then
|
||||
echo 'unsafe effective systemd profile was accepted' >&2
|
||||
@@ -591,6 +608,7 @@ fi
|
||||
}
|
||||
|
||||
t.Run("canonical profile", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := effectiveSystemdHarness(t, "", "", "") + "\n" + functions + "\nsafe_profile_verify_effective_target\n"
|
||||
if out, err := exec.Command("bash", "-c", script).CombinedOutput(); err != nil {
|
||||
t.Fatalf("canonical effective profile rejected: %v\n%s", err, out)
|
||||
@@ -599,6 +617,7 @@ fi
|
||||
}
|
||||
|
||||
func TestActionRunnerProvisionChecksEffectiveUnitBeforeStart(t *testing.T) {
|
||||
t.Parallel()
|
||||
provision := extractInstallShellFunction(t, "provision_action_runner")
|
||||
validation := strings.Index(provision, "action_runner_verify_effective_target")
|
||||
enable := strings.Index(provision, `systemctl enable "${ACTION_RUNNER_NAME}.service"`)
|
||||
@@ -609,6 +628,7 @@ func TestActionRunnerProvisionChecksEffectiveUnitBeforeStart(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTypedHelperProvisionChecksEffectiveUnitsBeforeSocketActivation(t *testing.T) {
|
||||
t.Parallel()
|
||||
provision := extractInstallShellFunction(t, "provision_typed_privileged_helper")
|
||||
validation := strings.Index(provision, "safe_profile_verify_helper_effective_target")
|
||||
enable := strings.Index(provision, `systemctl enable --now "${PRIVILEGED_HELPER_NAME}.socket"`)
|
||||
@@ -618,6 +638,7 @@ func TestTypedHelperProvisionChecksEffectiveUnitsBeforeSocketActivation(t *testi
|
||||
}
|
||||
|
||||
func TestTypedHelperProvisionReplacesRunningHelperAfterValidatedUnit(t *testing.T) {
|
||||
t.Parallel()
|
||||
provision := extractInstallShellFunction(t, "provision_typed_privileged_helper")
|
||||
// The production activation target remains fixed. Translate just that
|
||||
// comparison into this disposable filesystem, not the installer itself;
|
||||
@@ -628,6 +649,7 @@ func TestTypedHelperProvisionReplacesRunningHelperAfterValidatedUnit(t *testing.
|
||||
}
|
||||
for _, mode := range []string{"success", "effective-unit-failure", "restart-failure", "wrong-target"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
mustMkdirAll(t, filepath.Join(root, "bin"), filepath.Join(root, "systemd"))
|
||||
if err := os.WriteFile(filepath.Join(root, "bin", "pulse-agent"), []byte("fixture"), 0o755); err != nil {
|
||||
@@ -719,6 +741,7 @@ printf 'old-helper\n' > "$ROOT/running-helper"
|
||||
// hand a planted link's target to the collector, so only the collector's own
|
||||
// authority may touch that name unless its parent is closed to the collector.
|
||||
func TestTypedHelperQuarantineUsesCollectorAuthorityInsideCollectorWritableParent(t *testing.T) {
|
||||
t.Parallel()
|
||||
provision := extractInstallShellFunction(t, "provision_typed_privileged_helper")
|
||||
if strings.Count(provision, "\n ensure_collector_update_quarantine\n") != 1 ||
|
||||
strings.Contains(provision, "PRIVILEGED_HELPER_UPDATE_QUARANTINE_DIR") {
|
||||
@@ -727,6 +750,7 @@ func TestTypedHelperQuarantineUsesCollectorAuthorityInsideCollectorWritableParen
|
||||
ensure := extractInstallShellFunction(t, "ensure_collector_update_quarantine")
|
||||
for _, mode := range []string{"collector-parent", "shared-root-parent", "planted-link", "occupied-name", "root-parent"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
victim := filepath.Join(root, "victim")
|
||||
quarantine := filepath.Join(root, "state", "update-quarantine")
|
||||
@@ -812,6 +836,7 @@ install() { printf 'root %s\n' "$*" >> "$ROOT/events"; }
|
||||
}
|
||||
|
||||
func TestTypedHelperUnitRendersBoundedResources(t *testing.T) {
|
||||
t.Parallel()
|
||||
unitPath := filepath.Join(t.TempDir(), "pulse-agent-helper.service")
|
||||
render := extractInstallShellFunction(t, "render_privileged_helper_service_unit")
|
||||
script := `
|
||||
@@ -841,9 +866,11 @@ render_privileged_helper_service_unit "` + unitPath + `" /usr/local/lib/pulse-ag
|
||||
// on every platform, not infer enforcement from an effective property string.
|
||||
// These are installer regressions, not execution of a native sandbox.
|
||||
func TestTypedHelperIsolationDoesNotDependOnArchitectureOrPVE(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, arch := range []string{"amd64", "arm64", "armv7", "armv6", "386", "unknown"} {
|
||||
for _, pve := range []string{"false", "true"} {
|
||||
t.Run(arch+"/pve="+pve, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
unitPath := filepath.Join(t.TempDir(), "helper.service")
|
||||
script := `
|
||||
set -euo pipefail
|
||||
@@ -886,6 +913,7 @@ fi
|
||||
}
|
||||
|
||||
func TestSafeProfileRegistrationMustAdvanceLastSeen(t *testing.T) {
|
||||
t.Parallel()
|
||||
functions := extractInstallShellFunction(t, "verify_agent_server_registration")
|
||||
script := `
|
||||
set -euo pipefail
|
||||
@@ -924,8 +952,10 @@ test "$AGENT_REGISTRATION_LAST_SEEN" = '2026-08-30T10:00:31Z'
|
||||
}
|
||||
|
||||
func TestSafeProfileHelperProtocolProbeValidatesFramedHealth(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, success := range []bool{true, false} {
|
||||
t.Run(map[bool]string{true: "healthy", false: "typed failure"}[success], func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, err := os.MkdirTemp("/tmp", "pulse-helper-probe-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -1005,6 +1035,7 @@ id() { return 0; }
|
||||
}
|
||||
|
||||
func TestSafeProfileExitTrapRestoresUncommittedTransaction(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileHarness(t, root, true) + "\n" + extractInstallShellFunction(t, "cleanup") + `
|
||||
TMP_FILES=()
|
||||
@@ -1026,6 +1057,7 @@ exit 23
|
||||
}
|
||||
|
||||
func TestSafeProfileDockerDegradationRequiresCollectorOwnedRootlessRuntime(t *testing.T) {
|
||||
t.Parallel()
|
||||
function := extractInstallShellFunction(t, "safe_profile_apply_docker_degradation")
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
@@ -1038,6 +1070,7 @@ func TestSafeProfileDockerDegradationRequiresCollectorOwnedRootlessRuntime(t *te
|
||||
{name: "no safe source", want: "enabled=false explicit=true"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
script := `
|
||||
set -euo pipefail
|
||||
SAFE_PROFILE_ACTION=apply
|
||||
|
||||
@@ -103,12 +103,14 @@ printf 'runner-independent\n' > "$ACTION_RUNNER_SENTINEL"
|
||||
}
|
||||
|
||||
func TestSafeProfileRollbackRefusesUnconfirmedQuiescenceBeforeRestoration(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, unit := range []string{"pulse-agent.service", "pulse-agent-helper.socket", "pulse-agent-helper.service"} {
|
||||
for _, fault := range []string{
|
||||
"stop-refused", "stop-timeout", "stop-ignored", "disable-refused", "disable-timeout",
|
||||
"read-refused", "read-timeout", "read-empty", "read-incomplete", "read-diagnostic",
|
||||
} {
|
||||
t.Run(unit+"/"+fault, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileRollbackQuiescenceHarness(t, root)
|
||||
prepareSafeProfileRollback(t, harness)
|
||||
@@ -147,6 +149,7 @@ fi
|
||||
}
|
||||
|
||||
func TestSafeProfileRollbackExitTrapRetainsOriginalFailureAndSnapshot(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileRollbackQuiescenceHarness(t, root)
|
||||
prepareSafeProfileRollback(t, harness)
|
||||
@@ -181,8 +184,10 @@ exit 23
|
||||
}
|
||||
|
||||
func TestSafeProfileRollbackRechecksEarlierUnitsBeforeRestoration(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, unit := range []string{"pulse-agent.service", "pulse-agent-helper.socket"} {
|
||||
t.Run(unit, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileRollbackQuiescenceHarness(t, root)
|
||||
prepareSafeProfileRollback(t, harness)
|
||||
@@ -205,8 +210,10 @@ if safe_profile_restore_transaction "$transaction" reactivation-control; then ex
|
||||
}
|
||||
|
||||
func TestSafeProfileRollbackQuiescentControlRestoresSavedProfile(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, absentHelper := range []bool{false, true} {
|
||||
t.Run(map[bool]string{false: "helper present", true: "helper absent"}[absentHelper], func(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
harness := safeProfileRollbackQuiescenceHarness(t, root)
|
||||
if absentHelper {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestRootInstallSystemdUnitPublication(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix installer and confined filesystem controls")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUninstallSensorProxyScriptContract(t *testing.T) {
|
||||
t.Parallel()
|
||||
scriptPath := repoFile("scripts", "uninstall-sensor-proxy.sh")
|
||||
content, err := os.ReadFile(scriptPath)
|
||||
if err != nil {
|
||||
@@ -42,6 +43,7 @@ func TestUninstallSensorProxyScriptContract(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyRemoteCleanupUsesProvisionedHostKeys(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
binDir := filepath.Join(tmpDir, "bin")
|
||||
argsLog := filepath.Join(tmpDir, "ssh-args")
|
||||
@@ -98,6 +100,7 @@ cleanup_remote_authorized_keys 192.0.2.10
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyRemoteCleanupUsesStrictConfiguredTrustByDefault(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
binDir := filepath.Join(tmpDir, "bin")
|
||||
argsLog := filepath.Join(tmpDir, "ssh-args")
|
||||
@@ -144,6 +147,7 @@ cleanup_remote_authorized_keys 192.0.2.20
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyRemoteCleanupFailsWithoutProvisionedTrust(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
binDir := filepath.Join(tmpDir, "bin")
|
||||
argsLog := filepath.Join(tmpDir, "ssh-args")
|
||||
@@ -181,6 +185,7 @@ cleanup_remote_authorized_keys 192.0.2.11
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyRemoteCleanupRejectsHostKeyMismatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
binDir := filepath.Join(tmpDir, "bin")
|
||||
knownHosts := filepath.Join(tmpDir, "known_hosts")
|
||||
@@ -210,6 +215,7 @@ cleanup_remote_authorized_keys 192.0.2.12
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyLocalOnlyDoesNotUseSSH(t *testing.T) {
|
||||
t.Parallel()
|
||||
marker := filepath.Join(t.TempDir(), "cleanup-marker")
|
||||
command := `source "$1"
|
||||
LOCAL_ONLY=true
|
||||
@@ -232,6 +238,7 @@ cleanup_cluster_authorized_keys
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyReportsRemoteTrustFailureAfterLocalCleanup(t *testing.T) {
|
||||
t.Parallel()
|
||||
marker := filepath.Join(t.TempDir(), "cleanup-marker")
|
||||
command := `source "$1"
|
||||
disable_legacy_units() { :; }
|
||||
@@ -265,6 +272,7 @@ main --quiet
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyScriptRemovesTempFootprintAndManagedKeys(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
binDir := filepath.Join(tmpDir, "bin")
|
||||
if err := os.MkdirAll(binDir, 0755); err != nil {
|
||||
@@ -373,6 +381,7 @@ if cleanup_cluster_authorized_keys; then exit 0; else exit $?; fi
|
||||
`
|
||||
|
||||
func TestUninstallSensorProxyClusterInventoryUsesEveryValidatedNode(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "inventory"), []byte(`[{"node":"pve-b"},{"node":"pve-a"},{"node":"pve-b"},{"node":"pve-v6"}]`), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -398,6 +407,7 @@ func TestUninstallSensorProxyClusterInventoryUsesEveryValidatedNode(t *testing.T
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyIncompleteInventoryNeverStartsKeyCleanup(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tc := range []struct{ name, inventory string }{
|
||||
{"empty", `[]`}, {"object", `{}`}, {"null", `null`}, {"malformed", `[{`},
|
||||
{"missing", `[{"node":"pve-a"},{}]`}, {"wrong_type", `[{"node":7}]`},
|
||||
@@ -425,6 +435,7 @@ func TestUninstallSensorProxyIncompleteInventoryNeverStartsKeyCleanup(t *testing
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyMissingInventoryToolRequiresExplicitLocalOnly(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tool := range []string{"pvesh", "python3"} {
|
||||
t.Run(tool, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
@@ -449,6 +460,7 @@ if cleanup_cluster_authorized_keys; then exit 0; else exit $?; fi
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyKeyReplacementPreservesOriginalOnEveryFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
const original = "ssh-ed25519 AAAAlegacy pulse # pulse-managed-key\nssh-ed25519 AAAAkeep user-key\n"
|
||||
for _, phase := range []string{"mktemp", "grep", "cmp", "chmod", "chown", "mv", "success", "all_managed", "unchanged", "missing"} {
|
||||
t.Run(phase, func(t *testing.T) {
|
||||
@@ -513,6 +525,7 @@ if cleanup_local_authorized_keys; then exit 0; else exit $?; fi
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyLocalOnlyPropagatesKeyFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
body := `source "$1"
|
||||
LOCAL_ONLY=true
|
||||
cleanup_local_authorized_keys() { return 23; }
|
||||
@@ -525,6 +538,7 @@ if cleanup_cluster_authorized_keys; then exit 0; else exit $?; fi
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyAPICleanupRequiresCompleteInventoryAndRemovals(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tc := range []struct {
|
||||
name, inventory, actions string
|
||||
success bool
|
||||
@@ -580,6 +594,7 @@ if remove_proxmox_access; then exit 0; else exit $?; fi
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyMainCannotHideAPIRemovalFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
body := `source "$1"
|
||||
disable_legacy_units() { :; }
|
||||
cleanup_cluster_authorized_keys() { :; }
|
||||
@@ -651,6 +666,7 @@ const sensorProxyRecoveryKeys = "ssh-ed25519 AAAAkeep recovery-key\n" +
|
||||
"restrict ssh-ed25519 AAAAkeep2 other # pulse-managed-key-not-a-marker\n"
|
||||
|
||||
func TestUninstallSensorProxyRemoteKeyPayloadPreservesSharedTarget(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, kind := range []string{"regular", "symlink"} {
|
||||
for _, phase := range []string{"success", "unchanged", "all_managed", "missing", "directory", "readlink", "mktemp", "output_open", "grep", "cmp", "chmod", "chown", "mv", "cleanup"} {
|
||||
t.Run(kind+"/"+phase, func(t *testing.T) {
|
||||
@@ -755,6 +771,7 @@ func TestUninstallSensorProxyRemoteKeyPayloadPreservesSharedTarget(t *testing.T)
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyRemotePayloadFailureReachesMain(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
auth := filepath.Join(dir, "remote", "authorized_keys")
|
||||
if err := os.MkdirAll(filepath.Dir(auth), 0700); err != nil {
|
||||
@@ -793,6 +810,7 @@ if main; then exit 0; else exit $?; fi
|
||||
// Both shipped entrypoints must preserve unrelated access keys. All filesystem
|
||||
// operations below are real private-user operations; only faults are injected.
|
||||
func TestUninstallSensorProxyLocalKeyWritersPreserveRecovery(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, entry := range []struct{ name, script, function string }{
|
||||
{"standalone", repoFile("scripts", "uninstall-sensor-proxy.sh"), "cleanup_local_authorized_keys"},
|
||||
{"installer", repoFile("install.sh"), "remove_local_sensor_proxy_managed_keys"},
|
||||
@@ -928,6 +946,7 @@ if ` + entry.function + `; then exit 0; else exit $?; fi
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyLocalKeyWriterKeepsCallerResources(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, entry := range []struct{ name, script, function string }{
|
||||
{"standalone", repoFile("scripts", "uninstall-sensor-proxy.sh"), "cleanup_local_authorized_keys"},
|
||||
{"installer", repoFile("install.sh"), "remove_local_sensor_proxy_managed_keys"},
|
||||
@@ -960,6 +979,7 @@ fi
|
||||
}
|
||||
|
||||
func TestUninstallSensorProxyLocalKeyFailureReachesMain(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
keys := filepath.Join(dir, "authorized_keys")
|
||||
const original = "ssh-ed25519 AAAAold # pulse-managed-key\n" + sensorProxyRecoveryKeys
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestInstallSHUnraidBootReplacementPreservesUnrelatedJobs(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Unix shell/filesystem fixture; native Unraid acceptance remains separate")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user