Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Discovery of Internet Gateways, RouteTables; ec2test improvements #60
Conversation
added some commits
Aug 4, 2015
voidspace
reviewed
Aug 10, 2015
| + defer srv.mu.Unlock() | ||
| + oldZones := srv.zones | ||
| + srv.zones = make(map[string]availabilityZone) | ||
| + for _, z := range zones { |
voidspace
Aug 10, 2015
What this loop does is:
iterate over all the new zones removing all subnets associated with each new zone
Did you mean to iterate over oldZones instead?
(In the end, with the current loop, I believe that the only subnets left will be ones associated with zones from oldZones but not in new zones. I think the effect you're after is exactly the opposite.)
voidspace
reviewed
Aug 10, 2015
| + return fmt.Errorf("internet gateway %q not found", igwId) | ||
| +} | ||
| + | ||
| +type internetGateway struct { |
voidspace
Aug 10, 2015
Why do we create a private type that exactly matches the public type - why not just use the public type?
dimitern
Aug 10, 2015
Member
internetGateway (and similar ec2test types) embed the public type to provide access to it, but the unexported type has extra (internal) methods (e.g. matchAttr called while filtering).
voidspace
reviewed
Aug 10, 2015
| +} | ||
| + | ||
| +func (s *S) TestUpdateInternetGateway(c *C) { | ||
| + // AddDefaultVPCAndSubnets() creates a IGW as well. |
voidspace
Aug 10, 2015
but you're not calling AddDefaultVPCAndSubnets are you? So either the comment is outdated or there is some code missing.
dimitern
Aug 10, 2015
Member
I'll fix the typo. AddDefaultVPCAndSubnets is called in SetUpTest of the S suite.
voidspace
Aug 10, 2015
Oh, I looked for a SetUp but didn't see one. I obviously didn't look hard enough! Thanks.
voidspace
reviewed
Aug 10, 2015
| + }}, | ||
| + PropagatingVGWIds: []string{"foo", "bar"}, | ||
| + } | ||
| + added, err = s.srv.AddRouteTable(toAdd) |
voidspace
reviewed
Aug 10, 2015
| + subnet, err := s.srv.AddSubnet(ec2.Subnet{}) | ||
| + c.Assert(err, ErrorMatches, "empty VPCId field") | ||
| + c.Assert(subnet, DeepEquals, ec2.Subnet{}) | ||
| + s.assertVPCsExist(c, true) |
voidspace
Aug 10, 2015
It's not clear why this assert is called here. If it's a precondition that should be true before AddSubnet and true after, then please add an additional call to assertVPCsExist before calling AddSubnet. If the call to AddSubnet changes something about VPCs, please add a corresponding assert before AddSubnet.
dimitern
Aug 10, 2015
Member
Fair enough, will add a comment and move the assert (which just verifies AddDefaultVPCAndSubnets was called in SetUpTest) before AddSubnet.
voidspace
reviewed
Aug 10, 2015
| + c.Check(igw.Tags, HasLen, 0) | ||
| +} | ||
| + | ||
| +// Internet Gateway tests that run either agsints the local test |
voidspace
commented
Aug 10, 2015
|
Other than a few minor points, LGTM |
bz2
reviewed
Aug 10, 2015
| @@ -404,6 +416,10 @@ func (srv *Server) createIFace(w http.ResponseWriter, req *http.Request, reqId s | ||
| return resp | ||
| } | ||
| +func (srv *Server) dnsNameFromPrivateIP(privateIP string) string { | ||
| + return fmt.Sprintf("ip-%s.ec2.internal", strings.Replace(privateIP, ".", "-", -1)) |
bz2
Aug 10, 2015
Member
Using .internal may actually resolve to something when running tests, whereas .invalid is reserved, see rfc 2606. The tests should not be trying to do dns lookups on these faked names, but I like using .invalid or .test even so.
dimitern
Aug 10, 2015
Member
The only reason for this change was to make both the local-live and live tests pass consistently (AWS does not populate DNSName sometimes).
bz2
reviewed
Aug 10, 2015
| + | ||
| +// InternetGateways describes one or more Internet Gateways (IGWs). | ||
| +// Both parameters are optional, and if specified will limit the | ||
| +// returned IGWs to the matching ids or filterring rules. |
|
LGTM, though without going in detail over all the new test code. As mentioned on irc, have some version compat concern with the ec2test changes but I'm not sure how widely that's used. |
|
Thanks for the reviews! |
dimitern commentedAug 9, 2015
Building on the previous PR, this one improves ec2test server and adds tests for some of its features (more in a follow-up). Added support to pre-configure ec2test servers with:
trueeverything stored in the test server is reset, including counters, but the listener is kept. A value offalsewill add default AZ and security groups after resetting.In the ec2 package, added support for the DescribeInternetGateways and DescribeRouteTables AWS APIs, with more or less complete filtering support except for tags.
Finally, this PR includes a number of fixes around live tests to make them more robust and reliable.
Tested with different combinations of:
go test -check.v -test.timeout=1200m -amazon -race -coverprofile=cover -covermode=atomic