diff --git a/pkg/testing/windows/windows.go b/pkg/testing/windows/windows.go index 9275ebd51c8..46cda60ea85 100644 --- a/pkg/testing/windows/windows.go +++ b/pkg/testing/windows/windows.go @@ -26,7 +26,9 @@ func (WindowsRunner) Prepare(ctx context.Context, sshClient ssh.SSHClient, logge // install chocolatey logger.Logf("Installing chocolatey") chocoInstall := `"[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"` - stdOut, errOut, err := sshRunPowershell(ctx, sshClient, chocoInstall) + updateCtx, updateCancel := context.WithTimeout(ctx, 3*time.Minute) + defer updateCancel() + stdOut, errOut, err := sshRunPowershell(updateCtx, sshClient, chocoInstall) if err != nil { return fmt.Errorf("failed to install chocolatey: %w (stdout: %s, stderr: %s)", err, stdOut, errOut) } @@ -236,12 +238,12 @@ func (WindowsRunner) Diagnostics(ctx context.Context, sshClient ssh.SSHClient, l } func sshRunPowershell(ctx context.Context, sshClient ssh.SSHClient, cmd string) ([]byte, []byte, error) { - return sshClient.Exec(ctx, "powershell", []string{ + return sshClient.ExecWithRetry(ctx, "powershell", []string{ "-NoProfile", "-InputFormat", "None", "-ExecutionPolicy", "Bypass", "-Command", cmd, - }, nil) + }, 15*time.Second) } func toPowershellScript(agentVersion string, prefix string, verbose bool, tests []string, env map[string]string) string {