forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_container_restart_test.go
75 lines (55 loc) · 1.95 KB
/
api_container_restart_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"net/url"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"
"github.com/go-check/check"
)
// APIContainerRestartSuite is the test suite for container upgrade API.
type APIContainerRestartSuite struct{}
func init() {
check.Suite(&APIContainerRestartSuite{})
}
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerRestartSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
}
// TestAPIContainerRestart is to verify restarting container.
func (suite *APIContainerRestartSuite) TestAPIContainerRestart(c *check.C) {
cname := "TestAPIContainerRestart"
CreateBusyboxContainerOk(c, cname)
defer DelContainerForceMultyTime(c, cname)
StartContainerOk(c, cname)
q := url.Values{}
q.Add("t", "1")
query := request.WithQuery(q)
resp, err := request.Post("/containers/"+cname+"/restart", query)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
}
// TestAPIRestartStoppedContainer it to verify restarting a stopped container.
func (suite *APIContainerRestartSuite) TestAPIRestartStoppedContainer(c *check.C) {
cname := "TestAPIRestartStoppedContainer"
CreateBusyboxContainerOk(c, cname)
defer DelContainerForceMultyTime(c, cname)
q := url.Values{}
q.Add("t", "1")
query := request.WithQuery(q)
resp, err := request.Post("/containers/"+cname+"/restart", query)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
}
// TestAPIRestartPausedContainer is to verify restarting a paused container.
func (suite *APIContainerRestartSuite) TestAPIRestartPausedContainer(c *check.C) {
cname := "TestAPIRestartPauseContainer"
CreateBusyboxContainerOk(c, cname)
defer DelContainerForceMultyTime(c, cname)
StartContainerOk(c, cname)
PauseContainerOk(c, cname)
q := url.Values{}
q.Add("t", "1")
query := request.WithQuery(q)
resp, err := request.Post("/containers/"+cname+"/restart", query)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
}