1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #10837 from ahmetalpbalkan/win-cli/readContainerFile-with-exec

integration-cli: readContainerFileWithExec for links tests
This commit is contained in:
Michael Crosby 2015-02-24 15:24:48 -08:00
commit 435d654b09
5 changed files with 31 additions and 6 deletions

View file

@ -231,7 +231,7 @@ func TestLinksNotStartedParentNotFail(t *testing.T) {
}
func TestLinksHostsFilesInject(t *testing.T) {
testRequires(t, SameHostDaemon)
testRequires(t, SameHostDaemon, ExecSupport)
defer deleteAllContainers()
@ -251,12 +251,12 @@ func TestLinksHostsFilesInject(t *testing.T) {
time.Sleep(1 * time.Second)
contentOne, err := readContainerFile(idOne, "hosts")
contentOne, err := readContainerFileWithExec(idOne, "/etc/hosts")
if err != nil {
t.Fatal(err, string(contentOne))
}
contentTwo, err := readContainerFile(idTwo, "hosts")
contentTwo, err := readContainerFileWithExec(idTwo, "/etc/hosts")
if err != nil {
t.Fatal(err, string(contentTwo))
}
@ -285,7 +285,7 @@ func TestLinksNetworkHostContainer(t *testing.T) {
}
func TestLinksUpdateOnRestart(t *testing.T) {
testRequires(t, SameHostDaemon)
testRequires(t, SameHostDaemon, ExecSupport)
defer deleteAllContainers()
@ -302,7 +302,7 @@ func TestLinksUpdateOnRestart(t *testing.T) {
if err != nil {
t.Fatal(err)
}
content, err := readContainerFile(id, "hosts")
content, err := readContainerFileWithExec(id, "/etc/hosts")
if err != nil {
t.Fatal(err, string(content))
}
@ -327,7 +327,7 @@ func TestLinksUpdateOnRestart(t *testing.T) {
if err != nil {
t.Fatal(err)
}
content, err = readContainerFile(id, "hosts")
content, err = readContainerFileWithExec(id, "/etc/hosts")
if err != nil {
t.Fatal(err, string(content))
}

View file

@ -895,6 +895,11 @@ func readContainerFile(containerId, filename string) ([]byte, error) {
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() {
reg, err := newTestRegistryV2(t)
if err != nil {

View file

@ -21,6 +21,10 @@ var (
func() bool { return isUnixCli },
"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

View file

@ -0,0 +1,8 @@
// +build !test_no_exec
package main
const (
// indicates docker daemon tested supports 'docker exec'
supportsExec = true
)

View file

@ -0,0 +1,8 @@
// +build test_no_exec
package main
const (
// indicates docker daemon tested supports 'docker exec'
supportsExec = false
)