Jamie Hannaford | 80c7067 | 2015-10-06 16:09:33 +0200 | [diff] [blame] | 1 | // +build acceptance db rackspace |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 2 | |
| 3 | package v1 |
| 4 | |
| 5 | import ( |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame^] | 6 | "github.com/gophercloud/gophercloud/acceptance/tools" |
| 7 | "github.com/gophercloud/gophercloud/rackspace/db/v1/instances" |
| 8 | th "github.com/gophercloud/gophercloud/testhelper" |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 9 | ) |
| 10 | |
Jamie Hannaford | 99eced5 | 2015-03-02 15:24:22 +0100 | [diff] [blame] | 11 | func (c *context) createReplica() { |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 12 | opts := instances.CreateOpts{ |
Jamie Hannaford | 99eced5 | 2015-03-02 15:24:22 +0100 | [diff] [blame] | 13 | FlavorRef: "2", |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 14 | Size: 1, |
| 15 | Name: tools.RandomString("gopher_db", 5), |
| 16 | ReplicaOf: c.instanceID, |
| 17 | } |
| 18 | |
Jamie Hannaford | 1110840 | 2015-02-23 10:31:41 +0100 | [diff] [blame] | 19 | repl, err := instances.Create(c.client, opts).Extract() |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 20 | th.AssertNoErr(c.test, err) |
| 21 | |
| 22 | c.Logf("Creating replica of %s. Waiting...", c.instanceID) |
Jamie Hannaford | 1110840 | 2015-02-23 10:31:41 +0100 | [diff] [blame] | 23 | c.WaitUntilActive(repl.ID) |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 24 | c.Logf("Created replica %#v", repl) |
| 25 | |
| 26 | c.replicaID = repl.ID |
| 27 | } |
| 28 | |
Jamie Hannaford | 99eced5 | 2015-03-02 15:24:22 +0100 | [diff] [blame] | 29 | func (c *context) detachReplica() { |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 30 | err := instances.DetachReplica(c.client, c.replicaID).ExtractErr() |
| 31 | c.Logf("Detached replica %s", c.replicaID) |
Jamie Hannaford | 1110840 | 2015-02-23 10:31:41 +0100 | [diff] [blame] | 32 | c.AssertNoErr(err) |
Jamie Hannaford | 05d200d | 2015-02-20 14:49:05 +0100 | [diff] [blame] | 33 | } |