Browse code

Fix hanging integration tests

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 22f827ababc1910bc48762d7980913497dbc915d)

Tonis Tiigi authored on 2016/06/16 02:18:18
Showing 1 changed files
... ...
@@ -1634,7 +1634,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) {
1634 1634
 		t.Fatal(err)
1635 1635
 	}
1636 1636
 
1637
-	// start a new container try to publist port 80:80 will failed
1637
+	// start a new container, trying to publish port 80:80 should fail
1638 1638
 	out, err := s.d.Cmd("run", "-p", "80:80", "-d", "busybox", "top")
1639 1639
 	if err == nil || !strings.Contains(out, "Bind for 0.0.0.0:80 failed: port is already allocated") {
1640 1640
 		t.Fatalf("80 port is allocated to old running container, it should failed on allocating to new container")
... ...
@@ -1645,7 +1645,17 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) {
1645 1645
 	if err != nil {
1646 1646
 		t.Fatal(err)
1647 1647
 	}
1648
-	_, err = s.d.Cmd("run", "-p", "80:80", "-d", "busybox", "top")
1648
+	id, err := s.d.Cmd("run", "-p", "80:80", "-d", "busybox", "top")
1649
+	if err != nil {
1650
+		t.Fatal(err)
1651
+	}
1652
+
1653
+	// Cleanup because these containers will not be shut down by daemon
1654
+	out, err = s.d.Cmd("stop", newCon)
1655
+	if err != nil {
1656
+		t.Fatalf("err: %v %v", err, string(out))
1657
+	}
1658
+	_, err = s.d.Cmd("stop", strings.TrimSpace(id))
1649 1659
 	if err != nil {
1650 1660
 		t.Fatal(err)
1651 1661
 	}