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