Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(76)

Delta Between Two Patch Sets: ec2/vpc_test.go

Issue 54690048: ec2: Add support for VPC subnets (Closed)
Left Patch Set: ec2: Add support for VPC subnets Created 11 years, 2 months ago
Right Patch Set: ec2: Add support for VPC subnets Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « ec2/subnets_test.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // 1 //
2 // goamz - Go packages to interact with the Amazon Web Services. 2 // goamz - Go packages to interact with the Amazon Web Services.
3 // 3 //
4 // https://wiki.ubuntu.com/goamz 4 // https://wiki.ubuntu.com/goamz
5 // 5 //
6 // Copyright (c) 2014 Canonical Ltd. 6 // Copyright (c) 2014 Canonical Ltd.
7 // 7 //
8 8
9 package ec2_test 9 package ec2_test
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 c.Assert(err, IsNil) 140 c.Assert(err, IsNil)
141 c.Assert(list.VPCs, HasLen, 1) 141 c.Assert(list.VPCs, HasLen, 1)
142 assertVPC(c, list.VPCs[0], id2, resp2.VPC.CIDRBlock) 142 assertVPC(c, list.VPCs[0], id2, resp2.VPC.CIDRBlock)
143 143
144 _, err = s.ec2.DeleteVPC(id1) 144 _, err = s.ec2.DeleteVPC(id1)
145 c.Assert(err, IsNil) 145 c.Assert(err, IsNil)
146 _, err = s.ec2.DeleteVPC(id2) 146 _, err = s.ec2.DeleteVPC(id2)
147 c.Assert(err, IsNil) 147 c.Assert(err, IsNil)
148 } 148 }
149 149
150 // deleteVPCs ensures the given VPCs are deleted, by retrying until a
151 // timeout or all VPC cannot be found anymore. This should be used to
152 // make sure tests leave no VPCs around.
153 func (s *ServerTests) deleteVPCs(c *C, ids []string) {
154 testAttempt := aws.AttemptStrategy{
155 Total: 2 * time.Minute,
156 Delay: 5 * time.Second,
157 }
158 for a := testAttempt.Start(); a.Next(); {
159 deleted := 0
160 c.Logf("deleting VPCs %v", ids)
161 for _, id := range ids {
162 _, err := s.ec2.DeleteVPC(id)
163 if err == nil || errorCode(err) == "InvalidVpcID.NotFoun d" {
164 c.Logf("VPC %s deleted", id)
165 deleted++
166 continue
167 }
168 if err != nil {
169 c.Logf("retrying; DeleteVPC returned: %v", err)
170 }
171 }
172 if deleted == len(ids) {
173 c.Logf("all VPCs deleted")
174 return
175 }
176 }
177 c.Fatalf("timeout while waiting %v VPCs to get deleted!", ids)
178 }
179
150 func assertVPC(c *C, obtained ec2.VPC, expectId, expectCidr string) { 180 func assertVPC(c *C, obtained ec2.VPC, expectId, expectCidr string) {
151 if expectId != "" { 181 if expectId != "" {
152 c.Check(obtained.Id, Equals, expectId) 182 c.Check(obtained.Id, Equals, expectId)
153 } else { 183 } else {
154 c.Check(obtained.Id, Matches, `^vpc-[0-9a-f]+$`) 184 c.Check(obtained.Id, Matches, `^vpc-[0-9a-f]+$`)
155 } 185 }
156 c.Check(obtained.State, Matches, "(available|pending)") 186 c.Check(obtained.State, Matches, "(available|pending)")
157 if expectCidr != "" { 187 if expectCidr != "" {
158 c.Check(obtained.CIDRBlock, Equals, expectCidr) 188 c.Check(obtained.CIDRBlock, Equals, expectCidr)
159 } else { 189 } else {
160 c.Check(obtained.CIDRBlock, Matches, `^\d+\.\d+\.\d+\.\d+/\d+$`) 190 c.Check(obtained.CIDRBlock, Matches, `^\d+\.\d+\.\d+\.\d+/\d+$`)
161 } 191 }
162 c.Check(obtained.DHCPOptionsId, Matches, `^dopt-[0-9a-f]+$`) 192 c.Check(obtained.DHCPOptionsId, Matches, `^dopt-[0-9a-f]+$`)
163 c.Check(obtained.IsDefault, Equals, false) 193 c.Check(obtained.IsDefault, Equals, false)
164 c.Check(obtained.Tags, HasLen, 0) 194 c.Check(obtained.Tags, HasLen, 0)
165 c.Check(obtained.InstanceTenancy, Matches, "(default|dedicated)") 195 c.Check(obtained.InstanceTenancy, Matches, "(default|dedicated)")
166 } 196 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b