Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterYan committed Nov 4, 2024
1 parent e66c631 commit 9548fb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
17 changes: 6 additions & 11 deletions pkg/supportbundle/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion test/e2e/support-bundle/host_remote_collector_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 9548fb2

Please sign in to comment.