mirror of https://github.com/docker/docs.git
Merge pull request #10837 from ahmetalpbalkan/win-cli/readContainerFile-with-exec
integration-cli: readContainerFileWithExec for links tests
This commit is contained in:
commit
435d654b09
|
@ -231,7 +231,7 @@ func TestLinksNotStartedParentNotFail(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinksHostsFilesInject(t *testing.T) {
|
func TestLinksHostsFilesInject(t *testing.T) {
|
||||||
testRequires(t, SameHostDaemon)
|
testRequires(t, SameHostDaemon, ExecSupport)
|
||||||
|
|
||||||
defer deleteAllContainers()
|
defer deleteAllContainers()
|
||||||
|
|
||||||
|
@ -251,12 +251,12 @@ func TestLinksHostsFilesInject(t *testing.T) {
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
contentOne, err := readContainerFile(idOne, "hosts")
|
contentOne, err := readContainerFileWithExec(idOne, "/etc/hosts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(contentOne))
|
t.Fatal(err, string(contentOne))
|
||||||
}
|
}
|
||||||
|
|
||||||
contentTwo, err := readContainerFile(idTwo, "hosts")
|
contentTwo, err := readContainerFileWithExec(idTwo, "/etc/hosts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(contentTwo))
|
t.Fatal(err, string(contentTwo))
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ func TestLinksNetworkHostContainer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinksUpdateOnRestart(t *testing.T) {
|
func TestLinksUpdateOnRestart(t *testing.T) {
|
||||||
testRequires(t, SameHostDaemon)
|
testRequires(t, SameHostDaemon, ExecSupport)
|
||||||
|
|
||||||
defer deleteAllContainers()
|
defer deleteAllContainers()
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ func TestLinksUpdateOnRestart(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
content, err := readContainerFile(id, "hosts")
|
content, err := readContainerFileWithExec(id, "/etc/hosts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(content))
|
t.Fatal(err, string(content))
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ func TestLinksUpdateOnRestart(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
content, err = readContainerFile(id, "hosts")
|
content, err = readContainerFileWithExec(id, "/etc/hosts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(content))
|
t.Fatal(err, string(content))
|
||||||
}
|
}
|
||||||
|
|
|
@ -895,6 +895,11 @@ func readContainerFile(containerId, filename string) ([]byte, error) {
|
||||||
return content, nil
|
return content, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readContainerFileWithExec(containerId, filename string) ([]byte, error) {
|
||||||
|
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "exec", containerId, "cat", filename))
|
||||||
|
return []byte(out), err
|
||||||
|
}
|
||||||
|
|
||||||
func setupRegistry(t *testing.T) func() {
|
func setupRegistry(t *testing.T) func() {
|
||||||
reg, err := newTestRegistryV2(t)
|
reg, err := newTestRegistryV2(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -21,6 +21,10 @@ var (
|
||||||
func() bool { return isUnixCli },
|
func() bool { return isUnixCli },
|
||||||
"Test requires posix utilities or functionality to run.",
|
"Test requires posix utilities or functionality to run.",
|
||||||
}
|
}
|
||||||
|
ExecSupport = TestRequirement{
|
||||||
|
func() bool { return supportsExec },
|
||||||
|
"Test requires 'docker exec' capabilities on the tested daemon.",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// testRequires checks if the environment satisfies the requirements
|
// testRequires checks if the environment satisfies the requirements
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
// +build !test_no_exec
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
const (
|
||||||
|
// indicates docker daemon tested supports 'docker exec'
|
||||||
|
supportsExec = true
|
||||||
|
)
|
|
@ -0,0 +1,8 @@
|
||||||
|
// +build test_no_exec
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
const (
|
||||||
|
// indicates docker daemon tested supports 'docker exec'
|
||||||
|
supportsExec = false
|
||||||
|
)
|
Loading…
Reference in New Issue