diff --git a/acceptance/openstack/compute/v2/floatingip_test.go b/acceptance/openstack/compute/v2/floatingip_test.go
index 8231bd6..92249c7 100644
--- a/acceptance/openstack/compute/v2/floatingip_test.go
+++ b/acceptance/openstack/compute/v2/floatingip_test.go
@@ -3,97 +3,147 @@
 package v2
 
 import (
-	"os"
 	"testing"
 
 	"github.com/gophercloud/gophercloud"
-	"github.com/gophercloud/gophercloud/acceptance/tools"
-	"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingip"
+	"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips"
 	"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
-	th "github.com/gophercloud/gophercloud/testhelper"
 )
 
-func createFIPServer(t *testing.T, client *gophercloud.ServiceClient, choices *ComputeChoices) (*servers.Server, error) {
+func TestFloatingIPsList(t *testing.T) {
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
+
+	allPages, err := floatingips.List(client).AllPages()
+	if err != nil {
+		t.Fatalf("Unable to retrieve floating IPs: %v", err)
+	}
+
+	allFloatingIPs, err := floatingips.ExtractFloatingIPs(allPages)
+	if err != nil {
+		t.Fatalf("Unable to extract floating IPs: %v", err)
+	}
+
+	for _, floatingIP := range allFloatingIPs {
+		printFloatingIP(t, &floatingIP)
+	}
+}
+
+func TestFloatingIPsCreate(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)
+	}
+
+	floatingIP, err := createFloatingIP(t, client, choices)
+	if err != nil {
+		t.Fatalf("Unable to create floating IP: %v", err)
+	}
+	defer deleteFloatingIP(t, client, floatingIP)
+
+	printFloatingIP(t, floatingIP)
+}
+
+func TestFloatingIPsAssociate(t *testing.T) {
 	if testing.Short() {
 		t.Skip("Skipping test that requires server creation in short mode.")
 	}
 
-	name := tools.RandomString("ACPTTEST", 16)
-	t.Logf("Attempting to create server: %s\n", name)
+	client, err := newClient()
+	if err != nil {
+		t.Fatalf("Unable to create a compute client: %v", err)
+	}
 
-	pwd := tools.MakeNewPassword("")
+	choices, err := ComputeChoicesFromEnv()
+	if err != nil {
+		t.Fatal(err)
+	}
 
-	server, err := servers.Create(client, servers.CreateOpts{
-		Name:      name,
-		FlavorRef: choices.FlavorID,
-		ImageRef:  choices.ImageID,
-		AdminPass: pwd,
-	}).Extract()
+	server, err := createServer(t, client, choices)
 	if err != nil {
 		t.Fatalf("Unable to create server: %v", err)
 	}
 
-	th.AssertEquals(t, pwd, server.AdminPass)
-
-	return server, err
-}
-
-func createFloatingIP(t *testing.T, client *gophercloud.ServiceClient) (*floatingip.FloatingIP, error) {
-	pool := os.Getenv("OS_POOL_NAME")
-	fip, err := floatingip.Create(client, &floatingip.CreateOpts{
-		Pool: pool,
-	}).Extract()
-	th.AssertNoErr(t, err)
-	t.Logf("Obtained Floating IP: %v", fip.IP)
-
-	return fip, err
-}
-
-func associateFloatingIPDeprecated(t *testing.T, client *gophercloud.ServiceClient, serverId string, fip *floatingip.FloatingIP) {
-	// This form works, but is considered deprecated.
-	// See associateFloatingIP or associateFloatingIPFixed
-	err := floatingip.Associate(client, serverId, fip.IP).ExtractErr()
-	th.AssertNoErr(t, err)
-	t.Logf("Associated floating IP %v from instance %v", fip.IP, serverId)
-	defer func() {
-		err = floatingip.Disassociate(client, serverId, fip.IP).ExtractErr()
-		th.AssertNoErr(t, err)
-		t.Logf("Disassociated floating IP %v from instance %v", fip.IP, serverId)
-	}()
-	floatingIp, err := floatingip.Get(client, fip.ID).Extract()
-	th.AssertNoErr(t, err)
-	t.Logf("Floating IP %v is associated with Fixed IP %v", fip.IP, floatingIp.FixedIP)
-}
-
-func associateFloatingIP(t *testing.T, client *gophercloud.ServiceClient, serverId string, fip *floatingip.FloatingIP) {
-	associateOpts := floatingip.AssociateOpts{
-		ServerID:   serverId,
-		FloatingIP: fip.IP,
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatalf("Unable to wait for server: %v", err)
 	}
+	defer deleteServer(t, client, server)
 
-	err := floatingip.AssociateInstance(client, associateOpts).ExtractErr()
-	th.AssertNoErr(t, err)
-	t.Logf("Associated floating IP %v from instance %v", fip.IP, serverId)
-	defer func() {
-		err = floatingip.DisassociateInstance(client, associateOpts).ExtractErr()
-		th.AssertNoErr(t, err)
-		t.Logf("Disassociated floating IP %v from instance %v", fip.IP, serverId)
-	}()
-	floatingIp, err := floatingip.Get(client, fip.ID).Extract()
-	th.AssertNoErr(t, err)
-	t.Logf("Floating IP %v is associated with Fixed IP %v", fip.IP, floatingIp.FixedIP)
-}
-
-func associateFloatingIPFixed(t *testing.T, client *gophercloud.ServiceClient, serverId string, fip *floatingip.FloatingIP) {
-
-	network := os.Getenv("OS_NETWORK_NAME")
-	server, err := servers.Get(client, serverId).Extract()
+	floatingIP, err := createFloatingIP(t, client, choices)
 	if err != nil {
-		t.Fatalf("%s", err)
+		t.Fatalf("Unable to create floating IP: %v", err)
 	}
+	defer deleteFloatingIP(t, client, floatingIP)
+
+	printFloatingIP(t, floatingIP)
+
+	associateOpts := floatingips.AssociateOpts{
+		FloatingIP: floatingIP.IP,
+	}
+
+	t.Logf("Attempting to associate floating IP %s to instance %s", floatingIP.IP, server.ID)
+	err = floatingips.AssociateInstance(client, server.ID, associateOpts).ExtractErr()
+	if err != nil {
+		t.Fatalf("Unable to associate floating IP %s with server %s: %v", floatingIP.IP, server.ID, err)
+	}
+	defer disassociateFloatingIP(t, client, floatingIP, server)
+	t.Logf("Floating IP %s is associated with Fixed IP %s", floatingIP.IP, floatingIP.FixedIP)
+
+	newFloatingIP, err := floatingips.Get(client, floatingIP.ID).Extract()
+	if err != nil {
+		t.Fatalf("Unable to get floating IP %s: %v", floatingIP.ID, err)
+	}
+
+	printFloatingIP(t, newFloatingIP)
+}
+
+func TestFloatingIPsFixedIPAssociate(t *testing.T) {
+	if testing.Short() {
+		t.Skip("Skipping test that requires server creation in short mode.")
+	}
+
+	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.Fatalf("Unable to create server: %v", err)
+	}
+
+	if err = waitForStatus(client, server, "ACTIVE"); err != nil {
+		t.Fatalf("Unable to wait for server: %v", err)
+	}
+	defer deleteServer(t, client, server)
+
+	newServer, err := servers.Get(client, server.ID).Extract()
+	if err != nil {
+		t.Fatalf("Unable to get server %s: %v", server.ID, err)
+	}
+
+	floatingIP, err := createFloatingIP(t, client, choices)
+	if err != nil {
+		t.Fatalf("Unable to create floating IP: %v", err)
+	}
+	defer deleteFloatingIP(t, client, floatingIP)
+
+	printFloatingIP(t, floatingIP)
 
 	var fixedIP string
