mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add a network test
This just tries pinging first 127.0.0.1 and then 8.8.8.8. We can't ping via a dns name, because libresolv.so is missing from the test image, so dns resolving doesn't work.
This commit is contained in:
parent
494cd07f72
commit
249f5a65a5
1 changed files with 38 additions and 0 deletions
|
@ -407,6 +407,44 @@ func TestOutput(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContainerNetwork(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
container, err := runtime.Create(
|
||||||
|
&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Cmd: []string{"ping", "-c", "1", "127.0.0.1"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
if err := container.Run(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if container.State.ExitCode != 0 {
|
||||||
|
t.Errorf("Unexpected ping 127.0.0.1 exit code %d (expected 0)", container.State.ExitCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
container, err = runtime.Create(
|
||||||
|
&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Cmd: []string{"ping", "-c", "1", "8.8.8.8"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
if err := container.Run(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if container.State.ExitCode != 0 {
|
||||||
|
t.Errorf("Unexpected ping 8.8.8.8 exit code %d (expected 0)", container.State.ExitCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestKillDifferentUser(t *testing.T) {
|
func TestKillDifferentUser(t *testing.T) {
|
||||||
runtime := mkRuntime(t)
|
runtime := mkRuntime(t)
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue