From 9548fb2fbc26e8988e21fec020b9793044241938 Mon Sep 17 00:00:00 2001 From: Dexter Yan Date: Tue, 5 Nov 2024 12:24:13 +1300 Subject: [PATCH] fix test --- pkg/supportbundle/collect.go | 17 ++++++----------- .../host_remote_collector_e2e_test.go | 1 - 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pkg/supportbundle/collect.go b/pkg/supportbundle/collect.go index 5f2ce8789..a133f1918 100644 --- a/pkg/supportbundle/collect.go +++ b/pkg/supportbundle/collect.go @@ -306,22 +306,17 @@ func getExecOutputs( } // Set up the ticker and timeout ticker := time.NewTicker(100 * time.Millisecond) // Polling frequency - timeout := constants.DEFAULT_LOGS_COLLECTOR_TIMEOUT + // timeout := constants.DEFAULT_LOGS_COLLECTOR_TIMEOUT defer ticker.Stop() - timeoutChan := time.After(timeout) // Constant timeout + // timeoutChan := time.After(timeout) // Constant timeout // Loop until stdout has content or timeout is reached - for { - select { - case <-ticker.C: - if stdout.Len() > 0 { - return stdout.Bytes(), stderr.Bytes(), nil - } - case <-timeoutChan: - // Return whatever we have if the timeout is reached - return stdout.Bytes(), stderr.Bytes(), fmt.Errorf("host remote collector timed out after %v", timeout) + for range ticker.C { + if stdout.Len() > 0 { + return stdout.Bytes(), stderr.Bytes(), nil } } + return stdout.Bytes(), stderr.Bytes(), nil } func runRemoteHostCollectors(ctx context.Context, hostCollectors []*troubleshootv1beta2.HostCollect, bundlePath string, opts SupportBundleCreateOpts) (map[string][]byte, error) { diff --git a/test/e2e/support-bundle/host_remote_collector_e2e_test.go b/test/e2e/support-bundle/host_remote_collector_e2e_test.go index e40097329..f8538e254 100644 --- a/test/e2e/support-bundle/host_remote_collector_e2e_test.go +++ b/test/e2e/support-bundle/host_remote_collector_e2e_test.go @@ -21,7 +21,6 @@ func TestHostRemoteCollector(t *testing.T) { cmd.Stdout = &out err := cmd.Run() if err != nil { - fmt.Println(out.String()) t.Fatalf("Failed to run the binary: %v", err) }