LEFT | RIGHT |
1 package ec2_test | 1 package ec2_test |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "launchpad.net/goamz/aws" | 5 "launchpad.net/goamz/aws" |
6 "launchpad.net/goamz/ec2" | 6 "launchpad.net/goamz/ec2" |
7 "launchpad.net/goamz/ec2/ec2test" | 7 "launchpad.net/goamz/ec2/ec2test" |
8 . "launchpad.net/gocheck" | 8 . "launchpad.net/gocheck" |
9 "sort" | 9 "sort" |
10 ) | 10 ) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 c.Assert(err, IsNil) | 67 c.Assert(err, IsNil) |
68 c.Assert(inst, NotNil) | 68 c.Assert(inst, NotNil) |
69 c.Assert(inst.Instances[0].DNSName, Equals, inst.Instances[0].InstanceId
+".example.com") | 69 c.Assert(inst.Instances[0].DNSName, Equals, inst.Instances[0].InstanceId
+".example.com") |
70 | 70 |
71 id := inst.Instances[0].InstanceId | 71 id := inst.Instances[0].InstanceId |
72 | 72 |
73 defer s.ec2.TerminateInstances([]string{id}) | 73 defer s.ec2.TerminateInstances([]string{id}) |
74 | 74 |
75 tinst := s.srv.srv.Instance(id) | 75 tinst := s.srv.srv.Instance(id) |
76 c.Assert(tinst, NotNil) | 76 c.Assert(tinst, NotNil) |
77 » c.Assert(tinst.UserData, Equals, data) | 77 » c.Assert(tinst.UserData, DeepEquals, data) |
78 } | 78 } |
79 | 79 |
80 // AmazonServerSuite runs the ec2test server tests against a live EC2 server. | 80 // AmazonServerSuite runs the ec2test server tests against a live EC2 server. |
81 // It will only be activated if the -all flag is specified. | 81 // It will only be activated if the -all flag is specified. |
82 type AmazonServerSuite struct { | 82 type AmazonServerSuite struct { |
83 srv AmazonServer | 83 srv AmazonServer |
84 ServerTests | 84 ServerTests |
85 } | 85 } |
86 | 86 |
87 var _ = Suite(&AmazonServerSuite{}) | 87 var _ = Suite(&AmazonServerSuite{}) |
(...skipping 15 matching lines...) Expand all Loading... |
103 } | 103 } |
104 | 104 |
105 func terminateInstances(c *C, e *ec2.EC2, insts []*ec2.Instance) { | 105 func terminateInstances(c *C, e *ec2.EC2, insts []*ec2.Instance) { |
106 var ids []string | 106 var ids []string |
107 for _, inst := range insts { | 107 for _, inst := range insts { |
108 if inst != nil { | 108 if inst != nil { |
109 ids = append(ids, inst.InstanceId) | 109 ids = append(ids, inst.InstanceId) |
110 } | 110 } |
111 } | 111 } |
112 _, err := e.TerminateInstances(ids) | 112 _, err := e.TerminateInstances(ids) |
113 » c.Check(err, IsNil, Bug("%d INSTANCES LEFT RUNNING!!!", len(ids))) | 113 » c.Check(err, IsNil, Commentf("%d INSTANCES LEFT RUNNING!!!", len(ids))) |
114 } | 114 } |
115 | 115 |
116 func (s *ServerTests) makeTestGroup(c *C, name, descr string) ec2.SecurityGroup
{ | 116 func (s *ServerTests) makeTestGroup(c *C, name, descr string) ec2.SecurityGroup
{ |
117 // Clean it up if a previous test left it around. | 117 // Clean it up if a previous test left it around. |
118 _, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name}) | 118 _, err := s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name}) |
119 if err != nil && err.(*ec2.Error).Code != "InvalidGroup.NotFound" { | 119 if err != nil && err.(*ec2.Error).Code != "InvalidGroup.NotFound" { |
120 c.Fatalf("delete security group: %v", err) | 120 c.Fatalf("delete security group: %v", err) |
121 } | 121 } |
122 | 122 |
123 resp, err := s.ec2.CreateSecurityGroup(name, descr) | 123 resp, err := s.ec2.CreateSecurityGroup(name, descr) |
124 c.Assert(err, IsNil) | 124 c.Assert(err, IsNil) |
125 c.Assert(resp.Name, Equals, name) | 125 c.Assert(resp.Name, Equals, name) |
126 return resp.SecurityGroup | 126 return resp.SecurityGroup |
127 } | 127 } |
128 | 128 |
129 func (s *ServerTests) TestIPPerms(c *C) { | 129 func (s *ServerTests) TestIPPerms(c *C) { |
130 g0 := s.makeTestGroup(c, "goamz-test0", "ec2test group 0") | 130 g0 := s.makeTestGroup(c, "goamz-test0", "ec2test group 0") |
131 defer s.ec2.DeleteSecurityGroup(g0) | 131 defer s.ec2.DeleteSecurityGroup(g0) |
132 | 132 |
133 g1 := s.makeTestGroup(c, "goamz-test1", "ec2test group 1") | 133 g1 := s.makeTestGroup(c, "goamz-test1", "ec2test group 1") |
134 defer s.ec2.DeleteSecurityGroup(g1) | 134 defer s.ec2.DeleteSecurityGroup(g1) |
135 | 135 |
136 resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{g0, g1}, nil) | 136 resp, err := s.ec2.SecurityGroups([]ec2.SecurityGroup{g0, g1}, nil) |
137 c.Assert(err, IsNil) | 137 c.Assert(err, IsNil) |
138 » c.Assert(len(resp.Groups), Equals, 2) | 138 » c.Assert(resp.Groups, HasLen, 2) |
139 » c.Assert(len(resp.Groups[0].IPPerms), Equals, 0) | 139 » c.Assert(resp.Groups[0].IPPerms, HasLen, 0) |
140 » c.Assert(len(resp.Groups[1].IPPerms), Equals, 0) | 140 » c.Assert(resp.Groups[1].IPPerms, HasLen, 0) |
141 | 141 |
142 ownerId := resp.Groups[0].OwnerId | 142 ownerId := resp.Groups[0].OwnerId |
143 | 143 |
144 // test some invalid parameters | 144 // test some invalid parameters |
145 // TODO more | 145 // TODO more |
146 _, err = s.ec2.AuthorizeSecurityGroup(g0, []ec2.IPPerm{{ | 146 _, err = s.ec2.AuthorizeSecurityGroup(g0, []ec2.IPPerm{{ |
147 Protocol: "tcp", | 147 Protocol: "tcp", |
148 FromPort: 0, | 148 FromPort: 0, |
149 ToPort: 1024, | 149 ToPort: 1024, |
150 SourceIPs: []string{"z127.0.0.1/24"}, | 150 SourceIPs: []string{"z127.0.0.1/24"}, |
(...skipping 16 matching lines...) Expand all Loading... |
167 }, { | 167 }, { |
168 Protocol: "tcp", | 168 Protocol: "tcp", |
169 FromPort: 2000, | 169 FromPort: 2000, |
170 ToPort: 2001, | 170 ToPort: 2001, |
171 SourceIPs: []string{"200.1.1.34/32"}, | 171 SourceIPs: []string{"200.1.1.34/32"}, |
172 }}) | 172 }}) |
173 c.Assert(err, IsNil) | 173 c.Assert(err, IsNil) |
174 | 174 |
175 resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil) | 175 resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil) |
176 c.Assert(err, IsNil) | 176 c.Assert(err, IsNil) |
177 » c.Assert(len(resp.Groups), Equals, 1) | 177 » c.Assert(resp.Groups, HasLen, 1) |
178 » c.Assert(len(resp.Groups[0].IPPerms), Equals, 1) | 178 » c.Assert(resp.Groups[0].IPPerms, HasLen, 1) |
179 | 179 |
180 perm := resp.Groups[0].IPPerms[0] | 180 perm := resp.Groups[0].IPPerms[0] |
181 srcg := perm.SourceGroups | 181 srcg := perm.SourceGroups |
182 » c.Assert(len(srcg), Equals, 2) | 182 » c.Assert(srcg, HasLen, 2) |
183 | 183 |
184 // Normalize so we don't care about returned order. | 184 // Normalize so we don't care about returned order. |
185 if srcg[0].Name == g1.Name { | 185 if srcg[0].Name == g1.Name { |
186 srcg[0], srcg[1] = srcg[1], srcg[0] | 186 srcg[0], srcg[1] = srcg[1], srcg[0] |
187 } | 187 } |
188 c.Check(srcg[0].Name, Equals, g0.Name) | 188 c.Check(srcg[0].Name, Equals, g0.Name) |
189 c.Check(srcg[0].Id, Equals, g0.Id) | 189 c.Check(srcg[0].Id, Equals, g0.Id) |
190 c.Check(srcg[0].OwnerId, Equals, ownerId) | 190 c.Check(srcg[0].OwnerId, Equals, ownerId) |
191 c.Check(srcg[1].Name, Equals, g1.Name) | 191 c.Check(srcg[1].Name, Equals, g1.Name) |
192 c.Check(srcg[1].Id, Equals, g1.Id) | 192 c.Check(srcg[1].Id, Equals, g1.Id) |
193 c.Check(srcg[1].OwnerId, Equals, ownerId) | 193 c.Check(srcg[1].OwnerId, Equals, ownerId) |
194 | 194 |
195 sort.Strings(perm.SourceIPs) | 195 sort.Strings(perm.SourceIPs) |
196 » c.Check(perm.SourceIPs, Equals, []string{"127.0.0.0/24", "200.1.1.34/32"
}) | 196 » c.Check(perm.SourceIPs, DeepEquals, []string{"127.0.0.0/24", "200.1.1.34
/32"}) |
197 | 197 |
198 // Check that we can't delete g1 (because g0 is using it) | 198 // Check that we can't delete g1 (because g0 is using it) |
199 _, err = s.ec2.DeleteSecurityGroup(g1) | 199 _, err = s.ec2.DeleteSecurityGroup(g1) |
200 c.Assert(err, NotNil) | 200 c.Assert(err, NotNil) |
201 c.Check(err.(*ec2.Error).Code, Equals, "InvalidGroup.InUse") | 201 c.Check(err.(*ec2.Error).Code, Equals, "InvalidGroup.InUse") |
202 | 202 |
203 _, err = s.ec2.RevokeSecurityGroup(g0, []ec2.IPPerm{{ | 203 _, err = s.ec2.RevokeSecurityGroup(g0, []ec2.IPPerm{{ |
204 Protocol: "tcp", | 204 Protocol: "tcp", |
205 FromPort: 2000, | 205 FromPort: 2000, |
206 ToPort: 2001, | 206 ToPort: 2001, |
207 SourceGroups: []ec2.UserSecurityGroup{{Id: g1.Id}}, | 207 SourceGroups: []ec2.UserSecurityGroup{{Id: g1.Id}}, |
208 }, { | 208 }, { |
209 Protocol: "tcp", | 209 Protocol: "tcp", |
210 FromPort: 2000, | 210 FromPort: 2000, |
211 ToPort: 2001, | 211 ToPort: 2001, |
212 SourceIPs: []string{"200.1.1.34/32"}, | 212 SourceIPs: []string{"200.1.1.34/32"}, |
213 }}) | 213 }}) |
214 c.Assert(err, IsNil) | 214 c.Assert(err, IsNil) |
215 | 215 |
216 resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil) | 216 resp, err = s.ec2.SecurityGroups([]ec2.SecurityGroup{g0}, nil) |
217 c.Assert(err, IsNil) | 217 c.Assert(err, IsNil) |
218 » c.Assert(len(resp.Groups), Equals, 1) | 218 » c.Assert(resp.Groups, HasLen, 1) |
219 » c.Assert(len(resp.Groups[0].IPPerms), Equals, 1) | 219 » c.Assert(resp.Groups[0].IPPerms, HasLen, 1) |
220 | 220 |
221 perm = resp.Groups[0].IPPerms[0] | 221 perm = resp.Groups[0].IPPerms[0] |
222 srcg = perm.SourceGroups | 222 srcg = perm.SourceGroups |
223 » c.Assert(len(srcg), Equals, 1) | 223 » c.Assert(srcg, HasLen, 1) |
224 c.Check(srcg[0].Name, Equals, g0.Name) | 224 c.Check(srcg[0].Name, Equals, g0.Name) |
225 c.Check(srcg[0].Id, Equals, g0.Id) | 225 c.Check(srcg[0].Id, Equals, g0.Id) |
226 c.Check(srcg[0].OwnerId, Equals, ownerId) | 226 c.Check(srcg[0].OwnerId, Equals, ownerId) |
227 | 227 |
228 » c.Check(perm.SourceIPs, Equals, []string{"127.0.0.0/24"}) | 228 » c.Check(perm.SourceIPs, DeepEquals, []string{"127.0.0.0/24"}) |
229 | 229 |
230 // We should be able to delete g1 now because we've removed its only use
. | 230 // We should be able to delete g1 now because we've removed its only use
. |
231 _, err = s.ec2.DeleteSecurityGroup(g1) | 231 _, err = s.ec2.DeleteSecurityGroup(g1) |
232 c.Assert(err, IsNil) | 232 c.Assert(err, IsNil) |
233 | 233 |
234 _, err = s.ec2.DeleteSecurityGroup(g0) | 234 _, err = s.ec2.DeleteSecurityGroup(g0) |
235 c.Assert(err, IsNil) | 235 c.Assert(err, IsNil) |
236 | 236 |
237 f := ec2.NewFilter() | 237 f := ec2.NewFilter() |
238 f.Add("group-id", g0.Id, g1.Id) | 238 f.Add("group-id", g0.Id, g1.Id) |
239 resp, err = s.ec2.SecurityGroups(nil, f) | 239 resp, err = s.ec2.SecurityGroups(nil, f) |
240 c.Assert(err, IsNil) | 240 c.Assert(err, IsNil) |
241 » c.Assert(len(resp.Groups), Equals, 0) | 241 » c.Assert(resp.Groups, HasLen, 0) |
242 } | 242 } |
243 | 243 |
244 func (s *ServerTests) TestDuplicateIPPerm(c *C) { | 244 func (s *ServerTests) TestDuplicateIPPerm(c *C) { |
245 name := "goamz-test" | 245 name := "goamz-test" |
246 descr := "goamz security group for tests" | 246 descr := "goamz security group for tests" |
247 | 247 |
248 // Clean it up, if a previous test left it around and avoid leaving it a
round. | 248 // Clean it up, if a previous test left it around and avoid leaving it a
round. |
249 s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name}) | 249 s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name}) |
250 defer s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name}) | 250 defer s.ec2.DeleteSecurityGroup(ec2.SecurityGroup{Name: name}) |
251 | 251 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 318 |
319 tests := []struct { | 319 tests := []struct { |
320 instanceIds []string // instanceIds argument to Instances me
thod. | 320 instanceIds []string // instanceIds argument to Instances me
thod. |
321 filters []filterSpec // filters argument to Instances method
. | 321 filters []filterSpec // filters argument to Instances method
. |
322 resultIds []string // set of instance ids of expected resu
lts. | 322 resultIds []string // set of instance ids of expected resu
lts. |
323 allowExtra bool // resultIds may be incomplete. | 323 allowExtra bool // resultIds may be incomplete. |
324 err string // expected error. | 324 err string // expected error. |
325 }{ | 325 }{ |
326 // check that Instances returns all instances. | 326 // check that Instances returns all instances. |
327 { | 327 { |
328 » » » nil, | 328 » » » resultIds: ids(0, 1, 2), |
329 » » » nil, | 329 » » » allowExtra: true, |
330 » » » ids(0, 1, 2), | |
331 » » » true, | |
332 » » » "", | |
333 }, | 330 }, |
334 // check that specifying two instance ids returns them. | 331 // check that specifying two instance ids returns them. |
335 { | 332 { |
336 » » » ids(0, 2), | 333 » » » instanceIds: ids(0, 2), |
337 » » » nil, | 334 » » » resultIds: ids(0, 2), |
338 » » » ids(0, 2), | |
339 » » » false, | |
340 » » » "", | |
341 }, | 335 }, |
342 // check that specifying a non-existent instance id gives an err
or | 336 // check that specifying a non-existent instance id gives an err
or |
343 { | 337 { |
344 » » » append(ids(0), "i-deadbeef12345"), | 338 » » » instanceIds: append(ids(0), "i-deadbeef12345"), |
345 » » » nil, | 339 » » » err: `.*\(InvalidInstanceID\.NotFound\)`, |
346 » » » nil, | |
347 » » » false, | |
348 » » » `.*\(InvalidInstanceID\.NotFound\)`, | |
349 }, | 340 }, |
350 // check that a filter allowed both instances returns both of th
em. | 341 // check that a filter allowed both instances returns both of th
em. |
351 { | 342 { |
352 » » » nil, | 343 » » » filters: []filterSpec{ |
353 » » » []filterSpec{ | |
354 {"instance-id", ids(0, 2)}, | 344 {"instance-id", ids(0, 2)}, |
355 }, | 345 }, |
356 » » » ids(0, 2), | 346 » » » resultIds: ids(0, 2), |
357 » » » false, | |
358 » » » "", | |
359 }, | 347 }, |
360 // check that a filter allowing only one instance returns it. | 348 // check that a filter allowing only one instance returns it. |
361 { | 349 { |
362 » » » nil, | 350 » » » filters: []filterSpec{ |
363 » » » []filterSpec{ | |
364 {"instance-id", ids(1)}, | 351 {"instance-id", ids(1)}, |
365 }, | 352 }, |
366 » » » ids(1), | 353 » » » resultIds: ids(1), |
367 » » » false, | |
368 » » » "", | |
369 }, | 354 }, |
370 // check that a filter allowing no instances returns none | 355 // check that a filter allowing no instances returns none |
371 { | 356 { |
372 » » » nil, | 357 » » » filters: []filterSpec{ |
373 » » » []filterSpec{ | |
374 {"instance-id", []string{"i-deadbeef12345"}}, | 358 {"instance-id", []string{"i-deadbeef12345"}}, |
375 }, | 359 }, |
376 » » » nil, | 360 » » }, |
377 » » » false, | 361 » » { |
378 » » » "", | 362 » » » filters: []filterSpec{ |
379 » » }, | |
380 » » { | |
381 » » » nil, | |
382 » » » []filterSpec{ | |
383 {"group-id", []string{group1.Id}}, | 363 {"group-id", []string{group1.Id}}, |
384 }, | 364 }, |
385 » » » ids(0, 1), | 365 » » » resultIds: ids(0, 1), |
386 » » » false, | 366 » » }, |
387 » » » "", | 367 » » { |
388 » » }, | 368 » » » filters: []filterSpec{ |
389 » » { | |
390 » » » nil, | |
391 » » » []filterSpec{ | |
392 {"group-name", []string{group1.Name}}, | 369 {"group-name", []string{group1.Name}}, |
393 }, | 370 }, |
394 » » » ids(0, 1), | 371 » » » resultIds: ids(0, 1), |
395 » » » false, | 372 » » }, |
396 » » » "", | 373 » » { |
397 » » }, | 374 » » » filters: []filterSpec{ |
398 » » { | |
399 » » » nil, | |
400 » » » []filterSpec{ | |
401 {"image-id", []string{imageId}}, | 375 {"image-id", []string{imageId}}, |
402 }, | 376 }, |
403 » » » ids(0, 1), | 377 » » » resultIds: ids(0, 1), |
404 » » » true, | 378 » » » allowExtra: true, |
405 » » » "", | |
406 }, | 379 }, |
407 // combination filters. | 380 // combination filters. |
408 { | 381 { |
409 » » » nil, | 382 » » » filters: []filterSpec{ |
410 » » » []filterSpec{ | |
411 {"image-id", []string{imageId, imageId2}}, | 383 {"image-id", []string{imageId, imageId2}}, |
412 {"group-name", []string{group1.Name}}, | 384 {"group-name", []string{group1.Name}}, |
413 }, | 385 }, |
414 » » » ids(0, 1), | 386 » » » resultIds: ids(0, 1), |
415 » » » false, | 387 » » }, |
416 » » » "", | 388 » » { |
417 » » }, | 389 » » » filters: []filterSpec{ |
418 » » { | |
419 » » » nil, | |
420 » » » []filterSpec{ | |
421 {"image-id", []string{imageId2}}, | 390 {"image-id", []string{imageId2}}, |
422 {"group-name", []string{group1.Name}}, | 391 {"group-name", []string{group1.Name}}, |
423 }, | 392 }, |
424 nil, | |
425 false, | |
426 "", | |
427 }, | 393 }, |
428 } | 394 } |
429 for i, t := range tests { | 395 for i, t := range tests { |
| 396 c.Logf("test %d", i) |
430 var f *ec2.Filter | 397 var f *ec2.Filter |
431 if t.filters != nil { | 398 if t.filters != nil { |
432 f = ec2.NewFilter() | 399 f = ec2.NewFilter() |
433 for _, spec := range t.filters { | 400 for _, spec := range t.filters { |
434 f.Add(spec.name, spec.values...) | 401 f.Add(spec.name, spec.values...) |
435 } | 402 } |
436 } | 403 } |
437 resp, err := s.ec2.Instances(t.instanceIds, f) | 404 resp, err := s.ec2.Instances(t.instanceIds, f) |
438 if t.err != "" { | 405 if t.err != "" { |
439 » » » c.Check(err, ErrorMatches, t.err, Bug("test %d", i)) | 406 » » » c.Check(err, ErrorMatches, t.err) |
440 continue | 407 continue |
441 } | 408 } |
442 » » c.Assert(err, IsNil, Bug("test %d", i)) | 409 » » c.Assert(err, IsNil) |
443 insts := make(map[string]*ec2.Instance) | 410 insts := make(map[string]*ec2.Instance) |
444 for _, r := range resp.Reservations { | 411 for _, r := range resp.Reservations { |
445 for j := range r.Instances { | 412 for j := range r.Instances { |
446 inst := &r.Instances[j] | 413 inst := &r.Instances[j] |
447 » » » » c.Check(insts[inst.InstanceId], IsNil, Bug("test
%d, duplicate instance id: %q", i, inst.InstanceId)) | 414 » » » » c.Check(insts[inst.InstanceId], IsNil, Commentf(
"duplicate instance id: %q", inst.InstanceId)) |
448 insts[inst.InstanceId] = inst | 415 insts[inst.InstanceId] = inst |
449 } | 416 } |
450 } | 417 } |
451 if !t.allowExtra { | 418 if !t.allowExtra { |
452 » » » c.Check(len(insts), Equals, len(t.resultIds), Bug("test
%d, expected %d instances got %#v", i, len(t.resultIds), insts)) | 419 » » » c.Check(insts, HasLen, len(t.resultIds), Commentf("expec
ted %d instances got %#v", len(t.resultIds), insts)) |
453 } | 420 } |
454 for j, id := range t.resultIds { | 421 for j, id := range t.resultIds { |
455 » » » c.Check(insts[id], NotNil, Bug("test %d, instance id %d
(%q) not found; got %#v", i, j, id, insts)) | 422 » » » c.Check(insts[id], NotNil, Commentf("instance id %d (%q)
not found; got %#v", j, id, insts)) |
456 } | 423 } |
457 } | 424 } |
458 } | 425 } |
459 | 426 |
460 func idsOnly(gs []ec2.SecurityGroup) []ec2.SecurityGroup { | 427 func idsOnly(gs []ec2.SecurityGroup) []ec2.SecurityGroup { |
461 for i := range gs { | 428 for i := range gs { |
462 gs[i].Name = "" | 429 gs[i].Name = "" |
463 } | 430 } |
464 return gs | 431 return gs |
465 } | 432 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 c.Logf("test %d", i) | 572 c.Logf("test %d", i) |
606 var f *ec2.Filter | 573 var f *ec2.Filter |
607 if t.filters != nil { | 574 if t.filters != nil { |
608 f = ec2.NewFilter() | 575 f = ec2.NewFilter() |
609 for _, spec := range t.filters { | 576 for _, spec := range t.filters { |
610 f.Add(spec.name, spec.values...) | 577 f.Add(spec.name, spec.values...) |
611 } | 578 } |
612 } | 579 } |
613 resp, err := s.ec2.SecurityGroups(t.groups, f) | 580 resp, err := s.ec2.SecurityGroups(t.groups, f) |
614 if t.err != "" { | 581 if t.err != "" { |
615 » » » c.Check(err, ErrorMatches, t.err, Bug("test %d", i)) | 582 » » » c.Check(err, ErrorMatches, t.err) |
616 continue | 583 continue |
617 } | 584 } |
618 » » c.Assert(err, IsNil, Bug("test %d", i)) | 585 » » c.Assert(err, IsNil) |
619 groups := make(map[string]*ec2.SecurityGroup) | 586 groups := make(map[string]*ec2.SecurityGroup) |
620 for j := range resp.Groups { | 587 for j := range resp.Groups { |
621 group := &resp.Groups[j].SecurityGroup | 588 group := &resp.Groups[j].SecurityGroup |
622 » » » c.Check(groups[group.Id], IsNil, Bug("duplicate group id
: %q", group.Id)) | 589 » » » c.Check(groups[group.Id], IsNil, Commentf("duplicate gro
up id: %q", group.Id)) |
623 groups[group.Id] = group | 590 groups[group.Id] = group |
624 } | 591 } |
625 if !t.allowExtra { | 592 if !t.allowExtra { |
626 » » » c.Check(len(groups), Equals, len(t.results), Bug("expect
ed %d groups got %#v", len(t.results), groups)) | 593 » » » c.Check(groups, HasLen, len(t.results)) |
627 } | 594 } |
628 for j, g := range t.results { | 595 for j, g := range t.results { |
629 rg := groups[g.Id] | 596 rg := groups[g.Id] |
630 » » » c.Assert(rg, NotNil, Bug("group %d (%v) not found; got %
#v", j, g, groups)) | 597 » » » c.Assert(rg, NotNil, Commentf("group %d (%v) not found;
got %#v", j, g, groups)) |
631 » » » c.Check(rg.Name, Equals, g.Name, Bug("group %d (%v)", j,
g)) | 598 » » » c.Check(rg.Name, Equals, g.Name, Commentf("group %d (%v)
", j, g)) |
632 » » } | 599 » » } |
633 » } | 600 » } |
634 } | 601 } |
LEFT | RIGHT |