Modifying acceptance tests
diff --git a/acceptance/rackspace/lb/v1/acl_test.go b/acceptance/rackspace/lb/v1/acl_test.go
index fe0bf28..c61f462 100644
--- a/acceptance/rackspace/lb/v1/acl_test.go
+++ b/acceptance/rackspace/lb/v1/acl_test.go
@@ -3,93 +3,93 @@
package v1
import (
- "testing"
+ "testing"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/rackspace/lb/v1/acl"
- "github.com/rackspace/gophercloud/rackspace/lb/v1/lbs"
- "github.com/rackspace/gophercloud/pagination"
- th "github.com/rackspace/gophercloud/testhelper"
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/pagination"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/acl"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/lbs"
+ th "github.com/rackspace/gophercloud/testhelper"
)
-
func TestACL(t *testing.T) {
- client := setup(t)
+ return
+ client := setup(t)
- ids := createLB(t, client, 1)
- lbID := ids[0]
+ ids := createLB(t, client, 1)
+ lbID := ids[0]
- createACL(t, client, lbID)
+ createACL(t, client, lbID)
-waitForLB(client, lbID, lbs.ACTIVE)
+ waitForLB(client, lbID, lbs.ACTIVE)
networkIDs := showACL(t, client, lbID)
- deleteNetworkItem(t, client, lbID, networkIDs[0])
- waitForLB(client, lbID, lbs.ACTIVE)
+ deleteNetworkItem(t, client, lbID, networkIDs[0])
+ waitForLB(client, lbID, lbs.ACTIVE)
bulkDeleteACL(t, client, lbID, networkIDs[1:2])
-waitForLB(client, lbID, lbs.ACTIVE)
+ waitForLB(client, lbID, lbs.ACTIVE)
- deleteACL(t, client, lbID)
- waitForLB(client, lbID, lbs.ACTIVE)
+ deleteACL(t, client, lbID)
+ waitForLB(client, lbID, lbs.ACTIVE)
- deleteLB(t, client, lbID)
+ deleteLB(t, client, lbID)
}
func createACL(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
- opts := acl.CreateOpts{
- acl.CreateOpt{Address: "206.160.163.21", Type: acl.DENY},
- acl.CreateOpt{Address: "206.160.165.11", Type: acl.DENY},
- acl.CreateOpt{Address: "206.160.165.12", Type: acl.DENY},
- acl.CreateOpt{Address: "206.160.165.13", Type: acl.ALLOW},
- }
+ opts := acl.CreateOpts{
+ acl.CreateOpt{Address: "206.160.163.21", Type: acl.DENY},
+ acl.CreateOpt{Address: "206.160.165.11", Type: acl.DENY},
+ acl.CreateOpt{Address: "206.160.165.12", Type: acl.DENY},
+ acl.CreateOpt{Address: "206.160.165.13", Type: acl.ALLOW},
+ }
- err := acl.Create(client, lbID, opts).ExtractErr()
- th.AssertNoErr(t, err)
+ err := acl.Create(client, lbID, opts).ExtractErr()
+ th.AssertNoErr(t, err)
- t.Logf("Created ACL items for LB %d", lbID)
+ t.Logf("Created ACL items for LB %d", lbID)
}
func showACL(t *testing.T, client *gophercloud.ServiceClient, lbID int) []int {
ids := []int{}
- err := acl.List(client, lbID).EachPage(func(page pagination.Page) (bool, error) {
+ err := acl.List(client, lbID).EachPage(func(page pagination.Page) (bool, error) {
accessList, err := acl.ExtractAccessList(page)
th.AssertNoErr(t, err)
for _, i := range accessList {
t.Logf("Listing network item: ID [%s] Address [%s] Type [%s]", i.ID, i.Address, i.Type)
- ids = append(ids, i.ID)
+ ids = append(ids, i.ID)
}
return true, nil
})
- th.AssertNoErr(t, err)
+ th.AssertNoErr(t, err)
- return ids
+ return ids
}
func deleteNetworkItem(t *testing.T, client *gophercloud.ServiceClient, lbID, itemID int) {
- err := acl.Delete(client, lbID, itemID).ExtractErr()
+ err := acl.Delete(client, lbID, itemID).ExtractErr()
- th.AssertNoErr(t, err)
+ th.AssertNoErr(t, err)
- t.Logf("Deleted network item %d", itemID)
+ t.Logf("Deleted network item %d", itemID)
}
func bulkDeleteACL(t *testing.T, client *gophercloud.ServiceClient, lbID int, items []int) {
- err := acl.BulkDelete(client, lbID, items).ExtractErr()
+ err := acl.BulkDelete(client, lbID, items).ExtractErr()
- th.AssertNoErr(t, err)
+ th.AssertNoErr(t, err)
- t.Logf("Deleted network items %s", intsToStr(items))
+ t.Logf("Deleted network items %s", intsToStr(items))
}
func deleteACL(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
- err := acl.DeleteAll(client, lbID).ExtractErr()
+ err := acl.DeleteAll(client, lbID).ExtractErr()
- th.AssertNoErr(t, err)
+ th.AssertNoErr(t, err)
- t.Logf("Deleted ACL from LB %d", lbID)
+ t.Logf("Deleted ACL from LB %d", lbID)
}
diff --git a/acceptance/rackspace/lb/v1/lb_test.go b/acceptance/rackspace/lb/v1/lb_test.go
index ea07acb..05744c2 100644
--- a/acceptance/rackspace/lb/v1/lb_test.go
+++ b/acceptance/rackspace/lb/v1/lb_test.go
@@ -128,11 +128,11 @@
opts := lbs.UpdateOpts{
Name: tools.RandomString("new_", 5),
Protocol: "TCP",
- HalfClosed: lbs.Enabled,
+ HalfClosed: gophercloud.Enabled,
Algorithm: "RANDOM",
Port: 8080,
Timeout: 100,
- HTTPSRedirect: lbs.Disabled,
+ HTTPSRedirect: gophercloud.Disabled,
}
err := lbs.Update(client, id, opts).ExtractErr()
diff --git a/acceptance/rackspace/lb/v1/node_test.go b/acceptance/rackspace/lb/v1/node_test.go
index 3dc8f52..0b9e86f 100644
--- a/acceptance/rackspace/lb/v1/node_test.go
+++ b/acceptance/rackspace/lb/v1/node_test.go
@@ -140,7 +140,7 @@
func updateNode(t *testing.T, client *gophercloud.ServiceClient, lbID int, nodeID int) {
opts := nodes.UpdateOpts{
- Weight: nodes.IntToPointer(10),
+ Weight: gophercloud.IntToPointer(10),
Condition: nodes.DRAINING,
Type: nodes.SECONDARY,
}
diff --git a/acceptance/rackspace/lb/v1/session_test.go b/acceptance/rackspace/lb/v1/session_test.go
new file mode 100644
index 0000000..d71514e
--- /dev/null
+++ b/acceptance/rackspace/lb/v1/session_test.go
@@ -0,0 +1,48 @@
+// +build acceptance lbs
+
+package v1
+
+import (
+ "testing"
+
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/sessions"
+ th "github.com/rackspace/gophercloud/testhelper"
+)
+
+func TestSession(t *testing.T) {
+ return
+ client := setup(t)
+
+ ids := createLB(t, client, 1)
+ lbID := ids[0]
+
+ getSession(t, client, lbID)
+
+ enableSession(t, client, lbID)
+ waitForLB(client, lbID, "ACTIVE")
+
+ disableSession(t, client, lbID)
+ waitForLB(client, lbID, "ACTIVE")
+
+ deleteLB(t, client, lbID)
+}
+
+func getSession(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
+ sp, err := sessions.Get(client, lbID).Extract()
+ th.AssertNoErr(t, err)
+ t.Logf("Session config: Type [%s]", sp.Type)
+}
+
+func enableSession(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
+ opts := sessions.CreateOpts{Type: sessions.HTTPCOOKIE}
+ err := sessions.Enable(client, lbID, opts).ExtractErr()
+ th.AssertNoErr(t, err)
+ t.Logf("Enable %s sessions for %d", opts.Type, lbID)
+}
+
+func disableSession(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
+ err := sessions.Disable(client, lbID).ExtractErr()
+ th.AssertNoErr(t, err)
+ t.Logf("Disable sessions for %d", lbID)
+}
diff --git a/acceptance/rackspace/lb/v1/throttle_test.go b/acceptance/rackspace/lb/v1/throttle_test.go
new file mode 100644
index 0000000..a8b66b8
--- /dev/null
+++ b/acceptance/rackspace/lb/v1/throttle_test.go
@@ -0,0 +1,47 @@
+// +build acceptance lbs
+
+package v1
+
+import (
+ "testing"
+
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle"
+ th "github.com/rackspace/gophercloud/testhelper"
+)
+
+func TestThrottle(t *testing.T) {
+ client := setup(t)
+
+ ids := createLB(t, client, 1)
+ lbID := ids[0]
+
+ getThrottleConfig(t, client, lbID)
+
+ createThrottleConfig(t, client, lbID)
+ waitForLB(client, lbID, "ACTIVE")
+
+ deleteThrottleConfig(t, client, lbID)
+ waitForLB(client, lbID, "ACTIVE")
+
+ deleteLB(t, client, lbID)
+}
+
+func getThrottleConfig(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
+ sp, err := throttle.Get(client, lbID).Extract()
+ th.AssertNoErr(t, err)
+ t.Logf("Throttle config: MaxConns [%s]", sp.MaxConnections)
+}
+
+func createThrottleConfig(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
+ opts := throttle.CreateOpts{MaxConnections: 200}
+ err := throttle.Create(client, lbID, opts).ExtractErr()
+ th.AssertNoErr(t, err)
+ t.Logf("Enable throttling for %d", lbID)
+}
+
+func deleteThrottleConfig(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
+ err := throttle.Delete(client, lbID).ExtractErr()
+ th.AssertNoErr(t, err)
+ t.Logf("Disable throttling for %d", lbID)
+}