Reuse the real agent build in installer admission and removal tests (#4657)

Build the exact checkout's agent once per installer test process via the
existing lifecycle fixture. Give the URL and saved-transport tests their
own executable copies and retain their three-minute build bound and
existing assertions. No application code, test cases or CI check
selection changes.

---
Fleet candidate `20261119T013919Z-delivery-trust` from the
`delivery-trust` lane. Reviewed tip
`75e44cc8ab9c0a9ca4a8e929341ecedff461ed29` on `main`.

[How Pulse handles
triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
pulse-triage[bot]
2026-11-19 02:53:22 +00:00
committed by GitHub
3 changed files with 12 additions and 23 deletions

View File

@@ -32,17 +32,9 @@ func TestAgentInstalledRemovalSavedTransport(t *testing.T) {
// The binary, TLS peers and saved state are private; service/process
// operations below are doubles, not the host's live inventory. Admit this
// whole ordered scenario set through Go's existing parallel budget before
// starting its unchanged build and transport deadlines.
// requesting its own executable copy and starting the transport checks.
t.Parallel()
buildDir := t.TempDir()
binary := filepath.Join(buildDir, "pulse-agent")
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
build := exec.CommandContext(ctx, "go", "build", "-o", binary, "./cmd/pulse-agent")
build.Dir = repoFile()
if out, err := build.CombinedOutput(); err != nil {
t.Fatalf("build real installed CLI: %v\n%s", err, out)
}
binary := buildPulseAgentLifecycleBinary(t)
if err := os.Chmod(binary, 0755); err != nil {
t.Fatal(err)
}

View File

@@ -20,15 +20,7 @@ func TestAgentInstallerURLAdmission(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Unix installer")
}
buildDir := t.TempDir()
binary := filepath.Join(buildDir, "pulse-agent")
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
build := exec.CommandContext(ctx, "go", "build", "-o", binary, "./cmd/pulse-agent")
build.Dir = repoFile()
if out, err := build.CombinedOutput(); err != nil {
t.Fatalf("build real staged agent: %v\n%s", err, out)
}
binary := buildPulseAgentLifecycleBinary(t)
binaryBytes, err := os.ReadFile(binary)
if err != nil {
t.Fatal(err)

View File

@@ -2,6 +2,7 @@ package installtests
import (
"bytes"
"context"
"errors"
"fmt"
"os"
@@ -10,17 +11,21 @@ import (
"sync"
"sync/atomic"
"testing"
"time"
)
// Only the build is shared, and only within this test process. Each caller
// receives its own executable, so replacing or removing it cannot affect
// another lifecycle test. Keep the real source build and its failures: the Go
// build cache alone still links the same agent once for every caller.
// another lifecycle test. Keep the real source build, the URL/removal tests'
// three-minute build deadline and any compiler failure. The Go build cache
// alone still links the same agent once for every caller.
var lifecycleAgentFixture = newLifecycleBinaryFixture(func(binary string) error {
build := exec.Command("go", "build", "-o", binary, "./cmd/pulse-agent")
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
build := exec.CommandContext(ctx, "go", "build", "-o", binary, "./cmd/pulse-agent")
build.Dir = repoFile()
if output, err := build.CombinedOutput(); err != nil {
return fmt.Errorf("build pulse-agent lifecycle binary: %w\n%s", err, output)
return fmt.Errorf("build pulse-agent lifecycle binary: %w\n%s", errors.Join(err, ctx.Err()), output)
}
return nil
})