Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit d2b755f

Browse files
author
Jamie Hannaford
committed
add various fixes
1 parent 05665d6 commit d2b755f

File tree

6 files changed

+27
-46
lines changed

6 files changed

+27
-46
lines changed

acceptance/rackspace/db/v1/config_group_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ package v1
44

55
import (
66
"github.com/rackspace/gophercloud/acceptance/tools"
7+
os "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
78
"github.com/rackspace/gophercloud/pagination"
89
config "github.com/rackspace/gophercloud/rackspace/db/v1/configurations"
910
"github.com/rackspace/gophercloud/rackspace/db/v1/instances"
1011
)
1112

1213
func (c *context) createConfigGrp() {
13-
opts := config.CreateOpts{
14+
opts := os.CreateOpts{
1415
Name: tools.RandomString("config_", 5),
1516
Values: map[string]interface{}{
1617
"connect_timeout": 300,
@@ -33,7 +34,7 @@ func (c *context) getConfigGrp() {
3334
}
3435

3536
func (c *context) updateConfigGrp() {
36-
opts := config.UpdateOpts{
37+
opts := os.UpdateOpts{
3738
Name: tools.RandomString("new_name_", 5),
3839
Values: map[string]interface{}{
3940
"connect_timeout": 250,
@@ -45,9 +46,9 @@ func (c *context) updateConfigGrp() {
4546
}
4647

4748
func (c *context) replaceConfigGrp() {
48-
opts := config.UpdateOpts{
49+
opts := os.UpdateOpts{
4950
Values: map[string]interface{}{
50-
"expire_logs_days": 7,
51+
"big_tables": 1,
5152
},
5253
}
5354

acceptance/rackspace/db/v1/instance_test.go

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package v1
55
import (
66
"testing"
77

8-
"github.com/rackspace/gophercloud"
98
"github.com/rackspace/gophercloud/acceptance/tools"
109
"github.com/rackspace/gophercloud/pagination"
1110
"github.com/rackspace/gophercloud/rackspace/db/v1/instances"
@@ -69,8 +68,12 @@ func TestRunner(t *testing.T) {
6968
// TEARDOWN
7069
c.deleteUsers()
7170
c.deleteDBs()
72-
c.detachAndDeleteReplica()
73-
c.deleteInstance()
71+
72+
c.restartInstance()
73+
c.WaitUntilActive(c.instanceID)
74+
75+
c.deleteInstance(c.replicaID)
76+
c.deleteInstance(c.instanceID)
7477
}
7578

7679
func (c *context) createInstance() {
@@ -114,10 +117,10 @@ func (c *context) getInstance() {
114117
c.Logf("Getting instance: %#v", instance)
115118
}
116119

117-
func (c *context) deleteInstance() {
118-
err := instances.Delete(c.client, c.instanceID).ExtractErr()
120+
func (c *context) deleteInstance(id string) {
121+
err := instances.Delete(c.client, id).ExtractErr()
119122
c.AssertNoErr(err)
120-
c.Logf("Deleted instance %s", c.instanceID)
123+
c.Logf("Deleted instance %s", id)
121124
}
122125

123126
func (c *context) enableRootUser() {
@@ -164,25 +167,3 @@ func (c *context) getDefaultConfig() {
164167
c.Logf("Default config group for instance %s: %#v", c.instanceID, config)
165168
c.AssertNoErr(err)
166169
}
167-
168-
func (c *context) detachAndDeleteReplica() {
169-
err := instances.DetachReplica(c.client, c.replicaID).ExtractErr()
170-
c.AssertNoErr(err)
171-
c.Logf("Detached replica %s from instance %s", c.replicaID, c.instanceID)
172-
173-
err = instances.Delete(c.client, c.replicaID).ExtractErr()
174-
c.AssertNoErr(err)
175-
c.Logf("Deleted replica %s", c.replicaID)
176-
177-
// Check that it's deleted
178-
err = gophercloud.WaitFor(60, func() (bool, error) {
179-
_, err := instances.Get(c.client, c.replicaID).Extract()
180-
if casted, ok := err.(*gophercloud.UnexpectedResponseCodeError); ok && casted.Actual == 404 {
181-
return true, nil
182-
}
183-
if err != nil {
184-
return false, err
185-
}
186-
return false, nil
187-
})
188-
}

openstack/db/v1/configurations/fixtures.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ const singleConfigWithValuesJSON = `
3434
`
3535

3636
var (
37-
listConfigsJSON = fmt.Sprintf(`{"configurations": [%s]}`, singleConfigJSON)
38-
getConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigJSON)
39-
createConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigWithValuesJSON)
37+
ListConfigsJSON = fmt.Sprintf(`{"configurations": [%s]}`, singleConfigJSON)
38+
GetConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigJSON)
39+
CreateConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigWithValuesJSON)
4040
)
4141

42-
var createReq = `
42+
var CreateReq = `
4343
{
4444
"configuration": {
4545
"datastore": {
@@ -56,7 +56,7 @@ var createReq = `
5656
}
5757
`
5858

59-
var updateReq = `
59+
var UpdateReq = `
6060
{
6161
"configuration": {
6262
"values": {
@@ -66,7 +66,7 @@ var updateReq = `
6666
}
6767
`
6868

69-
var listInstancesJSON = `
69+
var ListInstancesJSON = `
7070
{
7171
"instances": [
7272
{
@@ -77,7 +77,7 @@ var listInstancesJSON = `
7777
}
7878
`
7979

80-
var listParamsJSON = `
80+
var ListParamsJSON = `
8181
{
8282
"configuration-parameters": [
8383
{
@@ -112,7 +112,7 @@ var listParamsJSON = `
112112
}
113113
`
114114

115-
var getParamJSON = `
115+
var GetParamJSON = `
116116
{
117117
"max": 1,
118118
"min": 0,
@@ -122,7 +122,7 @@ var getParamJSON = `
122122
}
123123
`
124124

125-
var exampleConfig = Config{
125+
var ExampleConfig = Config{
126126
Created: "2014-07-31T18:56:09",
127127
DatastoreName: "mysql",
128128
DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb",
@@ -133,7 +133,7 @@ var exampleConfig = Config{
133133
Updated: "2014-07-31T18:56:09",
134134
}
135135

136-
var exampleConfigWithValues = Config{
136+
var ExampleConfigWithValues = Config{
137137
Created: "2014-07-31T15:02:52",
138138
DatastoreName: "mysql",
139139
DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb",

openstack/db/v1/databases/requests.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ func Delete(client *gophercloud.ServiceClient, instanceID, dbName string) Delete
108108
var res DeleteResult
109109

110110
_, res.Err = client.Request("DELETE", dbURL(client, instanceID, dbName), gophercloud.RequestOpts{
111-
JSONBody: &res.Body,
112-
OkCodes: []int{202},
111+
OkCodes: []int{202},
113112
})
114113

115114
return res

openstack/db/v1/instances/fixtures.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var (
8989
)
9090

9191
var (
92-
restartReq = `{"restart": true}`
92+
restartReq = `{"restart": {}}`
9393
resizeReq = `{"resize": {"flavorRef": "2"}}`
9494
resizeVolReq = `{"resize": {"volume": {"size": 4}}}`
9595
)

openstack/db/v1/instances/requests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func RestartService(client *gophercloud.ServiceClient, id string) ActionResult {
179179
var res ActionResult
180180

181181
_, res.Err = client.Request("POST", actionURL(client, id), gophercloud.RequestOpts{
182-
JSONBody: map[string]interface{}{"restart": true},
182+
JSONBody: map[string]interface{}{"restart": struct{}{}},
183183
OkCodes: []int{202},
184184
})
185185

0 commit comments

Comments
 (0)