Skip to content

Commit

Permalink
Merge pull request #5367 from danfengliu/fix-issue--command-return-me…
Browse files Browse the repository at this point in the history
…ssage-checking

Fix issue of fail to get command output for test verification
  • Loading branch information
qiuming-best authored Sep 22, 2022
2 parents ee254c6 + fdc2383 commit 100d462
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/e2e/util/velero/velero_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,17 +431,19 @@ func VeleroScheduleCreate(ctx context.Context, veleroCLI string, veleroNamespace

func VeleroCmdExec(ctx context.Context, veleroCLI string, args []string) error {
cmd := exec.CommandContext(ctx, veleroCLI, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
var errBuf, outBuf bytes.Buffer
cmd.Stderr = io.MultiWriter(os.Stderr, &errBuf)
cmd.Stdout = io.MultiWriter(os.Stdout, &outBuf)
fmt.Printf("velero cmd =%v\n", cmd)
err := cmd.Run()
if strings.Contains(fmt.Sprint(cmd.Stdout), "Failed") {
retAll := outBuf.String() + " " + errBuf.String()
if strings.Contains(strings.ToLower(retAll), "failed") {
return errors.New(fmt.Sprintf("velero cmd =%v return with failure\n", cmd))
}
if err != nil {
return err
}
return err
return nil
}

func VeleroBackupLogs(ctx context.Context, veleroCLI string, veleroNamespace string, backupName string) error {
Expand Down

0 comments on commit 100d462

Please sign in to comment.