forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_container_resize.go
85 lines (61 loc) · 2.11 KB
/
api_container_resize.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
76
77
78
79
80
81
82
83
84
85
package main
import (
"net/url"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"
"github.com/go-check/check"
)
// APIContainerResizeSuite is the test suite for container upgrade API.
type APIContainerResizeSuite struct{}
func init() {
check.Suite(&APIContainerResizeSuite{})
}
// SetUpTest does common setup in the beginning of each test.
func (suite *APIContainerResizeSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
}
// TestContainerResizeOk is to verify resize container.
func (suite *APIContainerResizeSuite) TestContainerResizeOk(c *check.C) {
cname := "TestContainerResizeOk"
CreateBusyboxContainerOk(c, cname)
resp, err := request.Post("/containers/" + cname + "/start")
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
q := url.Values{}
q.Add("h", "10")
q.Add("w", "10")
query := request.WithQuery(q)
resp, err = request.Post("/containers/"+cname+"/resize", query)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 200)
DelContainerForceOk(c, cname)
}
// TestContainerResizeWithInvalidSize is to verify resize container with invalid size.
func (suite *APIContainerResizeSuite) TestContainerResizeWithInvalidSize(c *check.C) {
cname := "TestContainerResizeWithInvalidSize"
CreateBusyboxContainerOk(c, cname)
resp, err := request.Post("/containers/" + cname + "/start")
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 204)
q := url.Values{}
q.Add("h", "hi")
q.Add("w", "wo")
query := request.WithQuery(q)
resp, err = request.Post("/containers/"+cname+"/resize", query)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 400)
DelContainerForceOk(c, cname)
}
// TestResizeStoppedContainer is to verify resize a stopped container.
func (suite *APIContainerResizeSuite) TestResizeStoppedContainer(c *check.C) {
cname := "TestResizeStoppedContainer"
CreateBusyboxContainerOk(c, cname)
q := url.Values{}
q.Add("h", "10")
q.Add("w", "10")
query := request.WithQuery(q)
resp, err := request.Post("/containers/"+cname+"/resize", query)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 500)
DelContainerForceOk(c, cname)
}