From 75e44cc8ab9c0a9ca4a8e929341ecedff461ed29 Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 01:52:20 +0000 Subject: [PATCH] Reuse the real agent build in installer admission and removal tests 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. Change-source: pulse-maintainer --- .../agent_installed_removal_transport_test.go | 12 ++---------- scripts/installtests/agent_url_admission_test.go | 10 +--------- .../installtests/lifecycle_binary_fixture_test.go | 13 +++++++++---- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/scripts/installtests/agent_installed_removal_transport_test.go b/scripts/installtests/agent_installed_removal_transport_test.go index 2e91390dec..bd1ed06cbb 100644 --- a/scripts/installtests/agent_installed_removal_transport_test.go +++ b/scripts/installtests/agent_installed_removal_transport_test.go @@ -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) } diff --git a/scripts/installtests/agent_url_admission_test.go b/scripts/installtests/agent_url_admission_test.go index fff35463c8..8595efae8c 100644 --- a/scripts/installtests/agent_url_admission_test.go +++ b/scripts/installtests/agent_url_admission_test.go @@ -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) diff --git a/scripts/installtests/lifecycle_binary_fixture_test.go b/scripts/installtests/lifecycle_binary_fixture_test.go index c67bfa0153..5699dfcc6d 100644 --- a/scripts/installtests/lifecycle_binary_fixture_test.go +++ b/scripts/installtests/lifecycle_binary_fixture_test.go @@ -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 })