-	for _, networkAddresses := range server.Addresses[network].([]interface{}) {
+	for _, networkAddresses := range newServer.Addresses[choices.NetworkName].([]interface{}) {
 		address := networkAddresses.(map[string]interface{})
 		if address["OS-EXT-IPS:type"] == "fixed" {
 			if address["version"].(float64) == 4 {
@@ -102,67 +152,66 @@
 		}
 	}
 
-	associateOpts := floatingip.AssociateOpts{
-		ServerID:   serverId,
-		FloatingIP: fip.IP,
+	associateOpts := floatingips.AssociateOpts{
+		FloatingIP: floatingIP.IP,
 		FixedIP:    fixedIP,
 	}
 
-	err = floatingip.AssociateInstance(client, associateOpts).ExtractErr()
-	th.AssertNoErr(t, err)
-	t.Logf("Associated floating IP %v from instance %v with Fixed IP %v", fip.IP, serverId, fixedIP)
-	defer func() {
-		err = floatingip.DisassociateInstance(client, associateOpts).ExtractErr()
-		th.AssertNoErr(t, err)
-		t.Logf("Disassociated floating IP %v from instance %v with Fixed IP %v", fip.IP, serverId, fixedIP)
-	}()
-	floatingIp, err := floatingip.Get(client, fip.ID).Extract()
-	th.AssertNoErr(t, err)
-	th.AssertEquals(t, floatingIp.FixedIP, fixedIP)
-	t.Logf("Floating IP %v is associated with Fixed IP %v", fip.IP, floatingIp.FixedIP)
+	t.Logf("Attempting to associate floating IP %s to instance %s", floatingIP.IP, newServer.ID)
+	err = floatingips.AssociateInstance(client, newServer.ID, associateOpts).ExtractErr()
+	if err != nil {
+		t.Fatalf("Unable to associate floating IP %s with server %s: %v", floatingIP.IP, newServer.ID, err)
+	}
+	defer disassociateFloatingIP(t, client, floatingIP, newServer)
+	t.Logf("Floating IP %s is associated with Fixed IP %s", floatingIP.IP, floatingIP.FixedIP)
+
+	newFloatingIP, err := floatingips.Get(client, floatingIP.ID).Extract()
+	if err != nil {
+		t.Fatalf("Unable to get floating IP %s: %v", floatingIP.ID, err)
+	}
+
+	printFloatingIP(t, newFloatingIP)
 }
 
-func TestFloatingIP(t *testing.T) {
-	pool := os.Getenv("OS_POOL_NAME")
-	if pool == "" {
-		t.Fatalf("OS_POOL_NAME must be set")
+func createFloatingIP(t *testing.T, client *gophercloud.ServiceClient, choices *ComputeChoices) (*floatingips.FloatingIP, error) {
+	createOpts := floatingips.CreateOpts{
+		Pool: choices.FloatingIPPoolName,
 	}
-
-	choices, err := ComputeChoicesFromEnv()
+	floatingIP, err := floatingips.Create(client, createOpts).Extract()
 	if err != nil {
-		t.Fatal(err)
+		return floatingIP, err
 	}
 
-	client, err := newClient()
+	t.Logf("Created floating IP: %s", floatingIP.ID)
+	return floatingIP, nil
+}
+
+func deleteFloatingIP(t *testing.T, client *gophercloud.ServiceClient, floatingIP *floatingips.FloatingIP) {
+	err := floatingips.Delete(client, floatingIP.ID).ExtractErr()
 	if err != nil {
-		t.Fatalf("Unable to create a compute client: %v", err)
+		t.Fatalf("Unable to delete floating IP %s: %v", floatingIP.ID, err)
 	}
 
-	server, err := createFIPServer(t, client, choices)
+	t.Logf("Deleted floating IP: %s", floatingIP.ID)
+}
+
+func disassociateFloatingIP(t *testing.T, client *gophercloud.ServiceClient, floatingIP *floatingips.FloatingIP, server *servers.Server) {
+	disassociateOpts := floatingips.DisassociateOpts{
+		FloatingIP: floatingIP.IP,
+	}
+
+	err := floatingips.DisassociateInstance(client, server.ID, disassociateOpts).ExtractErr()
 	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)
+		t.Fatalf("Unable to disassociate floating IP %s from server %s: %v", floatingIP.IP, server.ID, err)
 	}
 
-	fip, err := createFloatingIP(t, client)
-	if err != nil {
-		t.Fatalf("Unable to create floating IP: %v", err)
-	}
-	defer func() {
-		err = floatingip.Delete(client, fip.ID).ExtractErr()
-		th.AssertNoErr(t, err)
-		t.Logf("Floating IP deleted.")
-	}()
+	t.Logf("Disassociated floating IP %s from server %s", floatingIP.IP, server.ID)
+}
 
-	associateFloatingIPDeprecated(t, client, server.ID, fip)
-	associateFloatingIP(t, client, server.ID, fip)
-	associateFloatingIPFixed(t, client, server.ID, fip)
-
+func printFloatingIP(t *testing.T, floatingIP *floatingips.FloatingIP) {
+	t.Logf("ID: %s", floatingIP.ID)
+	t.Logf("Fixed IP: %s", floatingIP.FixedIP)
+	t.Logf("Instance ID: %s", floatingIP.InstanceID)
+	t.Logf("IP: %s", floatingIP.IP)
+	t.Logf("Pool: %s", floatingIP.Pool)
 }
