Left: | ||
Right: |
OLD | NEW |
---|---|
1 package nova_test | 1 package nova_test |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 . "launchpad.net/gocheck" | 5 . "launchpad.net/gocheck" |
6 "launchpad.net/goose/client" | 6 "launchpad.net/goose/client" |
7 "launchpad.net/goose/errors" | 7 "launchpad.net/goose/errors" |
8 goosehttp "launchpad.net/goose/http" | 8 goosehttp "launchpad.net/goose/http" |
9 "launchpad.net/goose/identity" | 9 "launchpad.net/goose/identity" |
10 "launchpad.net/goose/nova" | 10 "launchpad.net/goose/nova" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 novaClient := s.setupClient(c, nil) | 216 novaClient := s.setupClient(c, nil) |
217 up := s.openstack.Identity.(*identityservice.UserPass) | 217 up := s.openstack.Identity.(*identityservice.UserPass) |
218 cleanup := up.RegisterControlPoint("authorisation", s.authHook(up)) | 218 cleanup := up.RegisterControlPoint("authorisation", s.authHook(up)) |
219 defer cleanup() | 219 defer cleanup() |
220 | 220 |
221 // If the re-authentication fails, ensure an Unauthorised error is retur ned. | 221 // If the re-authentication fails, ensure an Unauthorised error is retur ned. |
222 s.badTokens = 2 | 222 s.badTokens = 2 |
223 _, err := novaClient.ListServers(nil) | 223 _, err := novaClient.ListServers(nil) |
224 c.Assert(errors.IsUnauthorised(err), Equals, true) | 224 c.Assert(errors.IsUnauthorised(err), Equals, true) |
225 } | 225 } |
226 | |
227 func (s *localLiveSuite) TestListAvailabilityZonesUnimplemented(c *C) { | |
228 // When the test service has no availability zones registered, | |
229 // the /os-availability-zone API will return 404. We swallow | |
230 // that error. | |
231 s.openstack.Nova.SetAvailabilityZones() | |
232 listedZones, err := s.nova.ListAvailabilityZones() | |
233 c.Assert(err, IsNil) | |
234 c.Assert(listedZones, HasLen, 0) | |
235 } | |
236 | |
237 func (s *localLiveSuite) setAvailabilityZones() []nova.AvailabilityZone { | |
238 zones := []nova.AvailabilityZone{ | |
239 nova.AvailabilityZone{Name: "az1"}, | |
240 nova.AvailabilityZone{ | |
241 Name: "az2", State: nova.AvailabilityZoneState{Available : true}, | |
242 }, | |
243 } | |
244 s.openstack.Nova.SetAvailabilityZones(zones...) | |
245 return zones | |
246 } | |
247 | |
248 func (s *localLiveSuite) TestListAvailabilityZones(c *C) { | |
249 zones := s.setAvailabilityZones() | |
250 listedZones, err := s.nova.ListAvailabilityZones() | |
251 c.Assert(err, IsNil) | |
dfc
2014/06/06 04:33:17
Are these zones guaranteed to be returned in order
axw
2014/06/06 05:09:32
Yes, they are sorted by the server.
| |
252 c.Assert(listedZones, DeepEquals, zones) | |
253 } | |
254 | |
255 func (s *localLiveSuite) TestRunServerAvailabilityZone(c *C) { | |
256 s.setAvailabilityZones() | |
257 inst, err := s.runServerAvailabilityZone("az2") | |
258 c.Assert(err, IsNil) | |
259 defer s.nova.DeleteServer(inst.Id) | |
260 server, err := s.nova.GetServer(inst.Id) | |
261 c.Assert(err, IsNil) | |
262 c.Assert(server.AvailabilityZone, Equals, "az2") | |
263 } | |
264 | |
265 func (s *localLiveSuite) TestRunServerAvailabilityZoneNotAvailable(c *C) { | |
266 s.setAvailabilityZones() | |
267 // az1 is known, but not currently available. | |
268 _, err := s.runServerAvailabilityZone("az1") | |
269 c.Assert(err, ErrorMatches, "(.|\n)*The requested availability zone is n ot available(.|\n)*") | |
270 } | |
OLD | NEW |