diff --git a/test/cli_network_test.go b/test/cli_network_test.go index c47c8fdfa..b6c08694c 100644 --- a/test/cli_network_test.go +++ b/test/cli_network_test.go @@ -321,12 +321,7 @@ func (suite *PouchNetworkSuite) TestNetworkCreateDup(c *check.C) { } func (suite *PouchNetworkSuite) TestNetworkPortMapping(c *check.C) { - pc, _, _, _ := runtime.Caller(0) - tmpname := strings.Split(runtime.FuncForPC(pc).Name(), ".") - var funcname string - for i := range tmpname { - funcname = tmpname[i] - } + cname := "TestNetworkPortMapping" ret := icmd.RunCommand("which", "curl") if ret.ExitCode != 0 { @@ -342,15 +337,22 @@ func (suite *PouchNetworkSuite) TestNetworkPortMapping(c *check.C) { command.PouchRun("pull", image).Assert(c, icmd.Success) command.PouchRun("run", "-d", - "--name", funcname, + "--name", cname, "-p", "9999:80", image).Assert(c, icmd.Success) + defer DelContainerForceMultyTime(c, cname) - time.Sleep(10 * time.Second) - err := icmd.RunCommand("timeout", "5", "curl", "localhost:9999").Compare(expct) - c.Assert(err, check.IsNil) + success := false + for i := 0; i < 60; i++ { + err := icmd.RunCommand("timeout", "5", "curl", "localhost:9999").Compare(expct) + if err == nil { + success = true + break + } + time.Sleep(1 * time.Second) + } - command.PouchRun("rm", "-f", funcname) + c.Assert(success, check.Equals, true) } func createBridge(bridgeName string) (netlink.Link, error) { diff --git a/test/cli_run_network_test.go b/test/cli_run_network_test.go index de7f39a24..1c4ddedff 100644 --- a/test/cli_run_network_test.go +++ b/test/cli_run_network_test.go @@ -29,7 +29,7 @@ func (suite *PouchRunNetworkSuite) TestRunWithPing(c *check.C) { name := "TestRunWithPing" res := command.PouchRun("run", "--name", name, - busyboxImage, "ping", "-c", "10", "www.taobao.com") + busyboxImage, "ping", "-c", "3", "www.taobao.com") defer DelContainerForceMultyTime(c, name) res.Assert(c, icmd.Success) }