Keith Byrne | bda4859 | 2016-03-23 11:37:08 +0000 | [diff] [blame^] | 1 | // +build fixtures |
| 2 | |
Jamie Hannaford | 6ee7d4a | 2015-02-09 17:26:49 +0100 | [diff] [blame] | 3 | package instances |
| 4 | |
| 5 | import ( |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 6 | "fmt" |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 7 | "time" |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 8 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 9 | "github.com/rackspace/gophercloud" |
Jamie Hannaford | 52dbcee | 2015-10-06 16:09:56 +0200 | [diff] [blame] | 10 | "github.com/rackspace/gophercloud/openstack/db/v1/datastores" |
Jamie Hannaford | 1110840 | 2015-02-23 10:31:41 +0100 | [diff] [blame] | 11 | "github.com/rackspace/gophercloud/openstack/db/v1/flavors" |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 12 | os "github.com/rackspace/gophercloud/openstack/db/v1/instances" |
Jamie Hannaford | 6ee7d4a | 2015-02-09 17:26:49 +0100 | [diff] [blame] | 13 | ) |
| 14 | |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 15 | var ( |
| 16 | timestamp = "2015-11-12T14:22:42Z" |
| 17 | timeVal, _ = time.Parse(time.RFC3339, timestamp) |
| 18 | ) |
| 19 | |
| 20 | var instance = ` |
Jamie Hannaford | 39d4ffb | 2015-02-10 13:19:44 +0100 | [diff] [blame] | 21 | { |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 22 | "created": "` + timestamp + `", |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 23 | "datastore": { |
| 24 | "type": "mysql", |
| 25 | "version": "5.6" |
| 26 | }, |
| 27 | "flavor": { |
| 28 | "id": "1", |
Jamie Hannaford | 39d4ffb | 2015-02-10 13:19:44 +0100 | [diff] [blame] | 29 | "links": [ |
| 30 | { |
| 31 | "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", |
| 32 | "rel": "self" |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 33 | }, |
| 34 | { |
| 35 | "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", |
| 36 | "rel": "bookmark" |
Jamie Hannaford | 39d4ffb | 2015-02-10 13:19:44 +0100 | [diff] [blame] | 37 | } |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 38 | ] |
| 39 | }, |
| 40 | "links": [ |
| 41 | { |
| 42 | "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", |
| 43 | "rel": "self" |
Jamie Hannaford | 39d4ffb | 2015-02-10 13:19:44 +0100 | [diff] [blame] | 44 | } |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 45 | ], |
| 46 | "hostname": "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com", |
| 47 | "id": "{instanceID}", |
| 48 | "name": "json_rack_instance", |
| 49 | "status": "BUILD", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 50 | "updated": "` + timestamp + `", |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 51 | "volume": { |
| 52 | "size": 2 |
Jamie Hannaford | 39d4ffb | 2015-02-10 13:19:44 +0100 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | ` |
| 56 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 57 | var createReq = ` |
Jamie Hannaford | 6ee7d4a | 2015-02-09 17:26:49 +0100 | [diff] [blame] | 58 | { |
| 59 | "instance": { |
| 60 | "databases": [ |
| 61 | { |
| 62 | "character_set": "utf8", |
| 63 | "collate": "utf8_general_ci", |
| 64 | "name": "sampledb" |
| 65 | }, |
| 66 | { |
| 67 | "name": "nextround" |
| 68 | } |
| 69 | ], |
| 70 | "flavorRef": "1", |
| 71 | "name": "json_rack_instance", |
| 72 | "users": [ |
| 73 | { |
| 74 | "databases": [ |
| 75 | { |
| 76 | "name": "sampledb" |
| 77 | } |
| 78 | ], |
| 79 | "name": "demouser", |
| 80 | "password": "demopassword" |
| 81 | } |
| 82 | ], |
| 83 | "volume": { |
| 84 | "size": 2 |
| 85 | }, |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 86 | "restorePoint": { |
| 87 | "backupRef": "1234567890" |
| 88 | } |
Jamie Hannaford | 6ee7d4a | 2015-02-09 17:26:49 +0100 | [diff] [blame] | 89 | } |
| 90 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 91 | ` |
Jamie Hannaford | 6ee7d4a | 2015-02-09 17:26:49 +0100 | [diff] [blame] | 92 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 93 | var createReplicaReq = ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 94 | { |
| 95 | "instance": { |
| 96 | "volume": { |
| 97 | "size": 1 |
| 98 | }, |
| 99 | "flavorRef": "9", |
| 100 | "name": "t2s1_ALT_GUEST", |
| 101 | "replica_of": "6bdca2fc-418e-40bd-a595-62abda61862d" |
| 102 | } |
| 103 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 104 | ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 105 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 106 | var createReplicaResp = ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 107 | { |
| 108 | "instance": { |
| 109 | "status": "BUILD", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 110 | "updated": "` + timestamp + `", |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 111 | "name": "t2s1_ALT_GUEST", |
| 112 | "links": [ |
| 113 | { |
| 114 | "href": "https://ord.databases.api.rackspacecloud.com/v1.0/5919009/instances/8367c312-7c40-4a66-aab1-5767478914fc", |
| 115 | "rel": "self" |
| 116 | }, |
| 117 | { |
| 118 | "href": "https://ord.databases.api.rackspacecloud.com/instances/8367c312-7c40-4a66-aab1-5767478914fc", |
| 119 | "rel": "bookmark" |
| 120 | } |
| 121 | ], |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 122 | "created": "` + timestamp + `", |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 123 | "id": "8367c312-7c40-4a66-aab1-5767478914fc", |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 124 | "volume": { |
| 125 | "size": 1 |
| 126 | }, |
| 127 | "flavor": { |
| 128 | "id": "9" |
| 129 | }, |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 130 | "datastore": { |
| 131 | "version": "5.6", |
| 132 | "type": "mysql" |
| 133 | }, |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 134 | "replica_of": { |
| 135 | "id": "6bdca2fc-418e-40bd-a595-62abda61862d" |
| 136 | } |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 137 | } |
| 138 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 139 | ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 140 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 141 | var listReplicasResp = ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 142 | { |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 143 | "instances": [ |
| 144 | { |
| 145 | "status": "ACTIVE", |
| 146 | "name": "t1s1_ALT_GUEST", |
| 147 | "links": [ |
| 148 | { |
| 149 | "href": "https://ord.databases.api.rackspacecloud.com/v1.0/1234/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254", |
| 150 | "rel": "self" |
| 151 | }, |
| 152 | { |
| 153 | "href": "https://ord.databases.api.rackspacecloud.com/instances/3c691f06-bf9a-4618-b7ec-2817ce0cf254", |
| 154 | "rel": "bookmark" |
| 155 | } |
| 156 | ], |
| 157 | "ip": [ |
| 158 | "10.0.0.3" |
| 159 | ], |
| 160 | "id": "3c691f06-bf9a-4618-b7ec-2817ce0cf254", |
| 161 | "volume": { |
| 162 | "size": 1 |
| 163 | }, |
| 164 | "flavor": { |
| 165 | "id": "9" |
| 166 | }, |
| 167 | "datastore": { |
| 168 | "version": "5.6", |
| 169 | "type": "mysql" |
| 170 | }, |
| 171 | "replica_of": { |
| 172 | "id": "8b499b45-52d6-402d-b398-f9d8f279c69a" |
| 173 | } |
| 174 | } |
| 175 | ] |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 176 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 177 | ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 178 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 179 | var getReplicaResp = ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 180 | { |
| 181 | "instance": { |
| 182 | "status": "ACTIVE", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 183 | "updated": "` + timestamp + `", |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 184 | "name": "t1_ALT_GUEST", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 185 | "created": "` + timestamp + `", |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 186 | "ip": [ |
| 187 | "10.0.0.2" |
| 188 | ], |
| 189 | "replicas": [ |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 190 | { |
| 191 | "id": "3c691f06-bf9a-4618-b7ec-2817ce0cf254" |
| 192 | } |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 193 | ], |
| 194 | "id": "8b499b45-52d6-402d-b398-f9d8f279c69a", |
| 195 | "volume": { |
| 196 | "used": 0.54, |
| 197 | "size": 1 |
| 198 | }, |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 199 | "flavor": { |
| 200 | "id": "9" |
| 201 | }, |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 202 | "datastore": { |
| 203 | "version": "5.6", |
| 204 | "type": "mysql" |
| 205 | } |
| 206 | } |
| 207 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 208 | ` |
| 209 | |
| 210 | var detachReq = ` |
| 211 | { |
| 212 | "instance": { |
| 213 | "replica_of": "", |
| 214 | "slave_of": "" |
| 215 | } |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 216 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 217 | ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 218 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 219 | var getConfigResp = ` |
Jamie Hannaford | 936a547 | 2015-02-10 14:38:28 +0100 | [diff] [blame] | 220 | { |
| 221 | "instance": { |
| 222 | "configuration": { |
| 223 | "basedir": "/usr", |
| 224 | "connect_timeout": "15", |
| 225 | "datadir": "/var/lib/mysql", |
| 226 | "default_storage_engine": "innodb", |
| 227 | "innodb_buffer_pool_instances": "1", |
| 228 | "innodb_buffer_pool_size": "175M", |
| 229 | "innodb_checksum_algorithm": "crc32", |
| 230 | "innodb_data_file_path": "ibdata1:10M:autoextend", |
| 231 | "innodb_file_per_table": "1", |
| 232 | "innodb_io_capacity": "200", |
| 233 | "innodb_log_file_size": "256M", |
| 234 | "innodb_log_files_in_group": "2", |
| 235 | "innodb_open_files": "8192", |
| 236 | "innodb_thread_concurrency": "0", |
| 237 | "join_buffer_size": "1M", |
| 238 | "key_buffer_size": "50M", |
| 239 | "local-infile": "0", |
| 240 | "log-error": "/var/log/mysql/mysqld.log", |
| 241 | "max_allowed_packet": "16M", |
| 242 | "max_connect_errors": "10000", |
| 243 | "max_connections": "40", |
| 244 | "max_heap_table_size": "16M", |
| 245 | "myisam-recover": "BACKUP", |
| 246 | "open_files_limit": "8192", |
| 247 | "performance_schema": "off", |
| 248 | "pid_file": "/var/run/mysqld/mysqld.pid", |
| 249 | "port": "3306", |
| 250 | "query_cache_limit": "1M", |
| 251 | "query_cache_size": "8M", |
| 252 | "query_cache_type": "1", |
| 253 | "read_buffer_size": "256K", |
| 254 | "read_rnd_buffer_size": "1M", |
| 255 | "server_id": "1", |
| 256 | "skip-external-locking": "1", |
| 257 | "skip_name_resolve": "1", |
| 258 | "sort_buffer_size": "256K", |
| 259 | "table_open_cache": "4096", |
| 260 | "thread_stack": "192K", |
| 261 | "tmp_table_size": "16M", |
| 262 | "tmpdir": "/var/tmp", |
| 263 | "user": "mysql", |
| 264 | "wait_timeout": "3600" |
| 265 | } |
| 266 | } |
| 267 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 268 | ` |
Jamie Hannaford | f77fc10 | 2015-02-10 14:56:02 +0100 | [diff] [blame] | 269 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 270 | var associateReq = `{"instance": {"configuration": "{configGroupID}"}}` |
Jamie Hannaford | f77fc10 | 2015-02-10 14:56:02 +0100 | [diff] [blame] | 271 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 272 | var listBackupsResp = ` |
Jamie Hannaford | 2e81732 | 2015-02-16 15:29:17 +0100 | [diff] [blame] | 273 | { |
| 274 | "backups": [ |
| 275 | { |
| 276 | "status": "COMPLETED", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 277 | "updated": "` + timestamp + `", |
Jamie Hannaford | 2e81732 | 2015-02-16 15:29:17 +0100 | [diff] [blame] | 278 | "description": "Backup from Restored Instance", |
| 279 | "datastore": { |
| 280 | "version": "5.1", |
| 281 | "type": "MySQL", |
| 282 | "version_id": "20000000-0000-0000-0000-000000000002" |
| 283 | }, |
| 284 | "id": "87972694-4be2-40f5-83f8-501656e0032a", |
| 285 | "size": 0.141026, |
| 286 | "name": "restored_backup", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 287 | "created": "` + timestamp + `", |
Jamie Hannaford | 2e81732 | 2015-02-16 15:29:17 +0100 | [diff] [blame] | 288 | "instance_id": "29af2cd9-0674-48ab-b87a-b160f00208e6", |
| 289 | "parent_id": null, |
| 290 | "locationRef": "http://localhost/path/to/backup" |
| 291 | } |
| 292 | ] |
| 293 | } |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 294 | ` |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 295 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 296 | var ( |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 297 | createResp = fmt.Sprintf(`{"instance":%s}`, instance) |
| 298 | getResp = fmt.Sprintf(`{"instance":%s}`, instance) |
| 299 | associateResp = fmt.Sprintf(`{"instance":%s}`, instance) |
| 300 | listInstancesResp = fmt.Sprintf(`{"instances":[%s]}`, instance) |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 301 | ) |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 302 | |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 303 | var instanceID = "{instanceID}" |
| 304 | |
| 305 | var expectedInstance = &Instance{ |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 306 | Created: timeVal, |
| 307 | Updated: timeVal, |
Jamie Hannaford | 7274916 | 2015-10-14 12:14:32 +0200 | [diff] [blame] | 308 | Datastore: datastores.DatastorePartial{Type: "mysql", Version: "5.6"}, |
| 309 | Flavor: flavors.Flavor{ |
| 310 | ID: "1", |
| 311 | Links: []gophercloud.Link{ |
| 312 | gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "self"}, |
| 313 | gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "bookmark"}, |
| 314 | }, |
| 315 | }, |
| 316 | Hostname: "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com", |
| 317 | ID: instanceID, |
| 318 | Links: []gophercloud.Link{ |
| 319 | gophercloud.Link{Href: "https://ord.databases.api.rackspacecloud.com/v1.0/1234/flavors/1", Rel: "self"}, |
| 320 | }, |
| 321 | Name: "json_rack_instance", |
| 322 | Status: "BUILD", |
| 323 | Volume: os.Volume{Size: 2}, |
| 324 | } |
| 325 | |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 326 | var expectedReplica = &Instance{ |
| 327 | Status: "BUILD", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 328 | Updated: timeVal, |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 329 | Name: "t2s1_ALT_GUEST", |
| 330 | Links: []gophercloud.Link{ |
| 331 | gophercloud.Link{Rel: "self", Href: "https://ord.databases.api.rackspacecloud.com/v1.0/5919009/instances/8367c312-7c40-4a66-aab1-5767478914fc"}, |
| 332 | gophercloud.Link{Rel: "bookmark", Href: "https://ord.databases.api.rackspacecloud.com/instances/8367c312-7c40-4a66-aab1-5767478914fc"}, |
| 333 | }, |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 334 | Created: timeVal, |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 335 | ID: "8367c312-7c40-4a66-aab1-5767478914fc", |
| 336 | Volume: os.Volume{Size: 1}, |
Jamie Hannaford | 1110840 | 2015-02-23 10:31:41 +0100 | [diff] [blame] | 337 | Flavor: flavors.Flavor{ID: "9"}, |
Jamie Hannaford | e635b7d | 2015-02-18 14:11:46 +0100 | [diff] [blame] | 338 | Datastore: datastores.DatastorePartial{Version: "5.6", Type: "mysql"}, |
| 339 | ReplicaOf: &Instance{ |
| 340 | ID: "6bdca2fc-418e-40bd-a595-62abda61862d", |
| 341 | }, |
Jamie Hannaford | 4ec6afe | 2015-02-16 16:52:49 +0100 | [diff] [blame] | 342 | } |