Browse code

Add failing test case for issue #4681

Add a failing test case for an issue where docker is not creating a loopback device if networking is dissabled.

Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion)

Timothy Hobbs authored on 2014/03/16 07:04:36
Showing 1 changed files
... ...
@@ -434,28 +434,6 @@ func TestOutput(t *testing.T) {
434 434
 	}
435 435
 }
436 436
 
437
-func TestContainerNetwork(t *testing.T) {
438
-	runtime := mkRuntime(t)
439
-	defer nuke(runtime)
440
-	container, _, err := runtime.Create(
441
-		&runconfig.Config{
442
-			Image: GetTestImage(runtime).ID,
443
-			Cmd:   []string{"ping", "-c", "1", "127.0.0.1"},
444
-		},
445
-		"",
446
-	)
447
-	if err != nil {
448
-		t.Fatal(err)
449
-	}
450
-	defer runtime.Destroy(container)
451
-	if err := container.Run(); err != nil {
452
-		t.Fatal(err)
453
-	}
454
-	if code := container.State.GetExitCode(); code != 0 {
455
-		t.Fatalf("Unexpected ping 127.0.0.1 exit code %d (expected 0)", code)
456
-	}
457
-}
458
-
459 437
 func TestKillDifferentUser(t *testing.T) {
460 438
 	runtime := mkRuntime(t)
461 439
 	defer nuke(runtime)
... ...
@@ -1523,6 +1501,53 @@ func TestVolumesFromWithVolumes(t *testing.T) {
1523 1523
 	}
1524 1524
 }
1525 1525
 
1526
+func TestContainerNetwork(t *testing.T) {
1527
+	runtime := mkRuntime(t)
1528
+	defer nuke(runtime)
1529
+	container, _, err := runtime.Create(
1530
+		&runconfig.Config{
1531
+			Image: GetTestImage(runtime).ID,
1532
+			// If I change this to ping 8.8.8.8 it fails.  Any idea why? - timthelion
1533
+			Cmd: []string{"ping", "-c", "1", "127.0.0.1"},
1534
+		},
1535
+		"",
1536
+	)
1537
+	if err != nil {
1538
+		t.Fatal(err)
1539
+	}
1540
+	defer runtime.Destroy(container)
1541
+	if err := container.Run(); err != nil {
1542
+		t.Fatal(err)
1543
+	}
1544
+	if code := container.State.GetExitCode(); code != 0 {
1545
+		t.Fatalf("Unexpected ping 127.0.0.1 exit code %d (expected 0)", code)
1546
+	}
1547
+}
1548
+
1549
+// Issue #4681
1550
+func TestLoopbackFunctionsWhenNetworkingIsDissabled(t *testing.T) {
1551
+	runtime := mkRuntime(t)
1552
+	defer nuke(runtime)
1553
+	container, _, err := runtime.Create(
1554
+		&runconfig.Config{
1555
+			Image:           GetTestImage(runtime).ID,
1556
+			Cmd:             []string{"ping", "-c", "1", "127.0.0.1"},
1557
+			NetworkDisabled: true,
1558
+		},
1559
+		"",
1560
+	)
1561
+	if err != nil {
1562
+		t.Fatal(err)
1563
+	}
1564
+	defer runtime.Destroy(container)
1565
+	if err := container.Run(); err != nil {
1566
+		t.Fatal(err)
1567
+	}
1568
+	if code := container.State.GetExitCode(); code != 0 {
1569
+		t.Fatalf("Unexpected ping 127.0.0.1 exit code %d (expected 0)", code)
1570
+	}
1571
+}
1572
+
1526 1573
 func TestOnlyLoopbackExistsWhenUsingDisableNetworkOption(t *testing.T) {
1527 1574
 	eng := NewTestEngine(t)
1528 1575
 	runtime := mkRuntimeFromEngine(eng, t)