jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 1 | package testing |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 2 | |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 3 | import ( |
| 4 | "fmt" |
| 5 | "time" |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 6 | |
| 7 | "github.com/gophercloud/gophercloud/openstack/db/v1/configurations" |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 8 | ) |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 9 | |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 10 | var ( |
| 11 | timestamp = "2015-11-12T14:22:42Z" |
| 12 | timeVal, _ = time.Parse(time.RFC3339, timestamp) |
| 13 | ) |
| 14 | |
| 15 | var singleConfigJSON = ` |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 16 | { |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 17 | "created": "` + timestamp + `", |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 18 | "datastore_name": "mysql", |
| 19 | "datastore_version_id": "b00000b0-00b0-0b00-00b0-000b000000bb", |
| 20 | "datastore_version_name": "5.6", |
| 21 | "description": "example_description", |
| 22 | "id": "005a8bb7-a8df-40ee-b0b7-fc144641abc2", |
| 23 | "name": "example-configuration-name", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 24 | "updated": "` + timestamp + `" |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 25 | } |
| 26 | ` |
| 27 | |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 28 | var singleConfigWithValuesJSON = ` |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 29 | { |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 30 | "created": "` + timestamp + `", |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 31 | "datastore_name": "mysql", |
| 32 | "datastore_version_id": "b00000b0-00b0-0b00-00b0-000b000000bb", |
| 33 | "datastore_version_name": "5.6", |
| 34 | "description": "example description", |
| 35 | "id": "005a8bb7-a8df-40ee-b0b7-fc144641abc2", |
| 36 | "instance_count": 0, |
| 37 | "name": "example-configuration-name", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 38 | "updated": "` + timestamp + `", |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 39 | "values": { |
| 40 | "collation_server": "latin1_swedish_ci", |
| 41 | "connect_timeout": 120 |
| 42 | } |
| 43 | } |
| 44 | ` |
| 45 | |
| 46 | var ( |
Jamie Hannaford | d2b755f | 2015-10-07 14:01:57 +0200 | [diff] [blame] | 47 | ListConfigsJSON = fmt.Sprintf(`{"configurations": [%s]}`, singleConfigJSON) |
| 48 | GetConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigJSON) |
| 49 | CreateConfigJSON = fmt.Sprintf(`{"configuration": %s}`, singleConfigWithValuesJSON) |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 50 | ) |
| 51 | |
Jamie Hannaford | d2b755f | 2015-10-07 14:01:57 +0200 | [diff] [blame] | 52 | var CreateReq = ` |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 53 | { |
| 54 | "configuration": { |
| 55 | "datastore": { |
| 56 | "type": "a00000a0-00a0-0a00-00a0-000a000000aa", |
| 57 | "version": "b00000b0-00b0-0b00-00b0-000b000000bb" |
| 58 | }, |
| 59 | "description": "example description", |
| 60 | "name": "example-configuration-name", |
| 61 | "values": { |
| 62 | "collation_server": "latin1_swedish_ci", |
| 63 | "connect_timeout": 120 |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | ` |
| 68 | |
Jamie Hannaford | d2b755f | 2015-10-07 14:01:57 +0200 | [diff] [blame] | 69 | var UpdateReq = ` |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 70 | { |
| 71 | "configuration": { |
| 72 | "values": { |
| 73 | "connect_timeout": 300 |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | ` |
| 78 | |
Jamie Hannaford | d2b755f | 2015-10-07 14:01:57 +0200 | [diff] [blame] | 79 | var ListInstancesJSON = ` |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 80 | { |
| 81 | "instances": [ |
| 82 | { |
| 83 | "id": "d4603f69-ec7e-4e9b-803f-600b9205576f", |
| 84 | "name": "json_rack_instance" |
| 85 | } |
| 86 | ] |
| 87 | } |
| 88 | ` |
| 89 | |
Jamie Hannaford | d2b755f | 2015-10-07 14:01:57 +0200 | [diff] [blame] | 90 | var ListParamsJSON = ` |
Jamie Hannaford | 23867bb | 2015-02-17 15:56:48 +0100 | [diff] [blame] | 91 | { |
| 92 | "configuration-parameters": [ |
| 93 | { |
| 94 | "max": 1, |
| 95 | "min": 0, |
| 96 | "name": "innodb_file_per_table", |
| 97 | "restart_required": true, |
| 98 | "type": "integer" |
| 99 | }, |
| 100 | { |
| 101 | "max": 4294967296, |
| 102 | "min": 0, |
| 103 | "name": "key_buffer_size", |
| 104 | "restart_required": false, |
| 105 | "type": "integer" |
| 106 | }, |
| 107 | { |
| 108 | "max": 65535, |
| 109 | "min": 2, |
| 110 | "name": "connect_timeout", |
| 111 | "restart_required": false, |
| 112 | "type": "integer" |
| 113 | }, |
| 114 | { |
| 115 | "max": 4294967296, |
| 116 | "min": 0, |
| 117 | "name": "join_buffer_size", |
| 118 | "restart_required": false, |
| 119 | "type": "integer" |
| 120 | } |
| 121 | ] |
| 122 | } |
| 123 | ` |
| 124 | |
Jamie Hannaford | d2b755f | 2015-10-07 14:01:57 +0200 | [diff] [blame] | 125 | var GetParamJSON = ` |
Jamie Hannaford | 23867bb | 2015-02-17 15:56:48 +0100 | [diff] [blame] | 126 | { |
| 127 | "max": 1, |
| 128 | "min": 0, |
| 129 | "name": "innodb_file_per_table", |
| 130 | "restart_required": true, |
| 131 | "type": "integer" |
| 132 | } |
| 133 | ` |
| 134 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 135 | var ExampleConfig = configurations.Config{ |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 136 | Created: timeVal, |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 137 | DatastoreName: "mysql", |
| 138 | DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb", |
| 139 | DatastoreVersionName: "5.6", |
| 140 | Description: "example_description", |
| 141 | ID: "005a8bb7-a8df-40ee-b0b7-fc144641abc2", |
| 142 | Name: "example-configuration-name", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 143 | Updated: timeVal, |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 144 | } |
| 145 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 146 | var ExampleConfigWithValues = configurations.Config{ |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 147 | Created: timeVal, |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 148 | DatastoreName: "mysql", |
| 149 | DatastoreVersionID: "b00000b0-00b0-0b00-00b0-000b000000bb", |
| 150 | DatastoreVersionName: "5.6", |
| 151 | Description: "example description", |
| 152 | ID: "005a8bb7-a8df-40ee-b0b7-fc144641abc2", |
| 153 | Name: "example-configuration-name", |
Jamie Hannaford | e65ad95 | 2015-11-16 14:05:11 +0100 | [diff] [blame] | 154 | Updated: timeVal, |
Jamie Hannaford | ed7f453 | 2015-02-17 14:56:30 +0100 | [diff] [blame] | 155 | Values: map[string]interface{}{ |
| 156 | "collation_server": "latin1_swedish_ci", |
| 157 | "connect_timeout": 120, |
| 158 | }, |
| 159 | } |