mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 21:51:33 +00:00
Recfactor: Use dockerCmd when possible in integration-cli tests
Part of #14603 integration-cli/docker_cli_links_test.go (coolljt0725) integration-cli/docker_cli_links_unix_test.go (coolljt0725) integration-cli/docker_cli_logs_test.go (coolljt0725) integration-cli/docker_cli_nat_test.go (coolljt0725) integration-cli/docker_cli_network_test.go (coolljt0725) integration-cli/docker_cli_stats_test.go (coolljt0725) integration-cli/docker_cli_tag_test.go (coolljt0725) integration-cli/docker_cli_top_test.go (coolljt0725) integration-cli/docker_cli_version_test.go (coolljt0725) integration-cli/docker_cli_wait_test.go (coolljt0725 Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/go-check/check"
|
||||
@@ -44,11 +43,7 @@ func getExternalAddress(c *check.C) net.IP {
|
||||
}
|
||||
|
||||
func getContainerLogs(c *check.C, containerID string) string {
|
||||
runCmd := exec.Command(dockerBinary, "logs", containerID)
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
out, _ := dockerCmd(c, "logs", containerID)
|
||||
return strings.Trim(out, "\r\n")
|
||||
}
|
||||
|
||||
@@ -104,12 +99,8 @@ func (s *DockerSuite) TestNetworkLoopbackNat(c *check.C) {
|
||||
msg := "it works"
|
||||
startServerContainer(c, msg, 8080)
|
||||
endpoint := getExternalAddress(c)
|
||||
runCmd := exec.Command(dockerBinary, "run", "-t", "--net=container:server", "busybox",
|
||||
out, _ := dockerCmd(c, "run", "-t", "--net=container:server", "busybox",
|
||||
"sh", "-c", fmt.Sprintf("stty raw && nc -w 5 %s 8080", endpoint.String()))
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
final := strings.TrimRight(string(out), "\n")
|
||||
if final != msg {
|
||||
c.Fatalf("Expected message %q but received %q", msg, final)
|
||||
|
||||
Reference in New Issue
Block a user