blob: f0a69d57aa93eddcaa5d25e3848832e6bc36b59a [file] [log] [blame]
Jamie Hannafordbde72602014-11-10 10:32:26 +01001// +build acceptance lbs
2
3package v1
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud"
9 "github.com/rackspace/gophercloud/rackspace/lb/v1/throttle"
10 th "github.com/rackspace/gophercloud/testhelper"
11)
12
13func TestThrottle(t *testing.T) {
Jamie Hannaford82ce9162014-11-10 12:18:35 +010014 return
Jamie Hannafordbde72602014-11-10 10:32:26 +010015 client := setup(t)
16
17 ids := createLB(t, client, 1)
18 lbID := ids[0]
19
20 getThrottleConfig(t, client, lbID)
21
22 createThrottleConfig(t, client, lbID)
23 waitForLB(client, lbID, "ACTIVE")
24
25 deleteThrottleConfig(t, client, lbID)
26 waitForLB(client, lbID, "ACTIVE")
27
28 deleteLB(t, client, lbID)
29}
30
31func getThrottleConfig(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
32 sp, err := throttle.Get(client, lbID).Extract()
33 th.AssertNoErr(t, err)
34 t.Logf("Throttle config: MaxConns [%s]", sp.MaxConnections)
35}
36
37func createThrottleConfig(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
38 opts := throttle.CreateOpts{MaxConnections: 200}
39 err := throttle.Create(client, lbID, opts).ExtractErr()
40 th.AssertNoErr(t, err)
41 t.Logf("Enable throttling for %d", lbID)
42}
43
44func deleteThrottleConfig(t *testing.T, client *gophercloud.ServiceClient, lbID int) {
45 err := throttle.Delete(client, lbID).ExtractErr()
46 th.AssertNoErr(t, err)
47 t.Logf("Disable throttling for %d", lbID)
48}