diff --git a/acceptance/openstack/compute/v2/compute_test.go b/acceptance/openstack/compute/v2/compute_test.go
index 2310858..f5d0a65 100644
--- a/acceptance/openstack/compute/v2/compute_test.go
+++ b/acceptance/openstack/compute/v2/compute_test.go
@@ -1,370 +1,102 @@
 // +build acceptance
 
-package compute
+package v2
 
 import (
 	"fmt"
 	"os"
-	"testing"
+	"strings"
 
+	"github.com/rackspace/gophercloud"
 	"github.com/rackspace/gophercloud/acceptance/tools"
-	"github.com/rackspace/gophercloud/openstack/compute/v2/flavors"
-	"github.com/rackspace/gophercloud/openstack/compute/v2/images"
+	"github.com/rackspace/gophercloud/openstack"
 	"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
+	"github.com/rackspace/gophercloud/openstack/utils"
 )
 
-var service = "compute"
-
-func TestListServers(t *testing.T) {
-	ts, err := tools.SetupForList(service)
+func newClient() (*gophercloud.ServiceClient, error) {
+	ao, err := utils.AuthOptions()
 	if err != nil {
-		t.Error(err)
-		return
+		return nil, err
 	}
 
-	fmt.Fprintln(ts.W, "ID\tRegion\tName\tStatus\tIPv4\tIPv6\t")
+	client, err := openstack.AuthenticatedClient(ao)
+	if err != nil {
+		return nil, err
+	}
 
-	region := os.Getenv("OS_REGION_NAME")
-	n := 0
-	for _, ep := range ts.EPs {
-		if (region != "") && (region != ep.Region) {
-			continue
-		}
+	return openstack.NewComputeV2(client, gophercloud.EndpointOpts{
+		Region: os.Getenv("OS_REGION_NAME"),
+	})
+}
 
-		client := servers.NewClient(ep.PublicURL, ts.A, ts.O)
-
-		listResults, err := servers.List(client)
+func waitForStatus(client *gophercloud.ServiceClient, server *servers.Server, status string) error {
+	return tools.WaitFor(func() (bool, error) {
+		response, err := servers.Get(client, server.ID)
 		if err != nil {
-			t.Error(err)
-			return
+			return false, err
 		}
-
-		svrs, err := servers.GetServers(listResults)
+		latest, err := servers.ExtractServer(response)
 		if err != nil {
-			t.Error(err)
-			return
+			return false, err
 		}
 
-		n = n + len(svrs)
-
-		for _, s := range svrs {
-			fmt.Fprintf(ts.W, "%s\t%s\t%s\t%s\t%s\t%s\t\n", s.Id, s.Name, ep.Region, s.Status, s.AccessIPv4, s.AccessIPv6)
+		if latest.Status == status {
+			// Success!
+			return true, nil
 		}
-	}
-	ts.W.Flush()
-	fmt.Printf("--------\n%d servers listed.\n", n)
+
+		return false, nil
+	})
 }
 
-func TestListImages(t *testing.T) {
-	ts, err := tools.SetupForList(service)
-	if err != nil {
-		t.Error(err)
-		return
-	}
+// ComputeChoices contains image and flavor selections for use by the acceptance tests.
+type ComputeChoices struct {
+	// ImageID contains the ID of a valid image.
+	ImageID string
 
-	fmt.Fprintln(ts.W, "ID\tRegion\tName\tStatus\tCreated\t")
+	// FlavorID contains the ID of a valid flavor.
+	FlavorID string
 
-	region := os.Getenv("OS_REGION_NAME")
-	n := 0
-	for _, ep := range ts.EPs {
-		if (region != "") && (region != ep.Region) {
-			continue
-		}
-
-		client := images.NewClient(ep.PublicURL, ts.A, ts.O)
-
-		listResults, err := images.List(client)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-
-		imgs, err := images.GetImages(listResults)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-
-		n = n + len(imgs)
-
-		for _, i := range imgs {
-			fmt.Fprintf(ts.W, "%s\t%s\t%s\t%s\t%s\t\n", i.Id, ep.Region, i.Name, i.Status, i.Created)
-		}
-	}
-	ts.W.Flush()
-	fmt.Printf("--------\n%d images listed.\n", n)
+	// FlavorIDResize contains the ID of a different flavor available on the same OpenStack installation, that is distinct
+	// from FlavorID.
+	FlavorIDResize string
 }
 
-func TestListFlavors(t *testing.T) {
-	ts, err := tools.SetupForList(service)
-	if err != nil {
-		t.Error(err)
-		return
+// ComputeChoicesFromEnv populates a ComputeChoices struct from environment variables.
+// If any required state is missing, an `error` will be returned that enumerates the missing properties.
+func ComputeChoicesFromEnv() (*ComputeChoices, error) {
+	imageID := os.Getenv("OS_IMAGE_ID")
+	flavorID := os.Getenv("OS_FLAVOR_ID")
+	flavorIDResize := os.Getenv("OS_FLAVOR_ID_RESIZE")
+
+	missing := make([]string, 0, 3)
+	if imageID == "" {
+		missing = append(missing, "OS_IMAGE_ID")
+	}
+	if flavorID == "" {
+		missing = append(missing, "OS_FLAVOR_ID")
+	}
+	if flavorIDResize == "" {
+		missing = append(missing, "OS_FLAVOR_ID_RESIZE")
 	}
 
-	fmt.Fprintln(ts.W, "ID\tRegion\tName\tRAM\tDisk\tVCPUs\t")
+	notDistinct := ""
+	if flavorID == flavorIDResize {
+		notDistinct = "OS_FLAVOR_ID and OS_FLAVOR_ID_RESIZE must be distinct."
+	}
 
-	region := os.Getenv("OS_REGION_NAME")
-	n := 0
-	for _, ep := range ts.EPs {
-		if (region != "") && (region != ep.Region) {
-			continue
+	if len(missing) > 0 || notDistinct != "" {
+		text := "You're missing some important setup:\n"
+		if len(missing) > 0 {
+			text += " * These environment variables must be provided: " + strings.Join(missing, ", ") + "\n"
+		}
+		if notDistinct != "" {
+			text += " * " + notDistinct + "\n"
 		}
 
-		client := flavors.NewClient(ep.PublicURL, ts.A, ts.O)
-
-		listResults, err := flavors.List(client, flavors.ListFilterOptions{})
-		if err != nil {
-			t.Error(err)
-			return
-		}
-
-		flavs, err := flavors.GetFlavors(listResults)
-		if err != nil {
-			t.Error(err)
-			return
-		}
-
-		n = n + len(flavs)
-
-		for _, f := range flavs {
-			fmt.Fprintf(ts.W, "%s\t%s\t%s\t%d\t%d\t%d\t\n", f.Id, ep.Region, f.Name, f.Ram, f.Disk, f.VCpus)
-		}
-	}
-	ts.W.Flush()
-	fmt.Printf("--------\n%d flavors listed.\n", n)
-}
-
-func TestGetFlavor(t *testing.T) {
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Fatal(err)
+		return nil, fmt.Errorf(text)
 	}
 
-	region := os.Getenv("OS_REGION_NAME")
-	for _, ep := range ts.EPs {
-		if (region != "") && (region != ep.Region) {
-			continue
-		}
-		client := flavors.NewClient(ep.PublicURL, ts.A, ts.O)
-
-		getResults, err := flavors.Get(client, ts.FlavorId)
-		if err != nil {
-			t.Fatal(err)
-		}
-		flav, err := flavors.GetFlavor(getResults)
-		if err != nil {
-			t.Fatal(err)
-		}
-		fmt.Printf("%#v\n", flav)
-	}
-}
-
-func TestCreateDestroyServer(t *testing.T) {
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Error(err)
-		return
-	}
-
-	err = tools.CreateServer(ts)
-	if err != nil {
-		t.Error(err)
-		return
-	}
-
-	// We put this in a defer so that it gets executed even in the face of errors or panics.
-	defer func() {
-		servers.Delete(ts.Client, ts.CreatedServer.Id)
-	}()
-
-	err = tools.WaitForStatus(ts, "ACTIVE")
-	if err != nil {
-		t.Error(err)
-	}
-}
-
-func TestUpdateServer(t *testing.T) {
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Error(err)
-		return
-	}
-
-	err = tools.CreateServer(ts)
-	if err != nil {
-		t.Error(err)
-		return
-	}
-
-	defer func() {
-		servers.Delete(ts.Client, ts.CreatedServer.Id)
-	}()
-
-	err = tools.WaitForStatus(ts, "ACTIVE")
-	if err != nil {
-		t.Error(err)
-		return
-	}
-
-	err = tools.ChangeServerName(ts)
-	if err != nil {
-		t.Error(err)
-		return
-	}
-}
-
-func TestActionChangeAdminPassword(t *testing.T) {
-	t.Parallel()
-
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.CreateServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	defer func() {
-		servers.Delete(ts.Client, ts.CreatedServer.Id)
-	}()
-
-	err = tools.WaitForStatus(ts, "ACTIVE")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.ChangeAdminPassword(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestActionReboot(t *testing.T) {
-	t.Parallel()
-
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.CreateServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	defer func() {
-		servers.Delete(ts.Client, ts.CreatedServer.Id)
-	}()
-
-	err = tools.WaitForStatus(ts, "ACTIVE")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = servers.Reboot(ts.Client, ts.CreatedServer.Id, "aldhjflaskhjf")
-	if err == nil {
-		t.Fatal("Expected the SDK to provide an ArgumentError here")
-	}
-
-	err = tools.RebootServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestActionRebuild(t *testing.T) {
-	t.Parallel()
-
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.CreateServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	defer func() {
-		servers.Delete(ts.Client, ts.CreatedServer.Id)
-	}()
-
-	err = tools.WaitForStatus(ts, "ACTIVE")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.RebuildServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestActionResizeConfirm(t *testing.T) {
-	t.Parallel()
-
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.CreateServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	defer func() {
-		servers.Delete(ts.Client, ts.CreatedServer.Id)
-	}()
-
-	err = tools.WaitForStatus(ts, "ACTIVE")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.ResizeServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.ConfirmResize(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestActionResizeRevert(t *testing.T) {
-	t.Parallel()
-
-	ts, err := tools.SetupForCRUD()
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.CreateServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	defer func() {
-		servers.Delete(ts.Client, ts.CreatedServer.Id)
-	}()
-
-	err = tools.WaitForStatus(ts, "ACTIVE")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.ResizeServer(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = tools.RevertResize(ts)
-	if err != nil {
-		t.Fatal(err)
-	}
+	return &ComputeChoices{ImageID: imageID, FlavorID: flavorID, FlavorIDResize: flavorIDResize}, nil
 }
diff --git a/acceptance/openstack/compute/v2/flavors_test.go b/acceptance/openstack/compute/v2/flavors_test.go
new file mode 100644
index 0000000..f69be6b
--- /dev/null
+++ b/acceptance/openstack/compute/v2/flavors_test.go
@@ -0,0 +1,61 @@
+// +build acceptance
+
+package v2
+
+import (
+	"testing"
+
+	"github.com/rackspace/gophercloud/openstack/compute/v2/flavors"
+	"github.com/rackspace/gophercloud/pagination"
+)
+
+func TestListFlavors(t *testing.T) {
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	t.Logf("ID\tRegion\tName\tStatus\tCreated")
+
+	pager := flavors.List(client, flavors.ListFilterOptions{})
+	count, pages := 0, 0
+	pager.EachPage(func(page pagination.Page) (bool, error) {
+		t.Logf("---")
+		pages++
+		flavors, err := flavors.ExtractFlavors(page)
+		if err != nil {
+			return false, err
+		}
+
+		for _, f := range flavors {
+			t.Logf("%s\t%s\t%d\t%d\t%d", f.ID, f.Name, f.RAM, f.Disk, f.VCPUs)
+		}
+
+		return true, nil
+	})
+
+	t.Logf("--------\n%d flavors listed on %d pages.", count, pages)
+}
+
+func TestGetFlavor(t *testing.T) {
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	result, err := flavors.Get(client, choices.FlavorID)
+	if err != nil {
+		t.Fatalf("Unable to get flavor information: %v", err)
+	}
+	flavor, err := flavors.ExtractFlavor(result)
+	if err != nil {
+		t.Fatalf("Unable to extract flavor from GET result: %v", err)
+	}
+
+	t.Logf("Flavor: %#v", flavor)
+}
diff --git a/acceptance/openstack/compute/v2/images_test.go b/acceptance/openstack/compute/v2/images_test.go
new file mode 100644
index 0000000..7fca3ec
--- /dev/null
+++ b/acceptance/openstack/compute/v2/images_test.go
@@ -0,0 +1,37 @@
+// +build acceptance
+
+package v2
+
+import (
+	"testing"
+
+	"github.com/rackspace/gophercloud/openstack/compute/v2/images"
+	"github.com/rackspace/gophercloud/pagination"
+)
+
+func TestListImages(t *testing.T) {
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute: client: %v", err)
+	}
+
+	t.Logf("ID\tRegion\tName\tStatus\tCreated")
+
+	pager := images.List(client)
+	count, pages := 0, 0
+	pager.EachPage(func(page pagination.Page) (bool, error) {
+		pages++
+		images, err := images.ExtractImages(page)
+		if err != nil {
+			return false, err
+		}
+
+		for _, i := range images {
+			t.Logf("%s\t%s\t%s\t%s", i.ID, i.Name, i.Status, i.Created)
+		}
+
+		return true, nil
+	})
+
+	t.Logf("--------\n%d images listed on %d pages.", count, pages)
+}
diff --git a/acceptance/openstack/compute/v2/pkg.go b/acceptance/openstack/compute/v2/pkg.go
index a887fe9..bb158c3 100644
--- a/acceptance/openstack/compute/v2/pkg.go
+++ b/acceptance/openstack/compute/v2/pkg.go
@@ -1 +1,3 @@
-package compute
+// The v2 package contains acceptance tests for the Openstack Compute V2 service.
+
+package v2
diff --git a/acceptance/openstack/compute/v2/servers_test.go b/acceptance/openstack/compute/v2/servers_test.go
new file mode 100644
index 0000000..f5e800f
--- /dev/null
+++ b/acceptance/openstack/compute/v2/servers_test.go
@@ -0,0 +1,358 @@
+// +build acceptance
+
+package v2
+
+import (
+	"fmt"
+	"testing"
+
+	"github.com/rackspace/gophercloud"
+	"github.com/rackspace/gophercloud/acceptance/tools"
+	"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
+	"github.com/rackspace/gophercloud/pagination"
+)
+
+func TestListServers(t *testing.T) {
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	t.Logf("ID\tRegion\tName\tStatus\tIPv4\tIPv6")
+
+	pager := servers.List(client)
+	count, pages := 0, 0
+	pager.EachPage(func(page pagination.Page) (bool, error) {
+		pages++
+		t.Logf("---")
+
+		servers, err := servers.ExtractServers(page)
+		if err != nil {
+			return false, err
+		}
+
+		for _, s := range servers {
+			t.Logf("%s\t%s\t%s\t%s\t%s\t\n", s.ID, s.Name, s.Status, s.AccessIPv4, s.AccessIPv6)
+			count++
+		}
+
+		return true, nil
+	})
+
+	fmt.Printf("--------\n%d servers listed on %d pages.\n", count, pages)
+}
+
+func createServer(t *testing.T, client *gophercloud.ServiceClient, choices *ComputeChoices) (*servers.Server, error) {
+	name := tools.RandomString("ACPTTEST", 16)
+	t.Logf("Attempting to create server: %s\n", name)
+
+	server, err := servers.Create(client, map[string]interface{}{
+		"flavorRef": choices.FlavorID,
+		"imageRef":  choices.ImageID,
+		"name":      name,
+	})
+	if err != nil {
+		t.Fatalf("Unable to create server: %v", err)
+	}
+
+	return servers.ExtractServer(server)
+}
+
+func TestCreateDestroyServer(t *testing.T) {
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	name := tools.RandomString("ACPTTEST", 16)
+	t.Logf("Attempting to create server: %s\n", name)
+
+	server, err := createServer(t, client, choices)
+	if err != nil {
+		t.Fatalf("Unable to create server: %v", err)
+	}
+	defer func() {
+		servers.Delete(client, server.ID)
+		t.Logf("Server deleted.")
+	}()
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatalf("Unable to wait for server: %v", err)
+	}
+}
+
+func TestUpdateServer(t *testing.T) {
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	server, err := createServer(t, client, choices)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer servers.Delete(client, server.ID)
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+
+	alternateName := tools.RandomString("ACPTTEST", 16)
+	for alternateName == server.Name {
+		alternateName = tools.RandomString("ACPTTEST", 16)
+	}
+
+	t.Logf("Attempting to rename the server to %s.", alternateName)
+
+	result, err := servers.Update(client, server.ID, map[string]interface{}{
+		"name": alternateName,
+	})
+	if err != nil {
+		t.Fatalf("Unable to rename server: %v", err)
+	}
+	updated, err := servers.ExtractServer(result)
+	if err != nil {
+		t.Fatalf("Unable to extract server: %v", err)
+	}
+
+	if updated.ID != server.ID {
+		t.Errorf("Updated server ID [%s] didn't match original server ID [%s]!", updated.ID, server.ID)
+	}
+
+	err = tools.WaitFor(func() (bool, error) {
+		result, err := servers.Get(client, updated.ID)
+		if err != nil {
+			return false, err
+		}
+		latest, err := servers.ExtractServer(result)
+		if err != nil {
+			return false, err
+		}
+
+		return latest.Name == alternateName, nil
+	})
+}
+
+func TestActionChangeAdminPassword(t *testing.T) {
+	t.Parallel()
+
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	server, err := createServer(t, client, choices)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer servers.Delete(client, server.ID)
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+
+	randomPassword := tools.MakeNewPassword(server.AdminPass)
+	err = servers.ChangeAdminPassword(client, server.ID, randomPassword)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "PASSWORD"); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestActionReboot(t *testing.T) {
+	t.Parallel()
+
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	server, err := createServer(t, client, choices)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer servers.Delete(client, server.ID)
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+
+	err = servers.Reboot(client, server.ID, "aldhjflaskhjf")
+	if err == nil {
+		t.Fatal("Expected the SDK to provide an ArgumentError here")
+	}
+
+	t.Logf("Attempting reboot of server %s", server.ID)
+	err = servers.Reboot(client, server.ID, servers.OSReboot)
+	if err != nil {
+		t.Fatalf("Unable to reboot server: %v", err)
+	}
+
+	if err = waitForStatus(client, server, "REBOOT"); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestActionRebuild(t *testing.T) {
+	t.Parallel()
+
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	server, err := createServer(t, client, choices)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer servers.Delete(client, server.ID)
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+
+	t.Logf("Attempting to rebuild server %s", server.ID)
+
+	newPassword := tools.MakeNewPassword(server.AdminPass)
+	newName := tools.RandomString("ACPTTEST", 16)
+	result, err := servers.Rebuild(client, server.ID, newName, newPassword, choices.ImageID, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	rebuilt, err := servers.ExtractServer(result)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if rebuilt.ID != server.ID {
+		t.Errorf("Expected rebuilt server ID of [%s]; got [%s]", server.ID, rebuilt.ID)
+	}
+
+	if err = waitForStatus(client, rebuilt, "REBUILD"); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, rebuilt, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func resizeServer(t *testing.T, client *gophercloud.ServiceClient) *servers.Server {
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	server, err := createServer(t, client, choices)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+
+	t.Logf("Attempting to resize server [%s]", server.ID)
+
+	if err = servers.Resize(client, server.ID, choices.FlavorIDResize); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "RESIZE"); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "VERIFY_RESIZE"); err != nil {
+		t.Fatal(err)
+	}
+
+	return server
+}
+
+func TestActionResizeConfirm(t *testing.T) {
+	t.Parallel()
+
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	server := resizeServer(t, client)
+	defer servers.Delete(client, server.ID)
+
+	t.Logf("Attempting to confirm resize for server %s", server.ID)
+
+	if err = servers.ConfirmResize(client, server.ID); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+}
+
+func TestActionResizeRevert(t *testing.T) {
+	t.Parallel()
+
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	server := resizeServer(t, client)
+	defer servers.Delete(client, server.ID)
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+
+	t.Logf("Attempting to revert resize for server %s", server.ID)
+
+	if err := servers.RevertResize(client, server.ID); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "REVERT_RESIZE"); err != nil {
+		t.Fatal(err)
+	}
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatal(err)
+	}
+}
diff --git a/acceptance/openstack/compute/v2/tools_test.go b/acceptance/openstack/compute/v2/tools_test.go
deleted file mode 100644
index 1acb824..0000000
--- a/acceptance/openstack/compute/v2/tools_test.go
+++ /dev/null
@@ -1,367 +0,0 @@
-// +build acceptance
-
-package compute
-
-import (
-	"crypto/rand"
-	"fmt"
-	"os"
-	"text/tabwriter"
-	"time"
-
-	"github.com/rackspace/gophercloud"
-	"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
-	identity "github.com/rackspace/gophercloud/openstack/identity/v2"
-	"github.com/rackspace/gophercloud/openstack/utils"
-)
-
-var errTimeout = fmt.Errorf("Timeout.")
-
-type testState struct {
-	o              gophercloud.AuthOptions
-	a              identity.AuthResults
-	sc             *identity.ServiceCatalog
-	eps            []identity.Endpoint
-	w              *tabwriter.Writer
-	imageId        string
-	flavorId       string
-	region         string
-	ep             string
-	client         *servers.Client
-	createdServer  *servers.Server
-	gottenServer   *servers.Server
-	updatedServer  *servers.Server
-	serverName     string
-	alternateName  string
-	flavorIdResize string
-}
-
-func SetupForList(service string) (*testState, error) {
-	var err error
-
-	ts := new(testState)
-
-	ts.o, err = utils.AuthOptions()
-	if err != nil {
-		return ts, err
-	}
-
-	client := &gophercloud.ServiceClient{Endpoint: ts.o.IdentityEndpoint}
-	ts.a, err = identity.Authenticate(client, ts.o)
-	if err != nil {
-		return ts, err
-	}
-
-	ts.sc, err = identity.GetServiceCatalog(ts.a)
-	if err != nil {
-		return ts, err
-	}
-
-	ts.eps, err = FindAllEndpoints(ts.sc, service)
-	if err != nil {
-		return ts, err
-	}
-
-	ts.w = new(tabwriter.Writer)
-	ts.w.Init(os.Stdout, 2, 8, 2, ' ', 0)
-
-	return ts, nil
-}
-
-func SetupForCRUD() (*testState, error) {
-	ts, err := SetupForList("compute")
-	if err != nil {
-		return ts, err
-	}
-
-	ts.imageId = os.Getenv("OS_IMAGE_ID")
-	if ts.imageId == "" {
-		return ts, fmt.Errorf("Expected OS_IMAGE_ID environment variable to be set")
-	}
-
-	ts.flavorId = os.Getenv("OS_FLAVOR_ID")
-	if ts.flavorId == "" {
-		return ts, fmt.Errorf("Expected OS_FLAVOR_ID environment variable to be set")
-	}
-
-	ts.flavorIdResize = os.Getenv("OS_FLAVOR_ID_RESIZE")
-	if ts.flavorIdResize == "" {
-		return ts, fmt.Errorf("Expected OS_FLAVOR_ID_RESIZE environment variable to be set")
-	}
-
-	if ts.flavorIdResize == ts.flavorId {
-		return ts, fmt.Errorf("OS_FLAVOR_ID and OS_FLAVOR_ID_RESIZE cannot be the same")
-	}
-
-	ts.region = os.Getenv("OS_REGION_NAME")
-	if ts.region == "" {
-		ts.region = ts.eps[0].Region
-	}
-
-	ts.ep, err = FindEndpointForRegion(ts.eps, ts.region)
-	if err != nil {
-		return ts, err
-	}
-
-	return ts, err
-}
-
-func FindAllEndpoints(sc *identity.ServiceCatalog, service string) ([]identity.Endpoint, error) {
-	ces, err := sc.CatalogEntries()
-	if err != nil {
-		return nil, err
-	}
-
-	for _, ce := range ces {
-		if ce.Type == service {
-			return ce.Endpoints, nil
-		}
-	}
-
-	return nil, fmt.Errorf(service + " endpoint not found.")
-}
-
-func FindEndpointForRegion(eps []identity.Endpoint, r string) (string, error) {
-	for _, ep := range eps {
-		if ep.Region == r {
-			return ep.PublicURL, nil
-		}
-	}
-	return "", fmt.Errorf("Unknown region %s", r)
-}
-
-func CountDown(ts *testState, timeout int) (bool, int, error) {
-	if timeout < 1 {
-		return false, 0, errTimeout
-	}
-	time.Sleep(1 * time.Second)
-	timeout--
-
-	gr, err := servers.GetDetail(ts.client, ts.createdServer.Id)
-	if err != nil {
-		return false, timeout, err
-	}
-
-	ts.gottenServer, err = servers.GetServer(gr)
-	if err != nil {
-		return false, timeout, err
-	}
-
-	return true, timeout, nil
-}
-
-func CreateServer(ts *testState) error {
-	ts.serverName = RandomString("ACPTTEST", 16)
-	fmt.Printf("Attempting to create server: %s\n", ts.serverName)
-
-	ts.client = servers.NewClient(ts.ep, ts.a, ts.o)
-
-	cr, err := servers.Create(ts.client, map[string]interface{}{
-		"flavorRef": ts.flavorId,
-		"imageRef":  ts.imageId,
-		"name":      ts.serverName,
-	})
-	if err != nil {
-		return err
-	}
-
-	ts.createdServer, err = servers.GetServer(cr)
-	return err
-}
-
-func WaitForStatus(ts *testState, s string) error {
-	var (
-		inProgress bool
-		timeout    int
-		err        error
-	)
-
-	for inProgress, timeout, err = CountDown(ts, 300); inProgress; inProgress, timeout, err = CountDown(ts, timeout) {
-		if ts.gottenServer.Id != ts.createdServer.Id {
-			return fmt.Errorf("created server id (%s) != gotten server id (%s)", ts.createdServer.Id, ts.gottenServer.Id)
-		}
-
-		if ts.gottenServer.Status == s {
-			fmt.Printf("Server reached state %s after %d seconds (approximately)\n", s, 300-timeout)
-			break
-		}
-	}
-
-	if err == errTimeout {
-		fmt.Printf("Time out -- I'm not waiting around.\n")
-		err = nil
-	}
-
-	return err
-}
-
-func ChangeServerName(ts *testState) error {
-	var (
-		inProgress bool
-		timeout    int
-	)
-
-	ts.alternateName = RandomString("ACPTTEST", 16)
-	for ts.alternateName == ts.serverName {
-		ts.alternateName = RandomString("ACPTTEST", 16)
-	}
-	fmt.Println("Attempting to change server name")
-
-	ur, err := servers.Update(ts.client, ts.createdServer.Id, map[string]interface{}{
-		"name": ts.alternateName,
-	})
-	if err != nil {
-		return err
-	}
-
-	ts.updatedServer, err = servers.GetServer(ur)
-	if err != nil {
-		return err
-	}
-
-	if ts.updatedServer.Id != ts.createdServer.Id {
-		return fmt.Errorf("Expected updated and created server to share the same ID")
-	}
-
-	for inProgress, timeout, err = CountDown(ts, 300); inProgress; inProgress, timeout, err = CountDown(ts, timeout) {
-		if ts.gottenServer.Id != ts.updatedServer.Id {
-			return fmt.Errorf("Updated server ID (%s) != gotten server ID (%s)", ts.updatedServer.Id, ts.gottenServer.Id)
-		}
-
-		if ts.gottenServer.Name == ts.alternateName {
-			fmt.Printf("Server updated after %d seconds (approximately)\n", 300-timeout)
-			break
-		}
-	}
-
-	if err == errTimeout {
-		fmt.Printf("I'm not waiting around.\n")
-		err = nil
-	}
-
-	return err
-}
-
-func MakeNewPassword(oldPass string) string {
-	fmt.Println("Current password: " + oldPass)
-	randomPassword := RandomString("", 16)
-	for randomPassword == oldPass {
-		randomPassword = RandomString("", 16)
-	}
-	fmt.Println("    New password: " + randomPassword)
-	return randomPassword
-}
-
-func ChangeAdminPassword(ts *testState) error {
-	randomPassword := MakeNewPassword(ts.createdServer.AdminPass)
-
-	err := servers.ChangeAdminPassword(ts.client, ts.createdServer.Id, randomPassword)
-	if err != nil {
-		return err
-	}
-
-	err = WaitForStatus(ts, "PASSWORD")
-	if err != nil {
-		return err
-	}
-
-	return WaitForStatus(ts, "ACTIVE")
-}
-
-func RebootServer(ts *testState) error {
-	fmt.Println("Attempting reboot of server " + ts.createdServer.Id)
-	err := servers.Reboot(ts.client, ts.createdServer.Id, servers.OSReboot)
-	if err != nil {
-		return err
-	}
-
-	err = WaitForStatus(ts, "REBOOT")
-	if err != nil {
-		return err
-	}
-
-	return WaitForStatus(ts, "ACTIVE")
-}
-
-func RebuildServer(ts *testState) error {
-	fmt.Println("Attempting to rebuild server " + ts.createdServer.Id)
-
-	newPassword := MakeNewPassword(ts.createdServer.AdminPass)
-	newName := RandomString("ACPTTEST", 16)
-	sr, err := servers.Rebuild(ts.client, ts.createdServer.Id, newName, newPassword, ts.imageId, nil)
-	if err != nil {
-		return err
-	}
-
-	s, err := servers.GetServer(sr)
-	if err != nil {
-		return err
-	}
-	if s.Id != ts.createdServer.Id {
-		return fmt.Errorf("Expected rebuilt server ID of %s; got %s", ts.createdServer.Id, s.Id)
-	}
-
-	err = WaitForStatus(ts, "REBUILD")
-	if err != nil {
-		return err
-	}
-
-	return WaitForStatus(ts, "ACTIVE")
-}
-
-func ResizeServer(ts *testState) error {
-	fmt.Println("Attempting to resize server " + ts.createdServer.Id)
-
-	err := servers.Resize(ts.client, ts.createdServer.Id, ts.flavorIdResize)
-	if err != nil {
-		return err
-	}
-
-	err = WaitForStatus(ts, "RESIZE")
-	if err != nil {
-		return err
-	}
-
-	return WaitForStatus(ts, "VERIFY_RESIZE")
-}
-
-func ConfirmResize(ts *testState) error {
-	fmt.Println("Attempting to confirm resize for server " + ts.createdServer.Id)
-
-	err := servers.ConfirmResize(ts.client, ts.createdServer.Id)
-	if err != nil {
-		return err
-	}
-
-	return WaitForStatus(ts, "ACTIVE")
-}
-
-func RevertResize(ts *testState) error {
-	fmt.Println("Attempting to revert resize for server " + ts.createdServer.Id)
-
-	err := servers.RevertResize(ts.client, ts.createdServer.Id)
-	if err != nil {
-		return err
-	}
-
-	err = WaitForStatus(ts, "REVERT_RESIZE")
-	if err != nil {
-		return err
-	}
-
-	return WaitForStatus(ts, "ACTIVE")
-}
-
-// randomString generates a string of given length, but random content.
-// All content will be within the ASCII graphic character set.
-// (Implementation from Even Shaw's contribution on
-// http://stackoverflow.com/questions/12771930/what-is-the-fastest-way-to-generate-a-long-random-string-in-go).
-func RandomString(prefix string, n int) string {
-	const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
-	var bytes = make([]byte, n)
-	rand.Read(bytes)
-	for i, b := range bytes {
-		bytes[i] = alphanum[b%byte(len(alphanum))]
-	}
-	return prefix + string(bytes)
-}
