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:
commit
435d654b09
5 changed files with 31 additions and 6 deletions
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
8
integration-cli/test_vars_exec.go
Normal file
8
integration-cli/test_vars_exec.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
// +build !test_no_exec
|
||||
|
||||
package main
|
||||
|
||||
const (
|
||||
// indicates docker daemon tested supports 'docker exec'
|
||||
supportsExec = true
|
||||
)
|
8
integration-cli/test_vars_noexec.go
Normal file
8
integration-cli/test_vars_noexec.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
// +build test_no_exec
|
||||
|
||||
package main
|
||||
|
||||
const (
|
||||
// indicates docker daemon tested supports 'docker exec'
|
||||
supportsExec = false
|
||||
)
|
Loading…
Add table
Reference in a new issue