|
@@ -2,12 +2,13 @@ package main
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
- "github.com/dotcloud/docker/pkg/iptables"
|
|
|
"io/ioutil"
|
|
|
"os"
|
|
|
"os/exec"
|
|
|
"strings"
|
|
|
"testing"
|
|
|
+
|
|
|
+ "github.com/dotcloud/docker/pkg/iptables"
|
|
|
)
|
|
|
|
|
|
func TestEtcHostsRegularFile(t *testing.T) {
|
|
@@ -90,3 +91,33 @@ func TestIpTablesRulesWhenLinkAndUnlink(t *testing.T) {
|
|
|
|
|
|
logDone("link - verify iptables when link and unlink")
|
|
|
}
|
|
|
+
|
|
|
+func TestInspectLinksStarted(t *testing.T) {
|
|
|
+ defer deleteAllContainers()
|
|
|
+ cmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
|
|
|
+ cmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
|
|
|
+ cmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "sleep", "10")
|
|
|
+ links, err := inspectField("testinspectlink", "HostConfig.Links")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ if expected := "[/container1:/testinspectlink/alias1 /container2:/testinspectlink/alias2]"; links != expected {
|
|
|
+ t.Fatalf("Links %s, but expected %s", links, expected)
|
|
|
+ }
|
|
|
+ logDone("link - links in started container inspect")
|
|
|
+}
|
|
|
+
|
|
|
+func TestInspectLinksStopped(t *testing.T) {
|
|
|
+ defer deleteAllContainers()
|
|
|
+ cmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
|
|
|
+ cmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
|
|
|
+ cmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "true")
|
|
|
+ links, err := inspectField("testinspectlink", "HostConfig.Links")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ if expected := "[/container1:/testinspectlink/alias1 /container2:/testinspectlink/alias2]"; links != expected {
|
|
|
+ t.Fatalf("Links %s, but expected %s", links, expected)
|
|
|
+ }
|
|
|
+ logDone("link - links in stopped container inspect")
|
|
|
+}
|