Modifying acceptance tests to support alternative network name
diff --git a/acceptance/openstack/compute/v2/compute_test.go b/acceptance/openstack/compute/v2/compute_test.go
index 33e49fe..c1bbf79 100644
--- a/acceptance/openstack/compute/v2/compute_test.go
+++ b/acceptance/openstack/compute/v2/compute_test.go
@@ -56,6 +56,9 @@
// FlavorIDResize contains the ID of a different flavor available on the same OpenStack installation, that is distinct
// from FlavorID.
FlavorIDResize string
+
+ // NetworkName is the name of a network to launch the instance on.
+ NetworkName string
}
// ComputeChoicesFromEnv populates a ComputeChoices struct from environment variables.
@@ -64,6 +67,7 @@
imageID := os.Getenv("OS_IMAGE_ID")
flavorID := os.Getenv("OS_FLAVOR_ID")
flavorIDResize := os.Getenv("OS_FLAVOR_ID_RESIZE")
+ networkName := os.Getenv("OS_NETWORK_NAME")
missing := make([]string, 0, 3)
if imageID == "" {
@@ -75,6 +79,9 @@
if flavorIDResize == "" {
missing = append(missing, "OS_FLAVOR_ID_RESIZE")
}
+ if networkName == "" {
+ networkName = "public"
+ }
notDistinct := ""
if flavorID == flavorIDResize {
@@ -93,5 +100,5 @@
return nil, fmt.Errorf(text)
}
- return &ComputeChoices{ImageID: imageID, FlavorID: flavorID, FlavorIDResize: flavorIDResize}, nil
+ return &ComputeChoices{ImageID: imageID, FlavorID: flavorID, FlavorIDResize: flavorIDResize, NetworkName: networkName}, nil
}
diff --git a/acceptance/openstack/compute/v2/servers_test.go b/acceptance/openstack/compute/v2/servers_test.go
index d77d34a..7b928e9 100644
--- a/acceptance/openstack/compute/v2/servers_test.go
+++ b/acceptance/openstack/compute/v2/servers_test.go
@@ -57,7 +57,6 @@
}
return openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
- Name: "neutron",
Region: os.Getenv("OS_REGION_NAME"),
})
}
@@ -74,7 +73,10 @@
t.Fatalf("Unable to create a networking client: %v", err)
}
- pager := networks.List(networkingClient, networks.ListOpts{Name: "public", Limit: 1})
+ pager := networks.List(networkingClient, networks.ListOpts{
+ Name: choices.NetworkName,
+ Limit: 1,
+ })
pager.EachPage(func(page pagination.Page) (bool, error) {
networks, err := networks.ExtractNetworks(page)
if err != nil {
@@ -152,7 +154,7 @@
return true, nil
})
- pager = servers.ListAddressesByNetwork(client, server.ID, "public")
+ pager = servers.ListAddressesByNetwork(client, server.ID, choices.NetworkName)
pager.EachPage(func(page pagination.Page) (bool, error) {
addresses, err := servers.ExtractNetworkAddresses(page)
if err != nil {