| 442 | } |
| 443 | |
| 444 | func (a shellActions) RunStress(command string, args ...string) (string, string) { |
| 445 | var cmd *exec.Cmd |
| 446 | if a.fm.Hostname().Host == "localhost" { |
| 447 | // Just run locally. |
| 448 | cmd = exec.Command(command, args...) |
| 449 | } else { |
| 450 | // We must SSH to the remote machine and run the command. |
| 451 | cmd = a.wrapSSH(command, args...) |
| 452 | } |
| 453 | var stdout bytes.Buffer |
| 454 | var stderr bytes.Buffer |
| 455 | cmd.Stdout = &stdout |
| 456 | cmd.Stderr = &stderr |
| 457 | err := cmd.Run() |
| 458 | if err != nil { |
| 459 | a.fm.T().Logf("Ran %q %v in %q and received error: %q. Stdout: %q, Stderr: %s", command, args, a.fm.Hostname().Host, err, stdout.String(), stderr.String()) |
| 460 | return stdout.String(), stderr.String() |
| 461 | } |
| 462 | return stdout.String(), stderr.String() |
| 463 | } |
| 464 | |
| 465 | // Runs retryFunc until no error is returned. After dur time the last error is returned. |
| 466 | // Note that the function does not timeout the execution of retryFunc when the limit is reached. |