forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_daemon_update_test.go
64 lines (52 loc) · 1.41 KB
/
api_daemon_update_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
package main
import (
"github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"
"github.com/go-check/check"
)
// APIDaemonUpdateSuite is the test suite for daemon update API.
type APIDaemonUpdateSuite struct{}
func init() {
check.Suite(&APIDaemonUpdateSuite{})
}
// SetUpTest does common setup in the beginning of each test.
func (suite *APIDaemonUpdateSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
}
// TestStartOk tests starting container could work.
func (suite *APIDaemonUpdateSuite) TestUpdateDaemon(c *check.C) {
labels := []string{
"storage=ssd",
"zone=shanghai",
}
obj := map[string]interface{}{
"Labels": labels,
"ImageProxy": "http://192.168.0.3:2378",
}
body := request.WithJSONBody(obj)
resp, err := request.Post("/daemon/update", body)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 200)
resp, err = request.Get("/info", body)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 200)
info := types.SystemInfo{}
err = request.DecodeBody(&info, resp.Body)
c.Assert(err, check.IsNil)
for _, label := range labels {
isContained := false
for _, infoLabel := range info.Labels {
if infoLabel == label {
isContained = true
break
}
}
if !isContained {
c.Fatalf("label %s should be in labels in info API", label)
}
}
// TODO: missing case
//
// add checking image proxy
}