Skip to content

Commit

Permalink
Add ability to turn-on/off acceptance test for server live-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dstdfx committed Jan 20, 2018
1 parent 4f5656e commit 1d12f0d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions acceptance/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package clients
import (
"fmt"
"os"
"strconv"
"strings"

"github.com/gophercloud/gophercloud"
Expand Down Expand Up @@ -42,6 +43,9 @@ type AcceptanceTestChoices struct {

// DBDatastoreTypeID is the datastore type version for DB tests.
DBDatastoreVersion string

// LiveMigrate indicates ability to run multi-node migration tests
LiveMigrate bool
}

// AcceptanceTestChoicesFromEnv populates a ComputeChoices struct from environment variables.
Expand All @@ -56,6 +60,7 @@ func AcceptanceTestChoicesFromEnv() (*AcceptanceTestChoices, error) {
shareNetworkID := os.Getenv("OS_SHARE_NETWORK_ID")
dbDatastoreType := os.Getenv("OS_DB_DATASTORE_TYPE")
dbDatastoreVersion := os.Getenv("OS_DB_DATASTORE_VERSION")
liveMigrate := os.Getenv("OS_LIVE_MIGRATE")

missing := make([]string, 0, 3)
if imageID == "" {
Expand Down Expand Up @@ -84,6 +89,8 @@ func AcceptanceTestChoicesFromEnv() (*AcceptanceTestChoices, error) {
notDistinct = "OS_FLAVOR_ID and OS_FLAVOR_ID_RESIZE must be distinct."
}

LiveMigrate, _ := strconv.ParseBool(liveMigrate)

if len(missing) > 0 || notDistinct != "" {
text := "You're missing some important setup:\n"
if len(missing) > 0 {
Expand All @@ -106,6 +113,7 @@ func AcceptanceTestChoicesFromEnv() (*AcceptanceTestChoices, error) {
ShareNetworkID: shareNetworkID,
DBDatastoreType: dbDatastoreType,
DBDatastoreVersion: dbDatastoreVersion,
LiveMigrate: LiveMigrate,
}, nil
}

Expand Down
9 changes: 9 additions & 0 deletions acceptance/openstack/compute/v2/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ func TestMigrate(t *testing.T) {
}

func TestLiveMigrate(t *testing.T) {
choices, err := clients.AcceptanceTestChoicesFromEnv()
if err != nil {
t.Fatal(err)
}

if !choices.LiveMigrate {
t.Skip()
}

client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
Expand Down
1 change: 0 additions & 1 deletion openstack/compute/v2/extensions/migrate/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type LiveMigrateOptsBuilder interface {

// LiveMigrateOpts specifies parameters of live migrate action.
type LiveMigrateOpts struct {

// The host to which to migrate the server.
// If this parameter is None, the scheduler chooses a host.
Host *string `json:"host"`
Expand Down

0 comments on commit 1d12f0d

Please sign in to comment.