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 14:05:25 +02:00
parent 16acc36033
commit c5cd0f44f8
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"))
})