From 4b3e417a9cf2d9b08266c507096e2aad0d60b6f2 Mon Sep 17 00:00:00 2001 From: zhuangqh Date: Mon, 4 Jun 2018 15:10:47 +0800 Subject: [PATCH] fix: replace DelContainerForceOk with DelContainerForceMultyTime Signed-off-by: zhuangqh --- test/api_container_create_test.go | 16 ++++++++-------- test/api_container_delete_test.go | 4 ++-- test/api_container_exec_create_test.go | 10 +++++----- test/api_container_exec_inspect_test.go | 2 +- test/api_container_exec_start_test.go | 4 ++-- test/api_container_inspect_test.go | 4 ++-- test/api_container_logs_test.go | 12 ++++++------ test/api_container_pause_test.go | 4 ++-- test/api_container_rename_test.go | 6 +++--- test/api_container_resize_test.go | 6 +++--- test/api_container_restart_test.go | 6 +++--- test/api_container_start_test.go | 8 ++++---- test/api_container_stop_test.go | 6 +++--- test/api_container_wait_test.go | 4 ++-- test/api_image_delete_test.go | 2 +- test/util_api.go | 12 ++++++------ 16 files changed, 53 insertions(+), 53 deletions(-) diff --git a/test/api_container_create_test.go b/test/api_container_create_test.go index 39010e281..bbf58fc0a 100644 --- a/test/api_container_create_test.go +++ b/test/api_container_create_test.go @@ -48,7 +48,7 @@ func (suite *APIContainerCreateSuite) TestCreateOk(c *check.C) { c.Assert(err, check.IsNil) c.Assert(got.ID, check.NotNil) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestNilName tests creating container without giving name should succeed. @@ -70,7 +70,7 @@ func (suite *APIContainerCreateSuite) TestNilName(c *check.C) { c.Assert(got.ID, check.NotNil) c.Assert(got.Name, check.NotNil) - DelContainerForceOk(c, got.Name) + DelContainerForceMultyTime(c, got.Name) } // TestDupContainer tests create a duplicate container, return 409. @@ -96,7 +96,7 @@ func (suite *APIContainerCreateSuite) TestDupContainer(c *check.C) { CheckRespStatus(c, resp, 409) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestNonExistingImg tests using non-existing image return 404. @@ -146,7 +146,7 @@ func (suite *APIContainerCreateSuite) TestAllocateTTY(c *check.C) { CheckRespStatus(c, resp, 201) // TODO: verify TTY works? - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestAddVolume tests add volume is OK. @@ -173,7 +173,7 @@ func (suite *APIContainerCreateSuite) TestAddVolume(c *check.C) { CheckRespStatus(c, resp, 201) // TODO: verify volume - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestRuntime tests specify a different runtime, e.g. runv could work. @@ -200,7 +200,7 @@ func (suite *APIContainerCreateSuite) TestRuntime(c *check.C) { CheckRespStatus(c, resp, 201) // TODO: verify runtime - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestLxcfsEnable is OK. @@ -236,7 +236,7 @@ func (suite *APIContainerCreateSuite) TestLxcfsEnable(c *check.C) { c.Assert(got.HostConfig.EnableLxcfs, check.Equals, isEnable) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestRestartPolicyAlways tests create container with restartpolicy is always could work. @@ -275,7 +275,7 @@ func (suite *APIContainerCreateSuite) TestRestartPolicyAlways(c *check.C) { c.Assert(got.HostConfig.RestartPolicy.Name, check.Equals, "always") - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestAliOSOptions tests create container with alios related container isolation options. diff --git a/test/api_container_delete_test.go b/test/api_container_delete_test.go index 3c7862aa9..1390011f2 100644 --- a/test/api_container_delete_test.go +++ b/test/api_container_delete_test.go @@ -43,7 +43,7 @@ func (suite *APIContainerDeleteSuite) TestDeleteRunningCon(c *check.C) { CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestDeletePausedCon test deleting paused container return 500. @@ -61,7 +61,7 @@ func (suite *APIContainerDeleteSuite) TestDeletePausedCon(c *check.C) { CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestDeleteStoppedCon test deleting stopped container return 204. diff --git a/test/api_container_exec_create_test.go b/test/api_container_exec_create_test.go index faf4efc2c..c840857d4 100644 --- a/test/api_container_exec_create_test.go +++ b/test/api_container_exec_create_test.go @@ -43,7 +43,7 @@ func (suite *APIContainerExecSuite) TestContainerCreateExecOk(c *check.C) { request.DecodeBody(&execCreateResp, resp.Body) c.Logf("ExecID is %s", execCreateResp.ID) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestContainerCreateExecNoCmd tests execing containers is OK. @@ -64,7 +64,7 @@ func (suite *APIContainerExecSuite) TestContainerCreateExecNoCmd(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 201) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestExecCreatedContainer tests creating exec on created container return error. @@ -83,7 +83,7 @@ func (suite *APIContainerExecSuite) TestExecCreatedContainer(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestExecPausedContainer tests creating exec on paused container return error. @@ -105,7 +105,7 @@ func (suite *APIContainerExecSuite) TestExecPausedContainer(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestExecStoppedContainer tests creating exec on stopped container return error. @@ -127,5 +127,5 @@ func (suite *APIContainerExecSuite) TestExecStoppedContainer(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/api_container_exec_inspect_test.go b/test/api_container_exec_inspect_test.go index b34778948..1a75d47ff 100644 --- a/test/api_container_exec_inspect_test.go +++ b/test/api_container_exec_inspect_test.go @@ -90,5 +90,5 @@ func (suite *APIContainerExecInspectSuite) TestContainerExecInspectOk(c *check.C c.Assert(execInspect03.Running, check.Equals, false) c.Assert(execInspect03.ExitCode, check.Equals, int64(0)) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/api_container_exec_start_test.go b/test/api_container_exec_start_test.go index a73d30955..c3da19f10 100644 --- a/test/api_container_exec_start_test.go +++ b/test/api_container_exec_start_test.go @@ -62,7 +62,7 @@ func (suite *APIContainerExecStartSuite) TestContainerExecStartWithoutUpgrade(c checkEchoSuccess(c, false, conn, br, "test") - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestContainerExecStartOk tests start exec. @@ -81,7 +81,7 @@ func (suite *APIContainerExecStartSuite) TestContainerExecStart(c *check.C) { checkEchoSuccess(c, false, conn, reader, "test") - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestContainerExecStartNotFound tests starting an non-existing execID return error. diff --git a/test/api_container_inspect_test.go b/test/api_container_inspect_test.go index 2e93a3abb..20a6ca83b 100644 --- a/test/api_container_inspect_test.go +++ b/test/api_container_inspect_test.go @@ -52,7 +52,7 @@ func (suite *APIContainerInspectSuite) TestInpectOk(c *check.C) { // FinishAt time should be 0001-01-01T00:00:00Z for a non-stopped container c.Assert(got.State.FinishedAt, check.Equals, time.Time{}.UTC().Format(time.RFC3339Nano)) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestNonExistingContainer tests inspect a non-existing container return 404. @@ -81,5 +81,5 @@ func (suite *APIContainerInspectSuite) TestInspectPid(c *check.C) { c.Assert(got.State.Pid, check.NotNil) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/api_container_logs_test.go b/test/api_container_logs_test.go index cc2c7eed2..e6a8fa31f 100644 --- a/test/api_container_logs_test.go +++ b/test/api_container_logs_test.go @@ -52,7 +52,7 @@ func (suite *APIContainerLogsSuite) TestNoSuchContainer(c *check.C) { func (suite *APIContainerLogsSuite) TestNoShowStdoutAndShowStderr(c *check.C) { name := "logs_without_one_of_showstdout_and_showstderr" command.PouchRun("run", "-d", "--name", name, busyboxImage, "ls").Assert(c, icmd.Success) - defer DelContainerForceOk(c, name) + defer DelContainerForceMultyTime(c, name) resp, err := request.Get(fmt.Sprintf("/containers/%s/logs", name)) c.Assert(err, check.IsNil) @@ -63,7 +63,7 @@ func (suite *APIContainerLogsSuite) TestNoShowStdoutAndShowStderr(c *check.C) { func (suite *APIContainerLogsSuite) TestStdout(c *check.C) { name := "logs_stdout_stream" command.PouchRun("run", "-t", "--name", name, busyboxImage, "echo", "hello").Assert(c, icmd.Success) - defer DelContainerForceOk(c, name) + defer DelContainerForceMultyTime(c, name) allLogs := suite.syncReadLog(c, name, map[string]string{"stdout": "1"}) c.Assert(len(allLogs), check.Equals, 1) @@ -74,7 +74,7 @@ func (suite *APIContainerLogsSuite) TestStdout(c *check.C) { func (suite *APIContainerLogsSuite) TestTimestamp(c *check.C) { name := "logs_stdout_stream_with_timestamp" command.PouchRun("run", "-t", "--name", name, busyboxImage, "echo", "hello").Assert(c, icmd.Success) - defer DelContainerForceOk(c, name) + defer DelContainerForceMultyTime(c, name) allLogs := suite.syncReadLog(c, name, map[string]string{"stdout": "1", "timestamps": "1"}) c.Assert(len(allLogs), check.Equals, 1) @@ -88,7 +88,7 @@ func (suite *APIContainerLogsSuite) TestTimestamp(c *check.C) { func (suite *APIContainerLogsSuite) TestTails(c *check.C) { name := "logs_stdout_stream_with_tails" command.PouchRun("run", "-t", "--name", name, busyboxImage, "sh", "-c", "for i in $(seq 1 3); do echo hi$i; done").Assert(c, icmd.Success) - defer DelContainerForceOk(c, name) + defer DelContainerForceMultyTime(c, name) allLogs := suite.syncReadLog(c, name, map[string]string{"stdout": "1", "tail": "2"}) c.Assert(len(allLogs), check.Equals, 2) @@ -101,7 +101,7 @@ func (suite *APIContainerLogsSuite) TestTails(c *check.C) { func (suite *APIContainerLogsSuite) TestSinceAndUntil(c *check.C) { name := "logs_stdout_stream_with_tails" command.PouchRun("run", "-t", "--name", name, busyboxImage, "sh", "-c", "for i in $(seq 1 3); do echo hi$i; sleep 1; done").Assert(c, icmd.Success) - defer DelContainerForceOk(c, name) + defer DelContainerForceMultyTime(c, name) allLogs := suite.syncReadLog(c, name, map[string]string{"stdout": "1", "timestamps": "1"}) c.Assert(len(allLogs), check.Equals, 3) @@ -126,7 +126,7 @@ func (suite *APIContainerLogsSuite) TestSinceAndUntil(c *check.C) { func (suite *APIContainerLogsSuite) TestCheckLeakByFollowing(c *check.C) { name := "logs_check_leak_by_following" command.PouchRun("run", "-d", "--name", name, busyboxImage, "sh", "-c", "while true; do sleep 1; done").Assert(c, icmd.Success) - defer DelContainerForceOk(c, name) + defer DelContainerForceMultyTime(c, name) // follow one second and check the goroutine leak ctx, cancel := context.WithTimeout(context.TODO(), 1*time.Second) diff --git a/test/api_container_pause_test.go b/test/api_container_pause_test.go index c7843c130..96d8ae403 100644 --- a/test/api_container_pause_test.go +++ b/test/api_container_pause_test.go @@ -38,7 +38,7 @@ func (suite *APIContainerPauseSuite) TestPauseUnpauseOk(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestNonExistingContainer tests pause a non-existing container return 404. @@ -78,5 +78,5 @@ func (suite *APIContainerPauseSuite) TestNotRunningContainer(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/api_container_rename_test.go b/test/api_container_rename_test.go index 720543a29..79e2b5eab 100644 --- a/test/api_container_rename_test.go +++ b/test/api_container_rename_test.go @@ -39,7 +39,7 @@ func (suite *APIContainerRenameSuite) TestRenameOk(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, newname) + DelContainerForceMultyTime(c, newname) } // TestRenameOk test create api is ok with default parameters. @@ -63,7 +63,7 @@ func (suite *APIContainerRenameSuite) TestRenameById(c *check.C) { defer resp2.Body.Close() CheckRespStatus(c, resp2, 204) - DelContainerForceOk(c, newname) + DelContainerForceMultyTime(c, newname) resp3, err := CreateBusyboxContainer(c, oldname, "top") c.Assert(err, check.IsNil) @@ -73,7 +73,7 @@ func (suite *APIContainerRenameSuite) TestRenameById(c *check.C) { err = json.NewDecoder(resp3.Body).Decode(&ccr) c.Assert(err, check.IsNil) - DelContainerForceOk(c, oldname) + DelContainerForceMultyTime(c, oldname) if ccr.ID == "" { c.Errorf("container with old name %s create error. %v", oldname, ccr) diff --git a/test/api_container_resize_test.go b/test/api_container_resize_test.go index f661b74f6..05e3bf8b4 100644 --- a/test/api_container_resize_test.go +++ b/test/api_container_resize_test.go @@ -42,7 +42,7 @@ func (suite *APIContainerResizeSuite) TestContainerResizeOk(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 200) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestContainerResizeWithInvalidSize is to verify resize container with invalid size. @@ -64,7 +64,7 @@ func (suite *APIContainerResizeSuite) TestContainerResizeWithInvalidSize(c *chec c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 400) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestResizeStoppedContainer is to verify resize a stopped container. @@ -82,5 +82,5 @@ func (suite *APIContainerResizeSuite) TestResizeStoppedContainer(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/api_container_restart_test.go b/test/api_container_restart_test.go index 840607c3c..d25a68f0d 100644 --- a/test/api_container_restart_test.go +++ b/test/api_container_restart_test.go @@ -39,7 +39,7 @@ func (suite *APIContainerRestartSuite) TestAPIContainerRestart(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestAPIRestartStoppedContainer it to verify restarting a stopped container. @@ -56,7 +56,7 @@ func (suite *APIContainerRestartSuite) TestAPIRestartStoppedContainer(c *check.C c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestAPIRestartPausedContainer is to verify restarting a paused container. @@ -75,5 +75,5 @@ func (suite *APIContainerRestartSuite) TestAPIRestartPausedContainer(c *check.C) c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/api_container_start_test.go b/test/api_container_start_test.go index 77eac994c..d78229c3e 100644 --- a/test/api_container_start_test.go +++ b/test/api_container_start_test.go @@ -32,7 +32,7 @@ func (suite *APIContainerStartSuite) TestStartOk(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestNonExistingContainer tests start a non-existing container return 404. @@ -58,7 +58,7 @@ func (suite *APIContainerStartSuite) TestStartStoppedContainer(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestStartPausedContainer tests start a contain in paused state will fail. @@ -75,7 +75,7 @@ func (suite *APIContainerStartSuite) TestStartPausedContainer(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestStartDetachKeyWork test detatch-keys works. @@ -94,7 +94,7 @@ func (suite *APIContainerStartSuite) TestStartDetachKeyWork(c *check.C) { // TODO: check the "EOF" detatchkey really works. - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestInvalidParam tests using invalid parameter return. diff --git a/test/api_container_stop_test.go b/test/api_container_stop_test.go index 69495dbf3..6d02566bf 100644 --- a/test/api_container_stop_test.go +++ b/test/api_container_stop_test.go @@ -34,7 +34,7 @@ func (suite *APIContainerStopSuite) TestStopOk(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestNonExistingContainer tests stop a non-existing container return 404. @@ -60,7 +60,7 @@ func (suite *APIContainerStopSuite) TestStopWait(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestInvalidParam tests using invalid parameter return. @@ -95,5 +95,5 @@ func (suite *APIContainerStopSuite) TestStopPausedContainer(c *check.C) { c.Assert(err, check.IsNil) c.Assert(string(got.State.Status), check.Equals, "stopped") - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/api_container_wait_test.go b/test/api_container_wait_test.go index 3dff9aa42..735a7408f 100644 --- a/test/api_container_wait_test.go +++ b/test/api_container_wait_test.go @@ -35,7 +35,7 @@ func (suite *APIContainerWaitSuite) TestWaitOk(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 200) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestWaitRunningContainer tests waiting a running container to stop, then returns 200. @@ -67,7 +67,7 @@ func (suite *APIContainerWaitSuite) TestWaitRunningContainer(c *check.C) { case <-time.After(2 * time.Second): c.Errorf("timeout waiting for `pouch wait` API to exit") } - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } // TestWaitNonExistingContainer tests waiting a non-existing container return 404. diff --git a/test/api_image_delete_test.go b/test/api_image_delete_test.go index 83fbaf50e..02690c1a8 100644 --- a/test/api_image_delete_test.go +++ b/test/api_image_delete_test.go @@ -37,5 +37,5 @@ func (suite *APIImageDeleteSuite) TestDeleteUsingImage(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 500) - DelContainerForceOk(c, cname) + DelContainerForceMultyTime(c, cname) } diff --git a/test/util_api.go b/test/util_api.go index d3986b80a..439913af3 100644 --- a/test/util_api.go +++ b/test/util_api.go @@ -88,27 +88,27 @@ func DelContainerForceMultyTime(c *check.C, cname string) { q := url.Values{} q.Add("force", "true") - ch := make(chan bool, 1) + done := make(chan bool, 1) ticker := time.NewTicker(500 * time.Millisecond) defer ticker.Stop() - done := make(chan bool) + timeout := make(chan bool) go func() { time.Sleep(3 * time.Second) - done <- true + timeout <- true }() for { select { - case <-ch: - return case <-done: return + case <-timeout: + return case <-ticker.C: resp, _ := DelContainerForce(c, cname) if resp.StatusCode == 204 { - ch <- true + done <- true } } }