Left: | ||
Right: |
OLD | NEW |
---|---|
1 // Nova double testing service - HTTP API tests | 1 // Nova double testing service - HTTP API tests |
2 | 2 |
3 package novaservice | 3 package novaservice |
4 | 4 |
5 import ( | 5 import ( |
6 "bytes" | 6 "bytes" |
7 "encoding/json" | 7 "encoding/json" |
8 "fmt" | 8 "fmt" |
9 "io/ioutil" | 9 "io/ioutil" |
10 . "launchpad.net/gocheck" | 10 . "launchpad.net/gocheck" |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 Address string `json:"address"` | 1168 Address string `json:"address"` |
1169 } `json:"removeFloatingIp"` | 1169 } `json:"removeFloatingIp"` |
1170 } | 1170 } |
1171 req.RemoveFloatingIP.Address = fip.IP | 1171 req.RemoveFloatingIP.Address = fip.IP |
1172 resp, err := s.jsonRequest("POST", "/servers/"+server.Id+"/action", req, nil) | 1172 resp, err := s.jsonRequest("POST", "/servers/"+server.Id+"/action", req, nil) |
1173 c.Assert(err, IsNil) | 1173 c.Assert(err, IsNil) |
1174 c.Assert(resp.StatusCode, Equals, http.StatusAccepted) | 1174 c.Assert(resp.StatusCode, Equals, http.StatusAccepted) |
1175 c.Assert(s.service.hasServerFloatingIP(server.Id, fip.IP), Equals, false ) | 1175 c.Assert(s.service.hasServerFloatingIP(server.Id, fip.IP), Equals, false ) |
1176 } | 1176 } |
1177 | 1177 |
1178 func (s *NovaHTTPSuite) TestListAvailabilityZones(c *C) { | |
1179 resp, err := s.jsonRequest("GET", "/os-availability-zone", nil, nil) | |
1180 c.Assert(err, IsNil) | |
1181 assertBody(c, resp, errNotFoundJSON) | |
1182 | |
1183 zones := []nova.AvailabilityZone{ | |
1184 nova.AvailabilityZone{Name: "az1"}, | |
1185 nova.AvailabilityZone{ | |
1186 Name: "az2", State: nova.AvailabilityZoneState{Available : true}, | |
1187 }, | |
1188 } | |
1189 s.service.SetAvailabilityZones(zones...) | |
1190 resp, err = s.jsonRequest("GET", "/os-availability-zone", nil, nil) | |
1191 c.Assert(err, IsNil) | |
1192 var expected struct { | |
1193 Zones []nova.AvailabilityZone `json:"availabilityZoneInfo"` | |
1194 } | |
1195 assertJSON(c, resp, &expected) | |
1196 c.Assert(expected.Zones, DeepEquals, zones) | |
dfc
2014/06/06 04:33:17
jc.SameContents
axw
2014/06/06 05:09:32
They are sorted by the server. No need to introduc
| |
1197 } | |
1198 | |
1178 func (s *NovaHTTPSSuite) SetUpSuite(c *C) { | 1199 func (s *NovaHTTPSSuite) SetUpSuite(c *C) { |
1179 s.HTTPSuite.SetUpSuite(c) | 1200 s.HTTPSuite.SetUpSuite(c) |
1180 identityDouble := identityservice.NewUserPass() | 1201 identityDouble := identityservice.NewUserPass() |
1181 userInfo := identityDouble.AddUser("fred", "secret", "tenant") | 1202 userInfo := identityDouble.AddUser("fred", "secret", "tenant") |
1182 s.token = userInfo.Token | 1203 s.token = userInfo.Token |
1183 c.Assert(s.Server.URL[:8], Equals, "https://") | 1204 c.Assert(s.Server.URL[:8], Equals, "https://") |
1184 s.service = New(s.Server.URL, versionPath, userInfo.TenantId, region, id entityDouble) | 1205 s.service = New(s.Server.URL, versionPath, userInfo.TenantId, region, id entityDouble) |
1185 } | 1206 } |
1186 | 1207 |
1187 func (s *NovaHTTPSSuite) TearDownSuite(c *C) { | 1208 func (s *NovaHTTPSSuite) TearDownSuite(c *C) { |
1188 s.HTTPSuite.TearDownSuite(c) | 1209 s.HTTPSuite.TearDownSuite(c) |
1189 } | 1210 } |
1190 | 1211 |
1191 func (s *NovaHTTPSSuite) SetUpTest(c *C) { | 1212 func (s *NovaHTTPSSuite) SetUpTest(c *C) { |
1192 s.HTTPSuite.SetUpTest(c) | 1213 s.HTTPSuite.SetUpTest(c) |
1193 s.service.SetupHTTP(s.Mux) | 1214 s.service.SetupHTTP(s.Mux) |
1194 } | 1215 } |
1195 | 1216 |
1196 func (s *NovaHTTPSSuite) TearDownTest(c *C) { | 1217 func (s *NovaHTTPSSuite) TearDownTest(c *C) { |
1197 s.HTTPSuite.TearDownTest(c) | 1218 s.HTTPSuite.TearDownTest(c) |
1198 } | 1219 } |
1199 | 1220 |
1200 func (s *NovaHTTPSSuite) TestHasHTTPSServiceURL(c *C) { | 1221 func (s *NovaHTTPSSuite) TestHasHTTPSServiceURL(c *C) { |
1201 endpoints := s.service.Endpoints() | 1222 endpoints := s.service.Endpoints() |
1202 c.Assert(endpoints[0].PublicURL[:8], Equals, "https://") | 1223 c.Assert(endpoints[0].PublicURL[:8], Equals, "https://") |
1203 } | 1224 } |
OLD | NEW |