|
@@ -1870,7 +1870,7 @@ func TestRunMutableNetworkFiles(t *testing.T) {
|
|
|
|
|
|
func TestRunStableIPAndPort(t *testing.T) {
|
|
|
const nContainers = 2
|
|
|
- var ids, ips, ports [nContainers]string
|
|
|
+ var ids, ips, macs, ports [nContainers]string
|
|
|
|
|
|
// Setup: Create a couple of containers and collect their IPs and public ports.
|
|
|
for i := 0; i < nContainers; i++ {
|
|
@@ -1880,12 +1880,16 @@ func TestRunStableIPAndPort(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
ids[i] = strings.TrimSpace(out)
|
|
|
+
|
|
|
ips[i], err = inspectField(ids[i], "NetworkSettings.IPAddress")
|
|
|
errorOut(err, t, out)
|
|
|
if ips[i] == "" {
|
|
|
t.Fatal("IP allocation failed")
|
|
|
}
|
|
|
|
|
|
+ macs[i], err = inspectField(ids[i], "NetworkSettings.MacAddress")
|
|
|
+ errorOut(err, t, out)
|
|
|
+
|
|
|
portCmd := exec.Command(dockerBinary, "port", ids[i], "1234")
|
|
|
ports[i], _, err = runCommandWithOutput(portCmd)
|
|
|
errorOut(err, t, out)
|
|
@@ -1927,7 +1931,7 @@ func TestRunStableIPAndPort(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Start the containers back, and ensure they are getting the same IPs and ports.
|
|
|
+ // Start the containers back, and ensure they are getting the same IPs, MACs and ports.
|
|
|
for i, id := range ids {
|
|
|
runCmd := exec.Command(dockerBinary, "start", id)
|
|
|
out, _, err := runCommandWithOutput(runCmd)
|
|
@@ -1935,6 +1939,10 @@ func TestRunStableIPAndPort(t *testing.T) {
|
|
|
|
|
|
ip, err := inspectField(id, "NetworkSettings.IPAddress")
|
|
|
errorOut(err, t, out)
|
|
|
+
|
|
|
+ mac, err := inspectField(id, "NetworkSettings.MacAddress")
|
|
|
+ errorOut(err, t, out)
|
|
|
+
|
|
|
portCmd := exec.Command(dockerBinary, "port", ids[i], "1234")
|
|
|
port, _, err := runCommandWithOutput(portCmd)
|
|
|
errorOut(err, t, out)
|
|
@@ -1942,6 +1950,9 @@ func TestRunStableIPAndPort(t *testing.T) {
|
|
|
if ips[i] != ip {
|
|
|
t.Fatalf("Container started with a different IP: %s != %s", ip, ips[i])
|
|
|
}
|
|
|
+ if macs[i] != mac {
|
|
|
+ t.Fatalf("Container started with a different MAC: %s != %s", mac, macs[i])
|
|
|
+ }
|
|
|
if ports[i] != port {
|
|
|
t.Fatalf("Container started with a different port: %s != %s", port, ports[i])
|
|
|
}
|