52
|
|
|
Ian Booth |
11 years ago
|
|
|
51
|
|
Goose test infrastructure improvements
This branch improves the usabilty of the goose test infrastructure.
A full Openstack service test double is provided. A bunch of manual coding which was required in each test suite to set up various Openstack module test doubles is replaced by a few lines of code.
New code:
cred := &identity.Credentials{...} openstack := openstack.New(cred) openstack.SetupHTTP(s.Mux)
Old code:
// Create the identity service. s.identityDouble = identityservice.NewUserPass() token := s.identityDouble.AddUser(s.cred.User, s.cred.Secrets) s.Mux.Handle(baseIdentityURL, s.identityDouble)
// Register Swift endpoints with identity service. ep := identityservice.Endpoint{ AdminURL: s.Server.URL + baseSwiftURL, InternalURL: s.Server.URL + baseSwiftURL, PublicURL: s.Server.URL + baseSwiftURL, Region: s.cred.Region, } service := identityservice.Service{"swift", "object-store", []identityservice.Endpoint{ep}} s.identityDouble.AddService(service) s.swiftDouble = swiftservice.New("localhost", baseSwiftURL+"/", token) s.Mux.Handle(baseSwiftURL+"/", s.swiftDouble)
// Register Nova endpoints with identity service. ep = identityservice.Endpoint{ AdminURL: s.Server.URL + baseNovaURL, InternalURL: s.Server.URL + baseNovaURL, PublicURL: s.Server.URL + baseNovaURL, Region: s.cred.Region, } service = identityservice.Service{"nova", "compute", []identityservice.Endpoint{ep}} s.identityDouble.AddService(service) s.novaDouble = novaservice.New("localhost", "V1", token, "1") s.novaDouble.SetupHTTP(s.Mux) Other changes include:
- fix the identity service double to remove the hard coded userId and tenantId. - do not hard code a fixed token against a service double - each user is assigned their own token just like a real instance, allowing multi-user tests to be written. - improvements to the Swift service double to make it use URLs which are compliant with how a real Swift instance would do it. - factor out a common base class for the legacy and userpass double implementations. - use a SetupHTTP() for all test doubles instead of requiring the coder to know the magic URL paths to use.
R=dimitern CC= https://codereview.appspot.com/7194043
|
Ian Booth |
11 years ago
|
|
|
50
|
|
|
Martin Packman |
11 years ago
|
|
|
49
|
|
|
John Arbash Meinel |
11 years ago
|
|
|
48
|
|
Use nova service doubles in nova tests
This branch plugs the nova service doubles into the nova live tests and makes everything work. So now, in the nova package, "go test -gocheck.v" runs the tests against the doubles, and "go test -gocheck.v -live" uses an Openstack instance.
Also, the rate limit retry test is now only run locally against the service doubles, where a special request is used to trigger a rate limit service response. This replaces the previous test which hammered a real Openstack instance to try and induce a rate limit response.
A few things needed to be done, and as a result of implementation changes to the service doubles, changes were also needed for the service double unit tests.
Viewing highlights:
1. Default security group
A real Openstack instance always has a default security group. The nova double and associated unit tests were modified accordingly.
2. Out of the box flavours
The real Openstack instance used for testing has flavours defined out of the box. The live tests assume this behaviour so the test double needed to be modifed to match.
3. Response changes
Some changes were required to certain response data eg creating a security group rule
4. ** This issue will need a follow up change **
The security group rule response contains a SecurityGroupRef struct:
type SecurityGroupRule struct { FromPort *int `json:"from_port"` // Can be nil IPProtocol *string `json:"ip_protocol"` // Can be nil ToPort *int `json:"to_port"` // Can be nil ParentGroupId int `json:"parent_group_id"` IPRange map[string]string `json:"ip_range"` // Can be empty Id int Group SecurityGroupRef }
The was defined as a pointer ie Group *SecurityGroupRef. However, nova double tests which do a DeepEquals to compare security group rules fail because the pointer deferencing isn't done. So to make stuff work, I've used a struct value instead and use the zeroSecurityGroupRef pattern as used on the ec2 side. This isn't desirable and should be looked at. But if we are prepared to go with it for now, it can be fixed in a followup branch. BTW, nothing uses this attribute value so the change should not break juju core.
R=dimitern, jameinel CC= https://codereview.appspot.com/7098074
|
Ian Booth |
11 years ago
|
|
|
47
|
|
|
Martin Packman |
11 years ago
|
|
|
46
|
|
|
Dimiter Naydenov |
11 years ago
|
|
|
45
|
|
|
Dimiter Naydenov |
11 years ago
|
|
|
44
|
|
|
John Arbash Meinel |
11 years ago
|
|
|
43
|
|
|
Dimiter Naydenov |
11 years ago
|
|
|
42
|
|
|
Ian Booth |
11 years ago
|
|
|
41
|
|
|
Ian Booth |
11 years ago
|
|
|
40
|
|
Improved error handling
This branch improves how errors are defined and handled.
The current version introduces changes suggested in code reviews.
An Error interface has been defined for specifying erros with an error code. The code is used to distinguish between types of error eg NotFound vs DuplicateValue. Errors can be nested, and can refer to a root cause error. This allows errors to propogate up the call stack, keeping each error small and self contained, but not discarding important root cause information. At the base level, the context will usually be data pulled from the http repsonse, namely status code and headers, since these are usually sufficient to grok what may have gone wrong. Additional info can be added to the ResponseData struct if required.
The determination of a NotFound error is easy - just look at the http response code and see a 404. DuplicateValue errors are more difficult, since the OpenStack API just returns a 400 with text saying there was a duplicate. The current implementation sucks balls but ti's all we can do ATM AFAIK.
The NotFound and DuplicateValue errors will be used specifically by the juju-core code which calls goose, hence their introduction here. Other error types can be created as required.
R=jameinel, rog, amnonbc, gz CC= https://codereview.appspot.com/6889049
|
Ian Booth |
11 years ago
|
|
|
39
|
|
|
Dimiter Naydenov |
11 years ago
|
|
|
38
|
|
|
Dimiter Naydenov |
11 years ago
|
|
|
37
|
|
|
Dimiter Naydenov |
11 years ago
|
|
|
36
|
|
|
Ian Booth |
11 years ago
|
|
|
35
|
|
|
Ian Booth |
11 years ago
|
|
|
34
|
|
|
Ian Booth |
11 years ago
|
|
|
33
|
|
|
Ian Booth |
11 years ago
|
|
|