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)
}
}