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