Parcourir la source

Merge pull request #362 from docker/fix_aci_tests

Fix ACI e2e tests : do not use console if no tty option set in exec
Guillaume Tardif il y a 5 ans
Parent
commit
1e3b90f4f8
2 fichiers modifiés avec 6 ajouts et 9 suppressions
  1. 4 4
      cli/cmd/exec.go
  2. 2 5
      tests/aci-e2e/e2e-aci_test.go

+ 4 - 4
cli/cmd/exec.go

@@ -19,6 +19,7 @@ package cmd
 import (
 	"context"
 	"fmt"
+	"os"
 	"strings"
 
 	"github.com/containerd/console"
@@ -56,9 +57,8 @@ func runExec(ctx context.Context, opts execOpts, name string, command string) er
 		return errors.Wrap(err, "cannot connect to backend")
 	}
 
-	con := console.Current()
-
 	if opts.Tty {
+		con := console.Current()
 		if err := con.SetRaw(); err != nil {
 			return err
 		}
@@ -67,7 +67,7 @@ func runExec(ctx context.Context, opts execOpts, name string, command string) er
 				fmt.Println("Unable to close the console")
 			}
 		}()
+		return c.ContainerService().Exec(ctx, name, command, con, con)
 	}
-
-	return c.ContainerService().Exec(ctx, name, command, con, con)
+	return c.ContainerService().Exec(ctx, name, command, os.Stdin, os.Stdout)
 }

+ 2 - 5
tests/aci-e2e/e2e-aci_test.go

@@ -151,11 +151,8 @@ func (s *E2eACISuite) TestACIBackend() {
 	})
 
 	s.T().Run("exec command", func(t *testing.T) {
-		output := s.NewDockerCommand("exec", testContainerName, "pwd").ExecOrDie()
-		Expect(output).To(ContainSubstring("/"))
-
-		output = s.NewDockerCommand("exec", testContainerName, "echo", "fail_with_argument").ExecOrDie()
-		Expect(output).To(ContainSubstring("ACI exec command does not accept arguments to the command. " +
+		_, err := s.NewDockerCommand("exec", testContainerName, "echo", "fail_with_argument").Exec()
+		Expect(err.Error()).To(ContainSubstring("ACI exec command does not accept arguments to the command. " +
 			"Only the binary should be specified"))
 	})