Merge pull request #362 from docker/fix_aci_tests

Fix ACI e2e tests : do not use console if no tty option set in exec
This commit is contained in:
Guillaume Tardif 2020-07-07 15:42:11 +02:00 committed by GitHub
commit 1e3b90f4f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -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)
}

View File

@ -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"))
})