Common Compute Acceptance Test Modifications
The following changes were made to the common compute acc test functions:
* Check for Instances in ERROR state to immediately return.
* Making OS_POOL_NAME required.
* Added identity client function.
* Added block storage client function.
* Making "private" the default OS_NETWORK_NAME.
diff --git a/acceptance/openstack/compute/v2/compute_test.go b/acceptance/openstack/compute/v2/compute_test.go
index 83b0e35..b76cfd1 100644
--- a/acceptance/openstack/compute/v2/compute_test.go
+++ b/acceptance/openstack/compute/v2/compute_test.go
@@ -29,6 +29,38 @@
})
}
+func newIdentityClient() (*gophercloud.ServiceClient, error) {
+ ao, err := openstack.AuthOptionsFromEnv()
+ if err != nil {
+ return nil, err
+ }
+
+ client, err := openstack.AuthenticatedClient(ao)
+ if err != nil {
+ return nil, err
+ }
+
+ return openstack.NewIdentityV2(client, gophercloud.EndpointOpts{
+ Region: os.Getenv("OS_REGION_NAME"),
+ })
+}
+
+func newBlockClient() (*gophercloud.ServiceClient, error) {
+ ao, err := openstack.AuthOptionsFromEnv()
+ if err != nil {
+ return nil, err
+ }
+
+ client, err := openstack.AuthenticatedClient(ao)
+ if err != nil {
+ return nil, err
+ }
+
+ return openstack.NewBlockStorageV1(client, gophercloud.EndpointOpts{
+ Region: os.Getenv("OS_REGION_NAME"),
+ })
+}
+
func waitForStatus(client *gophercloud.ServiceClient, server *servers.Server, status string) error {
return tools.WaitFor(func() (bool, error) {
latest, err := servers.Get(client, server.ID).Extract()
@@ -41,6 +73,10 @@
return true, nil
}
+ if latest.Status == "ERROR" {
+ return false, fmt.Errorf("Instance in ERROR state")
+ }
+
return false, nil
})
}
@@ -57,6 +93,9 @@
// from FlavorID.
FlavorIDResize string
+ // FloatingIPPool contains the name of the pool from where to obtain floating IPs.
+ FloatingIPPoolName string
+
// NetworkName is the name of a network to launch the instance on.
NetworkName string
}
@@ -68,6 +107,7 @@
flavorID := os.Getenv("OS_FLAVOR_ID")
flavorIDResize := os.Getenv("OS_FLAVOR_ID_RESIZE")
networkName := os.Getenv("OS_NETWORK_NAME")
+ floatingIPPoolName := os.Getenv("OS_POOL_NAME")
missing := make([]string, 0, 3)
if imageID == "" {
@@ -79,8 +119,11 @@
if flavorIDResize == "" {
missing = append(missing, "OS_FLAVOR_ID_RESIZE")
}
+ if floatingIPPoolName == "" {
+ missing = append(missing, "OS_POOL_NAME")
+ }
if networkName == "" {
- networkName = "public"
+ networkName = "private"
}
notDistinct := ""
@@ -100,5 +143,5 @@
return nil, fmt.Errorf(text)
}
- return &ComputeChoices{ImageID: imageID, FlavorID: flavorID, FlavorIDResize: flavorIDResize, NetworkName: networkName}, nil
+ return &ComputeChoices{ImageID: imageID, FlavorID: flavorID, FlavorIDResize: flavorIDResize, FloatingIPPoolName: floatingIPPoolName, NetworkName: networkName}, nil
}