Samuel A. Falvo II | b5d93f2 | 2014-02-21 15:00:20 -0800 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 3 | package compute |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 4 | |
| 5 | import ( |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 6 | "fmt" |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 7 | "os" |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 8 | "testing" |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 9 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 10 | "github.com/rackspace/gophercloud/acceptance/tools" |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 11 | "github.com/rackspace/gophercloud/openstack/compute/v2/flavors" |
| 12 | "github.com/rackspace/gophercloud/openstack/compute/v2/images" |
| 13 | "github.com/rackspace/gophercloud/openstack/compute/v2/servers" |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 14 | ) |
| 15 | |
Jon Perritt | 816d2a0 | 2014-03-11 20:49:46 -0500 | [diff] [blame] | 16 | var service = "compute" |
| 17 | |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 18 | func TestListServers(t *testing.T) { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 19 | ts, err := tools.SetupForList(service) |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 20 | if err != nil { |
| 21 | t.Error(err) |
| 22 | return |
| 23 | } |
| 24 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 25 | fmt.Fprintln(ts.W, "ID\tRegion\tName\tStatus\tIPv4\tIPv6\t") |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 26 | |
| 27 | region := os.Getenv("OS_REGION_NAME") |
| 28 | n := 0 |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 29 | for _, ep := range ts.EPs { |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 30 | if (region != "") && (region != ep.Region) { |
| 31 | continue |
| 32 | } |
| 33 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 34 | client := servers.NewClient(ep.PublicURL, ts.A, ts.O) |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 35 | |
| 36 | listResults, err := servers.List(client) |
| 37 | if err != nil { |
| 38 | t.Error(err) |
| 39 | return |
| 40 | } |
| 41 | |
| 42 | svrs, err := servers.GetServers(listResults) |
| 43 | if err != nil { |
| 44 | t.Error(err) |
| 45 | return |
| 46 | } |
| 47 | |
| 48 | n = n + len(svrs) |
| 49 | |
| 50 | for _, s := range svrs { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 51 | fmt.Fprintf(ts.W, "%s\t%s\t%s\t%s\t%s\t%s\t\n", s.Id, s.Name, ep.Region, s.Status, s.AccessIPv4, s.AccessIPv6) |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 52 | } |
| 53 | } |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 54 | ts.W.Flush() |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 55 | fmt.Printf("--------\n%d servers listed.\n", n) |
| 56 | } |
| 57 | |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 58 | func TestListImages(t *testing.T) { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 59 | ts, err := tools.SetupForList(service) |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 60 | if err != nil { |
| 61 | t.Error(err) |
| 62 | return |
| 63 | } |
| 64 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 65 | fmt.Fprintln(ts.W, "ID\tRegion\tName\tStatus\tCreated\t") |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 66 | |
| 67 | region := os.Getenv("OS_REGION_NAME") |
| 68 | n := 0 |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 69 | for _, ep := range ts.EPs { |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 70 | if (region != "") && (region != ep.Region) { |
| 71 | continue |
| 72 | } |
| 73 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 74 | client := images.NewClient(ep.PublicURL, ts.A, ts.O) |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 75 | |
| 76 | listResults, err := images.List(client) |
| 77 | if err != nil { |
| 78 | t.Error(err) |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | imgs, err := images.GetImages(listResults) |
| 83 | if err != nil { |
| 84 | t.Error(err) |
| 85 | return |
| 86 | } |
| 87 | |
| 88 | n = n + len(imgs) |
| 89 | |
| 90 | for _, i := range imgs { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 91 | fmt.Fprintf(ts.W, "%s\t%s\t%s\t%s\t%s\t\n", i.Id, ep.Region, i.Name, i.Status, i.Created) |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 92 | } |
| 93 | } |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 94 | ts.W.Flush() |
Samuel A. Falvo II | f370dc7 | 2014-02-13 15:05:34 -0800 | [diff] [blame] | 95 | fmt.Printf("--------\n%d images listed.\n", n) |
| 96 | } |
| 97 | |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 98 | func TestListFlavors(t *testing.T) { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 99 | ts, err := tools.SetupForList(service) |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 100 | if err != nil { |
| 101 | t.Error(err) |
| 102 | return |
| 103 | } |
| 104 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 105 | fmt.Fprintln(ts.W, "ID\tRegion\tName\tRAM\tDisk\tVCPUs\t") |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 106 | |
| 107 | region := os.Getenv("OS_REGION_NAME") |
| 108 | n := 0 |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 109 | for _, ep := range ts.EPs { |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 110 | if (region != "") && (region != ep.Region) { |
| 111 | continue |
| 112 | } |
| 113 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 114 | client := flavors.NewClient(ep.PublicURL, ts.A, ts.O) |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 115 | |
Samuel A. Falvo II | 38c6ad0 | 2014-05-06 18:09:46 -0700 | [diff] [blame] | 116 | listResults, err := flavors.List(client, flavors.ListFilterOptions{}) |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 117 | if err != nil { |
| 118 | t.Error(err) |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | flavs, err := flavors.GetFlavors(listResults) |
| 123 | if err != nil { |
| 124 | t.Error(err) |
| 125 | return |
| 126 | } |
| 127 | |
| 128 | n = n + len(flavs) |
| 129 | |
| 130 | for _, f := range flavs { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 131 | fmt.Fprintf(ts.W, "%s\t%s\t%s\t%d\t%d\t%d\t\n", f.Id, ep.Region, f.Name, f.Ram, f.Disk, f.VCpus) |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 132 | } |
| 133 | } |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 134 | ts.W.Flush() |
Samuel A. Falvo II | 38c6ad0 | 2014-05-06 18:09:46 -0700 | [diff] [blame] | 135 | fmt.Printf("--------\n%d flavors listed.\n", n) |
| 136 | } |
| 137 | |
| 138 | func TestGetFlavor(t *testing.T) { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 139 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | 38c6ad0 | 2014-05-06 18:09:46 -0700 | [diff] [blame] | 140 | if err != nil { |
| 141 | t.Fatal(err) |
| 142 | } |
| 143 | |
| 144 | region := os.Getenv("OS_REGION_NAME") |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 145 | for _, ep := range ts.EPs { |
Samuel A. Falvo II | 38c6ad0 | 2014-05-06 18:09:46 -0700 | [diff] [blame] | 146 | if (region != "") && (region != ep.Region) { |
| 147 | continue |
| 148 | } |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 149 | client := flavors.NewClient(ep.PublicURL, ts.A, ts.O) |
Samuel A. Falvo II | 38c6ad0 | 2014-05-06 18:09:46 -0700 | [diff] [blame] | 150 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 151 | getResults, err := flavors.Get(client, ts.FlavorId) |
Samuel A. Falvo II | 38c6ad0 | 2014-05-06 18:09:46 -0700 | [diff] [blame] | 152 | if err != nil { |
| 153 | t.Fatal(err) |
| 154 | } |
| 155 | flav, err := flavors.GetFlavor(getResults) |
| 156 | if err != nil { |
| 157 | t.Fatal(err) |
| 158 | } |
| 159 | fmt.Printf("%#v\n", flav) |
| 160 | } |
Samuel A. Falvo II | db02088 | 2014-02-13 15:37:57 -0800 | [diff] [blame] | 161 | } |
| 162 | |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 163 | func TestCreateDestroyServer(t *testing.T) { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 164 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 165 | if err != nil { |
| 166 | t.Error(err) |
| 167 | return |
| 168 | } |
| 169 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 170 | err = tools.CreateServer(ts) |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 171 | if err != nil { |
| 172 | t.Error(err) |
| 173 | return |
| 174 | } |
| 175 | |
Samuel A. Falvo II | 0abdb10 | 2014-02-13 23:19:26 -0800 | [diff] [blame] | 176 | // We put this in a defer so that it gets executed even in the face of errors or panics. |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 177 | defer func() { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 178 | servers.Delete(ts.Client, ts.CreatedServer.Id) |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 179 | }() |
| 180 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 181 | err = tools.WaitForStatus(ts, "ACTIVE") |
Samuel A. Falvo II | 0abdb10 | 2014-02-13 23:19:26 -0800 | [diff] [blame] | 182 | if err != nil { |
| 183 | t.Error(err) |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 187 | func TestUpdateServer(t *testing.T) { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 188 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 189 | if err != nil { |
| 190 | t.Error(err) |
| 191 | return |
| 192 | } |
| 193 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 194 | err = tools.CreateServer(ts) |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 195 | if err != nil { |
| 196 | t.Error(err) |
| 197 | return |
| 198 | } |
| 199 | |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 200 | defer func() { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 201 | servers.Delete(ts.Client, ts.CreatedServer.Id) |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 202 | }() |
| 203 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 204 | err = tools.WaitForStatus(ts, "ACTIVE") |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 205 | if err != nil { |
| 206 | t.Error(err) |
| 207 | return |
| 208 | } |
| 209 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 210 | err = tools.ChangeServerName(ts) |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 211 | if err != nil { |
| 212 | t.Error(err) |
| 213 | return |
| 214 | } |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 215 | } |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 216 | |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 217 | func TestActionChangeAdminPassword(t *testing.T) { |
| 218 | t.Parallel() |
| 219 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 220 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 221 | if err != nil { |
| 222 | t.Fatal(err) |
| 223 | } |
| 224 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 225 | err = tools.CreateServer(ts) |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 226 | if err != nil { |
| 227 | t.Fatal(err) |
| 228 | } |
| 229 | |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 230 | defer func() { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 231 | servers.Delete(ts.Client, ts.CreatedServer.Id) |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 232 | }() |
| 233 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 234 | err = tools.WaitForStatus(ts, "ACTIVE") |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 235 | if err != nil { |
| 236 | t.Fatal(err) |
| 237 | } |
| 238 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 239 | err = tools.ChangeAdminPassword(ts) |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 240 | if err != nil { |
| 241 | t.Fatal(err) |
| 242 | } |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | func TestActionReboot(t *testing.T) { |
| 246 | t.Parallel() |
| 247 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 248 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 249 | if err != nil { |
| 250 | t.Fatal(err) |
| 251 | } |
| 252 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 253 | err = tools.CreateServer(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 254 | if err != nil { |
| 255 | t.Fatal(err) |
| 256 | } |
| 257 | |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 258 | defer func() { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 259 | servers.Delete(ts.Client, ts.CreatedServer.Id) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 260 | }() |
| 261 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 262 | err = tools.WaitForStatus(ts, "ACTIVE") |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 263 | if err != nil { |
| 264 | t.Fatal(err) |
| 265 | } |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 266 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 267 | err = servers.Reboot(ts.Client, ts.CreatedServer.Id, "aldhjflaskhjf") |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 268 | if err == nil { |
| 269 | t.Fatal("Expected the SDK to provide an ArgumentError here") |
| 270 | } |
| 271 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 272 | err = tools.RebootServer(ts) |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 273 | if err != nil { |
| 274 | t.Fatal(err) |
| 275 | } |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 278 | func TestActionRebuild(t *testing.T) { |
| 279 | t.Parallel() |
| 280 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 281 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 282 | if err != nil { |
| 283 | t.Fatal(err) |
| 284 | } |
| 285 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 286 | err = tools.CreateServer(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 287 | if err != nil { |
| 288 | t.Fatal(err) |
| 289 | } |
| 290 | |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 291 | defer func() { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 292 | servers.Delete(ts.Client, ts.CreatedServer.Id) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 293 | }() |
| 294 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 295 | err = tools.WaitForStatus(ts, "ACTIVE") |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 296 | if err != nil { |
| 297 | t.Fatal(err) |
| 298 | } |
| 299 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 300 | err = tools.RebuildServer(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 301 | if err != nil { |
| 302 | t.Fatal(err) |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | func TestActionResizeConfirm(t *testing.T) { |
| 307 | t.Parallel() |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 308 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 309 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 310 | if err != nil { |
| 311 | t.Fatal(err) |
| 312 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 313 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 314 | err = tools.CreateServer(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 315 | if err != nil { |
| 316 | t.Fatal(err) |
| 317 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 318 | |
| 319 | defer func() { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 320 | servers.Delete(ts.Client, ts.CreatedServer.Id) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 321 | }() |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 322 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 323 | err = tools.WaitForStatus(ts, "ACTIVE") |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 324 | if err != nil { |
| 325 | t.Fatal(err) |
| 326 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 327 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 328 | err = tools.ResizeServer(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 329 | if err != nil { |
| 330 | t.Fatal(err) |
| 331 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 332 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 333 | err = tools.ConfirmResize(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 334 | if err != nil { |
| 335 | t.Fatal(err) |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | func TestActionResizeRevert(t *testing.T) { |
| 340 | t.Parallel() |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 341 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 342 | ts, err := tools.SetupForCRUD() |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 343 | if err != nil { |
| 344 | t.Fatal(err) |
| 345 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 346 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 347 | err = tools.CreateServer(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 348 | if err != nil { |
| 349 | t.Fatal(err) |
| 350 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 351 | |
| 352 | defer func() { |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 353 | servers.Delete(ts.Client, ts.CreatedServer.Id) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 354 | }() |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 355 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 356 | err = tools.WaitForStatus(ts, "ACTIVE") |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 357 | if err != nil { |
| 358 | t.Fatal(err) |
| 359 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 360 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 361 | err = tools.ResizeServer(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 362 | if err != nil { |
| 363 | t.Fatal(err) |
| 364 | } |
Jamie Hannaford | c8fc6ea | 2014-09-10 13:59:58 +0200 | [diff] [blame^] | 365 | |
Samuel A. Falvo II | 43d8353 | 2014-07-31 14:34:48 -0700 | [diff] [blame] | 366 | err = tools.RevertResize(ts) |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 367 | if err != nil { |
| 368 | t.Fatal(err) |
| 369 | } |
| 370 | } |