Finalizing most acceptance tests
diff --git a/acceptance/openstack/db/v1/common.go b/acceptance/openstack/db/v1/common.go
index 13d7628..2665ce4 100644
--- a/acceptance/openstack/db/v1/common.go
+++ b/acceptance/openstack/db/v1/common.go
@@ -8,6 +8,7 @@
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
+ "github.com/rackspace/gophercloud/openstack/db/v1/instances"
th "github.com/rackspace/gophercloud/testhelper"
)
@@ -31,6 +32,7 @@
client *gophercloud.ServiceClient
instanceID string
DBIDs []string
+ users []string
}
func newContext(t *testing.T) context {
@@ -59,4 +61,6 @@
}
return false, nil
})
+
+ c.AssertNoErr(err)
}
diff --git a/acceptance/openstack/db/v1/database_test.go b/acceptance/openstack/db/v1/database_test.go
index e2d41cf..cecd9c9 100644
--- a/acceptance/openstack/db/v1/database_test.go
+++ b/acceptance/openstack/db/v1/database_test.go
@@ -10,9 +10,9 @@
func (c context) createDBs() {
dbs := []string{
- tools.RandomString("db_"),
- tools.RandomString("db_"),
- tools.RandomString("db_"),
+ tools.RandomString("db_", 5),
+ tools.RandomString("db_", 5),
+ tools.RandomString("db_", 5),
}
opts := db.BatchCreateOpts{
@@ -21,7 +21,8 @@
db.CreateOpts{Name: dbs[2]},
}
- res := db.Create(c.client, c.instanceID, opts)
+ err := db.Create(c.client, c.instanceID, opts).ExtractErr()
+ c.AssertNoErr(err)
c.Logf("Created three databases on instance %s: %s, %s, %s", c.instanceID, dbs[0], dbs[1], dbs[2])
c.DBIDs = dbs
}
@@ -29,7 +30,7 @@
func (c context) listDBs() {
c.Logf("Listing databases on instance %s", c.instanceID)
- err := dbs.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
+ err := db.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
dbList, err := db.ExtractDBs(page)
c.AssertNoErr(err)
@@ -40,13 +41,13 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) deleteDBs() {
for _, id := range c.DBIDs {
err := db.Delete(c.client, c.instanceID, id).ExtractErr()
- c.CheckNoErr(err)
- t.Logf("Deleted DB %s", id)
+ c.AssertNoErr(err)
+ c.Logf("Deleted DB %s", id)
}
}
diff --git a/acceptance/openstack/db/v1/flavor_test.go b/acceptance/openstack/db/v1/flavor_test.go
index 98fc41e..4d6568d 100644
--- a/acceptance/openstack/db/v1/flavor_test.go
+++ b/acceptance/openstack/db/v1/flavor_test.go
@@ -10,8 +10,8 @@
func (c context) listFlavors() {
c.Logf("Listing flavors")
- err := flavors.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
- flavorList, err := db.ExtractFlavors(page)
+ err := flavors.List(c.client).EachPage(func(page pagination.Page) (bool, error) {
+ flavorList, err := flavors.ExtractFlavors(page)
c.AssertNoErr(err)
for _, f := range flavorList {
@@ -21,11 +21,11 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) getFlavor() {
- flavor, err := flavors.Get(c.client, "1").Extract()
+ flavor, err := flavors.Get(c.client, 1).Extract()
c.Logf("Getting flavor %s", flavor.ID)
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
diff --git a/acceptance/openstack/db/v1/instance_test.go b/acceptance/openstack/db/v1/instance_test.go
index 24678cb..1961f1f 100644
--- a/acceptance/openstack/db/v1/instance_test.go
+++ b/acceptance/openstack/db/v1/instance_test.go
@@ -3,13 +3,16 @@
package v1
import (
+ "testing"
+
"github.com/rackspace/gophercloud/acceptance/tools"
"github.com/rackspace/gophercloud/openstack/db/v1/instances"
"github.com/rackspace/gophercloud/pagination"
+ rackspaceInst "github.com/rackspace/gophercloud/rackspace/db/v1/instances"
th "github.com/rackspace/gophercloud/testhelper"
)
-func TestRunner(t *testingT) {
+func TestRunner(t *testing.T) {
c := newContext(t)
// FLAVOR tests
@@ -28,7 +31,7 @@
c.resizeVol()
// DATABASE tests
- c.createDB()
+ c.createDBs()
c.listDBs()
// USER tests
@@ -38,21 +41,22 @@
// TEARDOWN
c.deleteUsers()
c.deleteDBs()
- c.deleteInstance(id)
+ c.deleteInstance()
}
func (c context) createInstance() {
- opts := instances.CreateOpts{
+ opts := rackspaceInst.CreateOpts{
FlavorRef: "1",
Size: 1,
Name: tools.RandomString("gopher_db", 5),
+ Datastore: &rackspaceInst.DatastoreOpts{Version: "5.6", Type: "MySQL"},
}
instance, err := instances.Create(c.client, opts).Extract()
th.AssertNoErr(c.test, err)
- c.Logf("Restarting %s. Waiting...", id)
- c.WaitUntilActive(id)
+ c.Logf("Restarting %s. Waiting...", instance.ID)
+ c.WaitUntilActive(instance.ID)
c.Logf("Created DB %#v", instance)
c.instanceID = instance.ID
@@ -65,14 +69,14 @@
instanceList, err := instances.ExtractInstances(page)
c.AssertNoErr(err)
- for _, n := range networkList {
- c.Logf("Instance: %#v", instance)
+ for _, i := range instanceList {
+ c.Logf("Instance: %#v", i)
}
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) getInstance() {
@@ -88,7 +92,7 @@
}
func (c context) enableRootUser() {
- err := instances.EnableRootUser(c.client, c.instanceID).ExtractErr()
+ _, err := instances.EnableRootUser(c.client, c.instanceID).Extract()
c.AssertNoErr(err)
c.Logf("Enabled root user on %s", c.instanceID)
}
@@ -101,7 +105,7 @@
func (c context) restartInstance() {
id := c.instanceID
- err := instances.Restart(c.client, id).ExtractErr()
+ err := instances.RestartService(c.client, id).ExtractErr()
c.AssertNoErr(err)
c.Logf("Restarting %s. Waiting...", id)
c.WaitUntilActive(id)
@@ -110,7 +114,7 @@
func (c context) resizeInstance() {
id := c.instanceID
- err := instances.Resize(c.client, id, "2").ExtractErr()
+ err := instances.ResizeInstance(c.client, id, "2").ExtractErr()
c.AssertNoErr(err)
c.Logf("Resizing %s. Waiting...", id)
c.WaitUntilActive(id)
@@ -119,7 +123,7 @@
func (c context) resizeVol() {
id := c.instanceID
- err := instances.ResizeVol(c.client, id, 2).ExtractErr()
+ err := instances.ResizeVolume(c.client, id, 2).ExtractErr()
c.AssertNoErr(err)
c.Logf("Resizing volume of %s. Waiting...", id)
c.WaitUntilActive(id)
diff --git a/acceptance/openstack/db/v1/user_test.go b/acceptance/openstack/db/v1/user_test.go
index 9870419..b731469 100644
--- a/acceptance/openstack/db/v1/user_test.go
+++ b/acceptance/openstack/db/v1/user_test.go
@@ -11,34 +11,35 @@
func (c context) createUsers() {
users := []string{
- tools.RandomString("user_"),
- tools.RandomString("user_"),
- tools.RandomString("user_"),
+ tools.RandomString("user_", 5),
+ tools.RandomString("user_", 5),
+ tools.RandomString("user_", 5),
}
- db1 := db.CreateOpt{Name: c.DBIDs[0]}
- db2 := db.CreateOpt{Name: c.DBIDs[1]}
- db3 := db.CreateOpt{Name: c.DBIDs[2]}
+ db1 := db.CreateOpts{Name: c.DBIDs[0]}
+ db2 := db.CreateOpts{Name: c.DBIDs[1]}
+ db3 := db.CreateOpts{Name: c.DBIDs[2]}
opts := u.BatchCreateOpts{
u.CreateOpts{
Name: users[0],
- Password: tools.RandomString(),
- databases: db.BatchCreateOpts{db1, db2, db3},
+ Password: tools.RandomString("", 5),
+ Databases: db.BatchCreateOpts{db1, db2, db3},
},
u.CreateOpts{
Name: users[1],
- Password: tools.RandomString(),
- databases: db.BatchCreateOpts{db1, db2},
+ Password: tools.RandomString("", 5),
+ Databases: db.BatchCreateOpts{db1, db2},
},
u.CreateOpts{
Name: users[2],
- Password: tools.RandomString(),
- databases: db.BatchCreateOpts{db3},
+ Password: tools.RandomString("", 5),
+ Databases: db.BatchCreateOpts{db3},
},
}
err := u.Create(c.client, c.instanceID, opts).ExtractErr()
+ c.AssertNoErr(err)
c.Logf("Created three users on instance %s: %s, %s, %s", c.instanceID, users[0], users[1], users[2])
c.users = users
}
@@ -46,7 +47,7 @@
func (c context) listUsers() {
c.Logf("Listing databases on instance %s", c.instanceID)
- err := dbs.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
+ err := db.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
dbList, err := db.ExtractDBs(page)
c.AssertNoErr(err)
@@ -57,13 +58,13 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) deleteUsers() {
for _, id := range c.DBIDs {
err := db.Delete(c.client, c.instanceID, id).ExtractErr()
- c.CheckNoErr(err)
- t.Logf("Deleted DB %s", id)
+ c.AssertNoErr(err)
+ c.Logf("Deleted DB %s", id)
}
}
diff --git a/acceptance/rackspace/db/v1/backup_test.go b/acceptance/rackspace/db/v1/backup_test.go
index 677b3b3..7c50e19 100644
--- a/acceptance/rackspace/db/v1/backup_test.go
+++ b/acceptance/rackspace/db/v1/backup_test.go
@@ -2,18 +2,24 @@
package v1
-import "github.com/rackspace/gophercloud/pagination"
+import (
+ "github.com/rackspace/gophercloud/acceptance/tools"
+ "github.com/rackspace/gophercloud/pagination"
+
+ "github.com/rackspace/gophercloud/rackspace/db/v1/backups"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/instances"
+)
func (c context) createBackup() {
opts := backups.CreateOpts{
- Name: tools.PrefixString("backup_", 5),
+ Name: tools.RandomString("backup_", 5),
InstanceID: c.instanceID,
}
- backup, err := backups.Create(c.client, opts)
+ backup, err := backups.Create(c.client, opts).Extract()
c.Logf("Created backup %#v", backup)
- c.AssertNoErr(t, err)
+ c.AssertNoErr(err)
c.backupID = backup.ID
}
@@ -27,7 +33,7 @@
func (c context) listAllBackups() {
c.Logf("Listing backups")
- err := backups.List(c.client).EachPage(func(page pagination.Page) (bool, error) {
+ err := backups.List(c.client, nil).EachPage(func(page pagination.Page) (bool, error) {
backupList, err := backups.ExtractBackups(page)
c.AssertNoErr(err)
@@ -38,13 +44,13 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) listInstanceBackups() {
c.Logf("Listing backups for instance %s", c.instanceID)
- err := instances.ListBackups(c.client).EachPage(func(page pagination.Page) (bool, error) {
+ err := instances.ListBackups(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
backupList, err := backups.ExtractBackups(page)
c.AssertNoErr(err)
@@ -55,7 +61,7 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) deleteBackup() {
diff --git a/acceptance/rackspace/db/v1/common.go b/acceptance/rackspace/db/v1/common.go
index 2fa977f..3d10904 100644
--- a/acceptance/rackspace/db/v1/common.go
+++ b/acceptance/rackspace/db/v1/common.go
@@ -9,6 +9,7 @@
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
"github.com/rackspace/gophercloud/rackspace"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/instances"
th "github.com/rackspace/gophercloud/testhelper"
)
@@ -35,6 +36,7 @@
replicaID string
backupID string
configGroupID string
+ users []string
}
func newContext(t *testing.T) context {
@@ -63,4 +65,5 @@
}
return false, nil
})
+ c.AssertNoErr(err)
}
diff --git a/acceptance/rackspace/db/v1/config_group_test.go b/acceptance/rackspace/db/v1/config_group_test.go
index 3d269c4..fba46a9 100644
--- a/acceptance/rackspace/db/v1/config_group_test.go
+++ b/acceptance/rackspace/db/v1/config_group_test.go
@@ -3,20 +3,22 @@
package v1
import (
- config "github.com/rackspace/gophercloud/openstack/db/v1/configurations"
+ "github.com/rackspace/gophercloud/acceptance/tools"
"github.com/rackspace/gophercloud/pagination"
+ config "github.com/rackspace/gophercloud/rackspace/db/v1/configurations"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/instances"
)
func (c context) createConfigGrp() {
opts := config.CreateOpts{
- Name: tools.PrefixString("config_", 5),
+ Name: tools.RandomString("config_", 5),
Values: map[string]interface{}{
"connect_timeout": 300,
"join_buffer_size": 900000,
},
}
- cg, err := config.Create(c.client, opts)
+ cg, err := config.Create(c.client, opts).Extract()
c.AssertNoErr(err)
c.Logf("Created config group %#v", cg)
@@ -25,14 +27,14 @@
}
func (c context) getConfigGrp() {
- cg, err := config.Get(c.client, c.configGroupID)
+ cg, err := config.Get(c.client, c.configGroupID).Extract()
c.Logf("Getting config group: %#v", cg)
c.AssertNoErr(err)
}
func (c context) updateConfigGrp() {
opts := config.UpdateOpts{
- Name: tools.PrefixString("new_name_", 5),
+ Name: tools.RandomString("new_name_", 5),
Values: map[string]interface{}{
"connect_timeout": 250,
},
@@ -55,7 +57,7 @@
}
func (c context) associateInstanceWithConfigGrp() {
- err := config.AssociateWithConfigGroup(c.client, c.instanceID, c.configGroupID).ExtractErr()
+ err := instances.AssociateWithConfigGroup(c.client, c.instanceID, c.configGroupID).ExtractErr()
c.Logf("Associated instance %s with config group %s", c.instanceID, c.configGroupID)
c.AssertNoErr(err)
}
@@ -67,14 +69,14 @@
instanceList, err := instances.ExtractInstances(page)
c.AssertNoErr(err)
- for _, n := range networkList {
+ for _, instance := range instanceList {
c.Logf("Instance: %#v", instance)
}
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) deleteConfigGrp() {
diff --git a/acceptance/rackspace/db/v1/database_test.go b/acceptance/rackspace/db/v1/database_test.go
index e2d41cf..faaa7ca 100644
--- a/acceptance/rackspace/db/v1/database_test.go
+++ b/acceptance/rackspace/db/v1/database_test.go
@@ -10,9 +10,9 @@
func (c context) createDBs() {
dbs := []string{
- tools.RandomString("db_"),
- tools.RandomString("db_"),
- tools.RandomString("db_"),
+ tools.RandomString("db_", 5),
+ tools.RandomString("db_", 5),
+ tools.RandomString("db_", 5),
}
opts := db.BatchCreateOpts{
@@ -21,15 +21,17 @@
db.CreateOpts{Name: dbs[2]},
}
- res := db.Create(c.client, c.instanceID, opts)
+ err := db.Create(c.client, c.instanceID, opts).ExtractErr()
c.Logf("Created three databases on instance %s: %s, %s, %s", c.instanceID, dbs[0], dbs[1], dbs[2])
+ c.AssertNoErr(err)
+
c.DBIDs = dbs
}
func (c context) listDBs() {
c.Logf("Listing databases on instance %s", c.instanceID)
- err := dbs.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
+ err := db.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
dbList, err := db.ExtractDBs(page)
c.AssertNoErr(err)
@@ -40,13 +42,13 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) deleteDBs() {
for _, id := range c.DBIDs {
err := db.Delete(c.client, c.instanceID, id).ExtractErr()
- c.CheckNoErr(err)
- t.Logf("Deleted DB %s", id)
+ c.AssertNoErr(err)
+ c.Logf("Deleted DB %s", id)
}
}
diff --git a/acceptance/rackspace/db/v1/flavor_test.go b/acceptance/rackspace/db/v1/flavor_test.go
index e121f68..e5131c7 100644
--- a/acceptance/rackspace/db/v1/flavor_test.go
+++ b/acceptance/rackspace/db/v1/flavor_test.go
@@ -3,6 +3,7 @@
package v1
import (
+ os "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/rackspace/db/v1/flavors"
)
@@ -10,8 +11,8 @@
func (c context) listFlavors() {
c.Logf("Listing flavors")
- err := flavors.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
- flavorList, err := db.ExtractFlavors(page)
+ err := flavors.List(c.client).EachPage(func(page pagination.Page) (bool, error) {
+ flavorList, err := os.ExtractFlavors(page)
c.AssertNoErr(err)
for _, f := range flavorList {
@@ -21,11 +22,11 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) getFlavor() {
- flavor, err := flavors.Get(c.client, "1").Extract()
+ flavor, err := flavors.Get(c.client, 1).Extract()
c.Logf("Getting flavor %s", flavor.ID)
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
diff --git a/acceptance/rackspace/db/v1/instance_test.go b/acceptance/rackspace/db/v1/instance_test.go
index eb745e2..4bc44ab 100644
--- a/acceptance/rackspace/db/v1/instance_test.go
+++ b/acceptance/rackspace/db/v1/instance_test.go
@@ -3,13 +3,15 @@
package v1
import (
+ "testing"
+
"github.com/rackspace/gophercloud/acceptance/tools"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/rackspace/db/v1/instances"
th "github.com/rackspace/gophercloud/testhelper"
)
-func TestRunner(t *testingT) {
+func TestRunner(t *testing.T) {
c := newContext(t)
// FLAVOR tests
@@ -49,7 +51,7 @@
c.deleteConfigGrp()
// DATABASE tests
- c.createDB()
+ c.createDBs()
c.listDBs()
// USER tests
@@ -65,7 +67,7 @@
// TEARDOWN
c.deleteUsers()
c.deleteDBs()
- c.deleteInstance(id)
+ c.deleteInstance()
}
func (c context) createInstance() {
@@ -78,9 +80,9 @@
instance, err := instances.Create(c.client, opts).Extract()
th.AssertNoErr(c.test, err)
- c.Logf("Restarting %s. Waiting...", id)
- c.WaitUntilActive(id)
- c.Logf("Created DB %#v", instance)
+ c.Logf("Restarting %s. Waiting...", instance.ID)
+ c.WaitUntilActive(instance.ID)
+ c.Logf("Created DB %#v", instance.ID)
c.instanceID = instance.ID
}
@@ -92,14 +94,14 @@
instanceList, err := instances.ExtractInstances(page)
c.AssertNoErr(err)
- for _, n := range networkList {
+ for _, instance := range instanceList {
c.Logf("Instance: %#v", instance)
}
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) getInstance() {
@@ -115,7 +117,7 @@
}
func (c context) enableRootUser() {
- err := instances.EnableRootUser(c.client, c.instanceID).ExtractErr()
+ _, err := instances.EnableRootUser(c.client, c.instanceID).Extract()
c.AssertNoErr(err)
c.Logf("Enabled root user on %s", c.instanceID)
}
@@ -128,7 +130,7 @@
func (c context) restartInstance() {
id := c.instanceID
- err := instances.Restart(c.client, id).ExtractErr()
+ err := instances.RestartService(c.client, id).ExtractErr()
c.AssertNoErr(err)
c.Logf("Restarting %s. Waiting...", id)
c.WaitUntilActive(id)
@@ -137,7 +139,7 @@
func (c context) resizeInstance() {
id := c.instanceID
- err := instances.Resize(c.client, id, "2").ExtractErr()
+ err := instances.ResizeInstance(c.client, id, "2").ExtractErr()
c.AssertNoErr(err)
c.Logf("Resizing %s. Waiting...", id)
c.WaitUntilActive(id)
@@ -146,7 +148,7 @@
func (c context) resizeVol() {
id := c.instanceID
- err := instances.ResizeVol(c.client, id, 2).ExtractErr()
+ err := instances.ResizeVolume(c.client, id, 2).ExtractErr()
c.AssertNoErr(err)
c.Logf("Resizing volume of %s. Waiting...", id)
c.WaitUntilActive(id)
diff --git a/acceptance/rackspace/db/v1/replica_test.go b/acceptance/rackspace/db/v1/replica_test.go
index 96eaf19..3da2881 100644
--- a/acceptance/rackspace/db/v1/replica_test.go
+++ b/acceptance/rackspace/db/v1/replica_test.go
@@ -9,8 +9,6 @@
)
func (c context) createReplica() {
- repl, err := instances.Create(c.client, opts).Extract()
-
opts := instances.CreateOpts{
FlavorRef: "1",
Size: 1,
@@ -18,11 +16,11 @@
ReplicaOf: c.instanceID,
}
- instance, err := instances.Create(c.client, opts).Extract()
+ repl, err := instances.Create(c.client, opts).Extract()
th.AssertNoErr(c.test, err)
c.Logf("Creating replica of %s. Waiting...", c.instanceID)
- c.WaitUntilActive(id)
+ c.WaitUntilActive(repl.ID)
c.Logf("Created replica %#v", repl)
c.replicaID = repl.ID
@@ -31,4 +29,5 @@
func (c context) detachReplica() {
err := instances.DetachReplica(c.client, c.replicaID).ExtractErr()
c.Logf("Detached replica %s", c.replicaID)
+ c.AssertNoErr(err)
}
diff --git a/acceptance/rackspace/db/v1/user_test.go b/acceptance/rackspace/db/v1/user_test.go
index 9bf00dd..53cebc1 100644
--- a/acceptance/rackspace/db/v1/user_test.go
+++ b/acceptance/rackspace/db/v1/user_test.go
@@ -4,51 +4,51 @@
import (
"github.com/rackspace/gophercloud/acceptance/tools"
- "github.com/rackspace/gophercloud/openstack/identity/v2/users"
+ db "github.com/rackspace/gophercloud/openstack/db/v1/databases"
+ os "github.com/rackspace/gophercloud/openstack/db/v1/users"
"github.com/rackspace/gophercloud/pagination"
- db "github.com/rackspace/gophercloud/rackspace/db/v1/databases"
- u "github.com/rackspace/gophercloud/rackspace/db/v1/users"
+ "github.com/rackspace/gophercloud/rackspace/db/v1/users"
)
func (c context) createUsers() {
- users := []string{
- tools.RandomString("user_"),
- tools.RandomString("user_"),
- tools.RandomString("user_"),
+ c.users = []string{
+ tools.RandomString("user_", 5),
+ tools.RandomString("user_", 5),
+ tools.RandomString("user_", 5),
}
- db1 := db.CreateOpt{Name: c.DBIDs[0]}
- db2 := db.CreateOpt{Name: c.DBIDs[1]}
- db3 := db.CreateOpt{Name: c.DBIDs[2]}
+ db1 := db.CreateOpts{Name: c.DBIDs[0]}
+ db2 := db.CreateOpts{Name: c.DBIDs[1]}
+ db3 := db.CreateOpts{Name: c.DBIDs[2]}
- opts := u.BatchCreateOpts{
- u.CreateOpts{
- Name: users[0],
- Password: tools.RandomString(),
- databases: db.BatchCreateOpts{db1, db2, db3},
+ opts := os.BatchCreateOpts{
+ os.CreateOpts{
+ Name: c.users[0],
+ Password: tools.RandomString("db_", 5),
+ Databases: db.BatchCreateOpts{db1, db2, db3},
},
- u.CreateOpts{
- Name: users[1],
- Password: tools.RandomString(),
- databases: db.BatchCreateOpts{db1, db2},
+ os.CreateOpts{
+ Name: c.users[1],
+ Password: tools.RandomString("db_", 5),
+ Databases: db.BatchCreateOpts{db1, db2},
},
- u.CreateOpts{
- Name: users[2],
- Password: tools.RandomString(),
- databases: db.BatchCreateOpts{db3},
+ os.CreateOpts{
+ Name: c.users[2],
+ Password: tools.RandomString("db_", 5),
+ Databases: db.BatchCreateOpts{db3},
},
}
- err := u.Create(c.client, c.instanceID, opts).ExtractErr()
- c.Logf("Created three users on instance %s: %s, %s, %s", c.instanceID, users[0], users[1], users[2])
- c.users = users
+ err := users.Create(c.client, c.instanceID, opts).ExtractErr()
+ c.Logf("Created three users on instance %s: %s, %s, %s", c.instanceID, c.users[0], c.users[1], c.users[2])
+ c.AssertNoErr(err)
}
func (c context) listUsers() {
c.Logf("Listing users on instance %s", c.instanceID)
- err := users.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
- uList, err := u.ExtractUsers(page)
+ err := os.List(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
+ uList, err := os.ExtractUsers(page)
c.AssertNoErr(err)
for _, u := range uList {
@@ -58,44 +58,44 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) deleteUsers() {
for _, id := range c.users {
- err := u.Delete(c.client, c.instanceID, id).ExtractErr()
- c.CheckNoErr(err)
- t.Logf("Deleted user %s", id)
+ err := users.Delete(c.client, c.instanceID, id).ExtractErr()
+ c.AssertNoErr(err)
+ c.Logf("Deleted user %s", id)
}
}
func (c context) changeUserPwd() {
- opts := u.BatchCreateOpts{}
+ opts := os.BatchCreateOpts{}
- for _, id := range c.users[:1] {
- opts = append(opts, u.CreateOpts{Password: tools.PrefixString("", 5)})
+ for _, name := range c.users[:1] {
+ opts = append(opts, os.CreateOpts{Name: name, Password: tools.RandomString("", 5)})
}
- err := u.UpdatePassword(c.client, c.instanceID, opts).ExtractErr()
+ err := users.ChangePassword(c.client, c.instanceID, opts).ExtractErr()
c.Logf("Updated 2 users' passwords")
c.AssertNoErr(err)
}
func (c context) getUser() {
- user, err := u.Get(c.client, c.instanceID, c.users[0]).Extract()
+ user, err := users.Get(c.client, c.instanceID, c.users[0]).Extract()
c.Logf("Getting user %s", user)
c.AssertNoErr(err)
}
func (c context) updateUser() {
- opts := u.CreateOpts{Name: tools.PrefixString("new_name_", 5)}
- user, err := u.Update(c.client, c.instanceID, c.users[0], opts).Extract()
- c.Logf("Updated user %s", user)
+ opts := os.CreateOpts{Name: tools.RandomString("new_name_", 5)}
+ err := users.Update(c.client, c.instanceID, c.users[0], opts).ExtractErr()
+ c.Logf("Updated user %s", c.users[0])
c.AssertNoErr(err)
}
func (c context) listUserAccess() {
- err := u.ListAccess(c.client, c.instanceId, c.users[0]).EachPage(func(page pagination.Page) (bool, error) {
+ err := users.ListAccess(c.client, c.instanceID, c.users[0]).EachPage(func(page pagination.Page) (bool, error) {
dbList, err := db.ExtractDBs(page)
c.AssertNoErr(err)
@@ -106,17 +106,19 @@
return true, nil
})
- c.CheckNoErr(err)
+ c.AssertNoErr(err)
}
func (c context) grantUserAccess() {
- userID, dbID := c.users[0], c.DBIDS[0]
- err := u.GrantUserAccess(c.client, c.instanceID, userID, dbID)
- c.Logf("Granted access for user %s to DB %s", userID, dbID)
+ opts := db.BatchCreateOpts{db.CreateOpts{Name: c.DBIDs[0]}}
+ err := users.GrantAccess(c.client, c.instanceID, c.users[0], opts).ExtractErr()
+ c.Logf("Granted access for user %s to DB %s", c.users[0], c.DBIDs[0])
+ c.AssertNoErr(err)
}
func (c context) revokeUserAccess() {
- userID, dbID := c.users[0], c.DBIDS[0]
- err := u.RevokeUserAccess(c.client, c.instanceID, userID, dbID)
- c.Logf("Revoked access for user %s to DB %s", userID, dbID)
+ dbName, userName := c.DBIDs[0], c.users[0]
+ err := users.RevokeAccess(c.client, c.instanceID, userName, dbName).ExtractErr()
+ c.Logf("Revoked access for user %s to DB %s", userName, dbName)
+ c.AssertNoErr(err)
}
diff --git a/openstack/db/v1/databases/results.go b/openstack/db/v1/databases/results.go
index 7c967f5..7d4b6ae 100644
--- a/openstack/db/v1/databases/results.go
+++ b/openstack/db/v1/databases/results.go
@@ -21,7 +21,7 @@
// CreateResult represents the result of a Create operation.
type CreateResult struct {
- gophercloud.Result
+ gophercloud.ErrResult
}
// DeleteResult represents the result of a Delete operation.
diff --git a/openstack/db/v1/flavors/requests_test.go b/openstack/db/v1/flavors/requests_test.go
index 0afe9bb..88b5871 100644
--- a/openstack/db/v1/flavors/requests_test.go
+++ b/openstack/db/v1/flavors/requests_test.go
@@ -25,7 +25,7 @@
expected := []Flavor{
Flavor{
- ID: 1,
+ ID: "1",
Name: "m1.tiny",
RAM: 512,
Links: []gophercloud.Link{
@@ -34,7 +34,7 @@
},
},
Flavor{
- ID: 2,
+ ID: "2",
Name: "m1.small",
RAM: 1024,
Links: []gophercloud.Link{
@@ -43,7 +43,7 @@
},
},
Flavor{
- ID: 3,
+ ID: "3",
Name: "m1.medium",
RAM: 2048,
Links: []gophercloud.Link{
@@ -52,7 +52,7 @@
},
},
Flavor{
- ID: 4,
+ ID: "4",
Name: "m1.large",
RAM: 4096,
Links: []gophercloud.Link{
@@ -79,7 +79,7 @@
th.AssertNoErr(t, err)
expected := &Flavor{
- ID: 1,
+ ID: "1",
Name: "m1.tiny",
RAM: 512,
Links: []gophercloud.Link{
diff --git a/openstack/db/v1/flavors/results.go b/openstack/db/v1/flavors/results.go
index d3f507e..2089f67 100644
--- a/openstack/db/v1/flavors/results.go
+++ b/openstack/db/v1/flavors/results.go
@@ -28,7 +28,7 @@
// Flavor records represent (virtual) hardware configurations for server resources in a region.
type Flavor struct {
// The flavor's unique identifier.
- ID int `mapstructure:"id"`
+ ID string `mapstructure:"id"`
// The RAM capacity for the flavor.
RAM int `mapstructure:"ram"`
diff --git a/openstack/db/v1/instances/fixtures.go b/openstack/db/v1/instances/fixtures.go
index 726501b..502d87f 100644
--- a/openstack/db/v1/instances/fixtures.go
+++ b/openstack/db/v1/instances/fixtures.go
@@ -105,7 +105,7 @@
Created: "2014-02-13T21:47:13",
Updated: "2014-02-13T21:47:13",
Flavor: flavors.Flavor{
- ID: 1,
+ ID: "1",
Links: []gophercloud.Link{
gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "self"},
gophercloud.Link{Href: "https://my-openstack.com/v1.0/1234/flavors/1", Rel: "bookmark"},
diff --git a/rackspace/db/v1/configurations/urls.go b/rackspace/db/v1/configurations/urls.go
index 4d4c244..abea961 100644
--- a/rackspace/db/v1/configurations/urls.go
+++ b/rackspace/db/v1/configurations/urls.go
@@ -15,11 +15,11 @@
}
func listDSParamsURL(c *gophercloud.ServiceClient, datastoreID, versionID string) string {
- return c.ServiceURL("datastores", dsID, "versions", versionID, "parameters")
+ return c.ServiceURL("datastores", datastoreID, "versions", versionID, "parameters")
}
func getDSParamURL(c *gophercloud.ServiceClient, datastoreID, versionID, paramID string) string {
- return c.ServiceURL("datastores", dsID, "versions", versionID, "parameters", paramID)
+ return c.ServiceURL("datastores", datastoreID, "versions", versionID, "parameters", paramID)
}
func listGlobalParamsURL(c *gophercloud.ServiceClient, versionID string) string {
diff --git a/rackspace/db/v1/databases/results.go b/rackspace/db/v1/databases/results.go
deleted file mode 100644
index 18cbec7..0000000
--- a/rackspace/db/v1/databases/results.go
+++ /dev/null
@@ -1 +0,0 @@
-package databases
diff --git a/rackspace/db/v1/flavors/delegate.go b/rackspace/db/v1/flavors/delegate.go
index 689b81e..fd2608d 100644
--- a/rackspace/db/v1/flavors/delegate.go
+++ b/rackspace/db/v1/flavors/delegate.go
@@ -12,6 +12,6 @@
}
// Get retrieves the details for a particular flavor.
-func Get(client *gophercloud.ServiceClient, flavorID string) os.GetResult {
+func Get(client *gophercloud.ServiceClient, flavorID int) os.GetResult {
return os.Get(client, flavorID)
}
diff --git a/rackspace/db/v1/instances/fixtures.go b/rackspace/db/v1/instances/fixtures.go
index 92ad7ec..b59aeae 100644
--- a/rackspace/db/v1/instances/fixtures.go
+++ b/rackspace/db/v1/instances/fixtures.go
@@ -2,6 +2,7 @@
import (
"github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
"github.com/rackspace/gophercloud/rackspace/db/v1/datastores"
)
@@ -301,7 +302,7 @@
Created: "2014-10-14T18:42:15",
ID: "8367c312-7c40-4a66-aab1-5767478914fc",
Volume: os.Volume{Size: 1},
- Flavor: os.Flavor{ID: "9"},
+ Flavor: flavors.Flavor{ID: "9"},
Datastore: datastores.DatastorePartial{Version: "5.6", Type: "mysql"},
ReplicaOf: &Instance{
ID: "6bdca2fc-418e-40bd-a595-62abda61862d",
diff --git a/rackspace/db/v1/instances/results.go b/rackspace/db/v1/instances/results.go
index 7a44f1b..a516cb4 100644
--- a/rackspace/db/v1/instances/results.go
+++ b/rackspace/db/v1/instances/results.go
@@ -3,6 +3,7 @@
import (
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/openstack/db/v1/flavors"
os "github.com/rackspace/gophercloud/openstack/db/v1/instances"
"github.com/rackspace/gophercloud/pagination"
"github.com/rackspace/gophercloud/rackspace/db/v1/datastores"
@@ -20,7 +21,7 @@
Datastore datastores.DatastorePartial
// Indicates the hardware flavor the instance uses.
- Flavor os.Flavor
+ Flavor flavors.Flavor
// A DNS-resolvable hostname associated with the database instance (rather
// than an IPv4 address). Since the hostname always resolves to the correct
diff --git a/rackspace/db/v1/users/requests.go b/rackspace/db/v1/users/requests.go
index 7c30079..fd0b649 100644
--- a/rackspace/db/v1/users/requests.go
+++ b/rackspace/db/v1/users/requests.go
@@ -107,16 +107,9 @@
/*
RevokeAccess will revoke access for the specified user to one or more databases
-on a specified instance. For example, to remove a user's access to multiple
-databases:
+on a specified instance. For example:
- opts := db.BatchCreateOpts{
- db.CreateOpts{Name: "database_1"},
- db.CreateOpts{Name: "database_3"},
- db.CreateOpts{Name: "database_19"},
- }
-
- RevokeAccess(client, "instance_id", "user_name", opts)
+ RevokeAccess(client, "instance_id", "user_name", "db_name")
*/
func RevokeAccess(client *gophercloud.ServiceClient, instanceID, userName, dbName string) RevokeAccessResult {
var res RevokeAccessResult