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