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.

Deflake typed action containment tests

rcourtman2ad094c92775
diff --git a/internal/api/proxmox_guest_action_executor_test.go b/internal/api/proxmox_guest_action_executor_test.go
index 9c8a3e88ca..93feccb51d 100644
--- a/internal/api/proxmox_guest_action_executor_test.go
+++ b/internal/api/proxmox_guest_action_executor_test.go
@@ -186,7 +186,10 @@ func TestProxmoxGuestActionExecutorUsesIndependentControlPlaneVerification(t *te
}}
observer := &fakeProxmoxGuestPostconditionObserver{observations: []proxmoxGuestPostconditionObservation{
proxmoxGuestActionObservation(now.Add(-time.Second), "running", 3600, "proxmox-control-plane:default:homelab"),
- proxmoxGuestActionObservation(now.Add(time.Second), "stopped", 0, "proxmox-control-plane:default:homelab"),
+ // The after observation must postdate actionStartedAt, which is stamped
+ // inside ExecuteAction after handler setup; a one-second offset loses
+ // that race on a loaded runner, so use a generous margin.
+ proxmoxGuestActionObservation(now.Add(time.Minute), "stopped", 0, "proxmox-control-plane:default:homelab"),
}}
executor := newProxmoxGuestActionExecutor(h, agents, observer)
@@ -215,7 +218,7 @@ func TestProxmoxGuestActionExecutorRequiresUptimeResetToVerifyReboot(t *testing.
agents := &fakeDockerActionAgentCommander{results: []*agentexec.CommandResultPayload{{RequestID: "act_vm", Success: true, ExitCode: 0, Stdout: "reboot requested"}}}
observer := &fakeProxmoxGuestPostconditionObserver{observations: []proxmoxGuestPostconditionObservation{
proxmoxGuestActionObservation(now.Add(-time.Second), "running", 7200, "proxmox-control-plane:default:homelab"),
- proxmoxGuestActionObservation(now.Add(time.Second), "running", 4, "proxmox-control-plane:default:homelab"),
+ proxmoxGuestActionObservation(now.Add(time.Minute), "running", 4, "proxmox-control-plane:default:homelab"),
}}
executor := newProxmoxGuestActionExecutor(h, agents, observer)
@@ -239,7 +242,7 @@ func TestProxmoxGuestActionExecutorKeepsIndependentContradictionSeparateFromExec
agents := &fakeDockerActionAgentCommander{results: []*agentexec.CommandResultPayload{{RequestID: "act_vm", Success: true, ExitCode: 0, Stdout: "reboot requested"}}}
observer := &fakeProxmoxGuestPostconditionObserver{observations: []proxmoxGuestPostconditionObservation{
proxmoxGuestActionObservation(now.Add(-time.Second), "running", 7200, "proxmox-control-plane:default:homelab"),
- proxmoxGuestActionObservation(now.Add(time.Second), "running", 7201, "proxmox-control-plane:default:homelab"),
+ proxmoxGuestActionObservation(now.Add(time.Minute), "running", 7201, "proxmox-control-plane:default:homelab"),
}}
executor := newProxmoxGuestActionExecutor(h, agents, observer)
ctx, cancel := context.WithTimeout(actionDispatchTestContext(t, "act_vm"), 100*time.Millisecond)
diff --git a/internal/hostagent/typed_action_command_linux_test.go b/internal/hostagent/typed_action_command_linux_test.go
index a7b5bfa489..7eab05b26e 100644
--- a/internal/hostagent/typed_action_command_linux_test.go
+++ b/internal/hostagent/typed_action_command_linux_test.go
@@ -201,6 +201,11 @@ func TestValidateTrustedExecutableRequiresControlledExecutableFile(t *testing.T)
if err := os.WriteFile(writable, []byte("binary"), 0o720); err != nil {
t.Fatal(err)
}
+ // WriteFile filters mode through the process umask, which strips the
+ // group-write bit under the common 022 umask; force the mode we assert on.
+ if err := os.Chmod(writable, 0o720); err != nil {
+ t.Fatal(err)
+ }
if err := validateTrustedExecutable(writable, uint32(os.Geteuid())); err == nil {
t.Fatal("group-writable executable was trusted")
}