From 020f5619a16ed468fca88c985a9e743823564a76 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Thu, 2 Apr 2020 09:52:30 -0400 Subject: [PATCH 1/2] Fix make sanitize --- Makefile | 6 +- test/integration/fixtures/TestListEvents.yaml | 10 +-- .../fixtures/TestListFirewalls.yaml | 72 +++++++++---------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index 065a1ad35..2e10984c7 100644 --- a/Makefile +++ b/Makefile @@ -53,8 +53,8 @@ run_fixtures: sanitize: @echo "* Sanitizing fixtures" - @for yaml in fixtures/*yaml; do \ - sed -E -i.bak -e "s/$(LINODE_TOKEN)/awesometokenawesometokenawesometoken/g" \ + @for yaml in test/integration/fixtures/*yaml; do \ + sed -E -i.bak \ -e 's_stats/20[0-9]{2}/[1-9][0-2]?_stats/2018/1_g' \ -e 's/20[0-9]{2}-[01][0-9]-[0-3][0-9]T[0-2][0-9]:[0-9]{2}:[0-9]{2}/2018-01-02T03:04:05/g' \ -e 's/nb-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}\./nb-10-20-30-40./g' \ @@ -63,7 +63,7 @@ sanitize: -e 's/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/1234::5678/g' \ $$yaml; \ done - @find fixtures -name *yaml.bak -exec rm {} \; + @find test/integration/fixtures -name *yaml.bak -exec rm {} \; fixtures: run_fixtures sanitize diff --git a/test/integration/fixtures/TestListEvents.yaml b/test/integration/fixtures/TestListEvents.yaml index 6375f65e1..87836e8e1 100644 --- a/test/integration/fixtures/TestListEvents.yaml +++ b/test/integration/fixtures/TestListEvents.yaml @@ -15,8 +15,8 @@ interactions: method: POST response: body: '{"id": 19967871, "label": "linodego-test-instance", "group": "", "status": - "provisioning", "created": "2020-04-01T15:14:50", "updated": "2020-04-01T15:14:50", - "type": "g6-nanode-1", "ipv4": ["45.33.51.250"], "ipv6": "2600:3c01::f03c:92ff:fe60:c1b2/64", + "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["10.20.30.40"], "ipv6": "1234::5678/64", "image": "linode/debian9", "region": "us-west", "specs": {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000}, "backups": {"enabled": @@ -91,7 +91,7 @@ interactions: body: '{"id": 21348302, "label": "linodego-test-config", "helpers": {"updatedb_disabled": true, "distro": true, "modules_dep": true, "network": true, "devtmpfs_automount": true}, "kernel": "linode/latest-64bit", "comments": "", "memory_limit": 0, "created": - "2020-04-01T15:14:51", "updated": "2020-04-01T15:14:51", "root_device": "/dev/sda", + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "root_device": "/dev/sda", "devices": {"sda": null, "sdb": null, "sdc": null, "sdd": null, "sde": null, "sdf": null, "sdg": null, "sdh": null}, "initrd": null, "run_level": "default", "virt_mode": "paravirt"}' @@ -163,14 +163,14 @@ interactions: url: https://api.linode.com/v4beta/account/events method: GET response: - body: '{"data": [{"id": 79166449, "created": "2020-04-01T15:14:51", "seen": false, + body: '{"data": [{"id": 79166449, "created": "2018-01-02T03:04:05", "seen": false, "read": false, "percent_complete": null, "time_remaining": null, "rate": null, "duration": null, "action": "linode_config_create", "username": "pccampbell", "entity": {"label": "linodego-test-instance", "id": 19967871, "type": "linode", "url": "/v4/linode/instances/19967871"}, "status": "notification", "secondary_entity": {"id": 21348302, "type": "linode_config", "label": "linodego-test-config", "url": "/v4/linode/instances/19967871/configs/21348302"}}, {"id": 79166446, "created": - "2020-04-01T15:14:51", "seen": false, "read": false, "percent_complete": 0, + "2018-01-02T03:04:05", "seen": false, "read": false, "percent_complete": 0, "time_remaining": null, "rate": null, "duration": null, "action": "linode_create", "username": "pccampbell", "entity": {"label": "linodego-test-instance", "id": 19967871, "type": "linode", "url": "/v4/linode/instances/19967871"}, "status": diff --git a/test/integration/fixtures/TestListFirewalls.yaml b/test/integration/fixtures/TestListFirewalls.yaml index 343a97823..148ca76ab 100644 --- a/test/integration/fixtures/TestListFirewalls.yaml +++ b/test/integration/fixtures/TestListFirewalls.yaml @@ -2,7 +2,7 @@ version: 1 interactions: - request: - body: '{"label":"a83ef3go2h76-linodego-testing","rules":{"inbound":[{"ports":"22","protocol":"TCP","addresses":{"ipv4":["0.0.0.0/0"],"ipv6":["::0/0"]}}],"outbound":[{"ports":"22","protocol":"TCP","addresses":{"ipv4":["0.0.0.0/0"],"ipv6":["::0/0"]}}]},"tags":["testing"],"devices":{}}' + body: '{"label":"a83ef3go2h76-linodego-testing","rules":{"inbound":[{"ports":"22","protocol":"TCP","addresses":{"ipv4":["10.20.30.40/0"],"ipv6":["1234::5678/0"]}}],"outbound":[{"ports":"22","protocol":"TCP","addresses":{"ipv4":["10.20.30.40/0"],"ipv6":["1234::5678/0"]}}]},"tags":["testing"],"devices":{}}' form: {} headers: Accept: @@ -14,11 +14,11 @@ interactions: url: https://api.linode.com/v4beta/networking/firewalls method: POST response: - body: '{"id": 37, "label": "a83ef3go2h76-linodego-testing", "created": "2020-02-19T19:38:16", - "updated": "2020-02-19T19:38:16", "status": "enabled", "rules": {"inbound": - [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": - ["::0/0"]}}], "outbound": [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": - ["0.0.0.0/0"], "ipv6": ["::0/0"]}}]}, "tags": ["testing"]}' + body: '{"id": 37, "label": "a83ef3go2h76-linodego-testing", "created": "2018-01-02T03:04:05", + "updated": "2018-01-02T03:04:05", "status": "enabled", "rules": {"inbound": + [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": + ["1234::5678/0"]}}], "outbound": [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": + ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}]}, "tags": ["testing"]}' headers: Access-Control-Allow-Credentials: - "true" @@ -85,39 +85,39 @@ interactions: url: https://api.linode.com/v4beta/networking/firewalls method: GET response: - body: '{"data": [{"id": 19, "label": "firewall19", "created": "2020-02-10T22:24:05", - "updated": "2020-02-10T22:24:05", "status": "disabled", "rules": {"inbound": - [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": ["172.104.2.4"]}}]}, - "tags": []}, {"id": 20, "label": "firewall20", "created": "2020-02-11T14:48:23", - "updated": "2020-02-11T14:48:23", "status": "disabled", "rules": {"inbound": - [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": ["172.104.2.4"]}}]}, - "tags": []}, {"id": 31, "label": "firewall31", "created": "2020-02-14T22:31:45", - "updated": "2020-02-14T22:31:45", "status": "disabled", "rules": {"inbound": - [{"ports": "3306", "protocol": "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": - ["::0/0"]}}], "outbound": [{"ports": "3306", "protocol": "TCP", "addresses": - {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}]}, "tags": []}, {"id": 32, "label": - "blah", "created": "2020-02-19T15:36:40", "updated": "2020-02-19T15:36:40", + body: '{"data": [{"id": 19, "label": "firewall19", "created": "2018-01-02T03:04:05", + "updated": "2018-01-02T03:04:05", "status": "disabled", "rules": {"inbound": + [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40"]}}]}, + "tags": []}, {"id": 20, "label": "firewall20", "created": "2018-01-02T03:04:05", + "updated": "2018-01-02T03:04:05", "status": "disabled", "rules": {"inbound": + [{"ports": "22", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40"]}}]}, + "tags": []}, {"id": 31, "label": "firewall31", "created": "2018-01-02T03:04:05", + "updated": "2018-01-02T03:04:05", "status": "disabled", "rules": {"inbound": + [{"ports": "3306", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": + ["1234::5678/0"]}}], "outbound": [{"ports": "3306", "protocol": "TCP", "addresses": + {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}]}, "tags": []}, {"id": 32, "label": + "blah", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "status": "enabled", "rules": {"inbound": [{"ports": "80", "protocol": "TCP", - "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}, {"ports": "443", "protocol": - "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}], "outbound": - [{"ports": "80", "protocol": "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": - ["::0/0"]}}, {"ports": "443", "protocol": "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], - "ipv6": ["::0/0"]}}]}, "tags": []}, {"id": 33, "label": "test-firewall", "created": - "2020-02-19T17:45:58", "updated": "2020-02-19T17:45:58", "status": "enabled", + "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}, {"ports": "443", "protocol": + "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}], "outbound": + [{"ports": "80", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": + ["1234::5678/0"]}}, {"ports": "443", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], + "ipv6": ["1234::5678/0"]}}]}, "tags": []}, {"id": 33, "label": "test-firewall", "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "status": "enabled", "rules": {"inbound": [{"ports": "80", "protocol": "TCP", "addresses": {"ipv4": - ["0.0.0.0/0"], "ipv6": ["::0/0"]}}, {"ports": "443", "protocol": "TCP", "addresses": - {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}], "outbound": [{"ports": "80", "protocol": - "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}, {"ports": "443", - "protocol": "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}]}, - "tags": []}, {"id": 34, "label": "asdf", "created": "2020-02-19T18:03:47", "updated": - "2020-02-19T18:03:47", "status": "disabled", "rules": {"inbound": [{"ports": - "443", "protocol": "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}], - "outbound": [{"ports": "443", "protocol": "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], - "ipv6": ["::0/0"]}}]}, "tags": []}, {"id": 37, "label": "a83ef3go2h76-linodego-testing", - "created": "2020-02-19T19:38:17", "updated": "2020-02-19T19:38:17", "status": + ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}, {"ports": "443", "protocol": "TCP", "addresses": + {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}], "outbound": [{"ports": "80", "protocol": + "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}, {"ports": "443", + "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}]}, + "tags": []}, {"id": 34, "label": "asdf", "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05", "status": "disabled", "rules": {"inbound": [{"ports": + "443", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}], + "outbound": [{"ports": "443", "protocol": "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], + "ipv6": ["1234::5678/0"]}}]}, "tags": []}, {"id": 37, "label": "a83ef3go2h76-linodego-testing", + "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "status": "enabled", "rules": {"inbound": [{"ports": "22", "protocol": "TCP", "addresses": - {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}], "outbound": [{"ports": "22", "protocol": - "TCP", "addresses": {"ipv4": ["0.0.0.0/0"], "ipv6": ["::0/0"]}}]}, "tags": ["testing"]}], + {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}], "outbound": [{"ports": "22", "protocol": + "TCP", "addresses": {"ipv4": ["10.20.30.40/0"], "ipv6": ["1234::5678/0"]}}]}, "tags": ["testing"]}], "page": 1, "pages": 1, "results": 7}' headers: Access-Control-Allow-Credentials: From 585a0ae58d86ceb3d494194c1bdd2c7e9fa94ec7 Mon Sep 17 00:00:00 2001 From: phillc <15082+phillc@users.noreply.github.com> Date: Thu, 2 Apr 2020 09:34:59 -0400 Subject: [PATCH 2/2] InstanceRebuildOptions no longer requires all fields to be specified --- instances.go | 14 +- .../fixtures/TestRebuildInstance.yaml | 373 ++++++++++++++++++ test/integration/instances_test.go | 25 ++ 3 files changed, 405 insertions(+), 7 deletions(-) create mode 100644 test/integration/fixtures/TestRebuildInstance.yaml diff --git a/instances.go b/instances.go index 77a9def9f..abb807fb5 100644 --- a/instances.go +++ b/instances.go @@ -398,13 +398,13 @@ func (c *Client) RebootInstance(ctx context.Context, id int, configID int) error // InstanceRebuildOptions is a struct representing the options to send to the rebuild linode endpoint type InstanceRebuildOptions struct { - Image string `json:"image"` - RootPass string `json:"root_pass"` - AuthorizedKeys []string `json:"authorized_keys"` - AuthorizedUsers []string `json:"authorized_users"` - StackscriptID int `json:"stackscript_id"` - StackscriptData map[string]string `json:"stackscript_data"` - Booted bool `json:"booted"` + Image string `json:"image,omitempty"` + RootPass string `json:"root_pass,omitempty"` + AuthorizedKeys []string `json:"authorized_keys,omitempty"` + AuthorizedUsers []string `json:"authorized_users,omitempty"` + StackScriptID int `json:"stackscript_id,omitempty"` + StackScriptData map[string]string `json:"stackscript_data,omitempty"` + Booted *bool `json:"booted,omitempty"` } // RebuildInstance Deletes all Disks and Configs on this Linode, diff --git a/test/integration/fixtures/TestRebuildInstance.yaml b/test/integration/fixtures/TestRebuildInstance.yaml new file mode 100644 index 000000000..5cc472be8 --- /dev/null +++ b/test/integration/fixtures/TestRebuildInstance.yaml @@ -0,0 +1,373 @@ +--- +version: 1 +interactions: +- request: + body: '{"region":"us-west","type":"g6-nanode-1","label":"linodego-test-instance-wo-disk","booted":false}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego 0.12.0 https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances + method: POST + response: + body: '{"id": 19977966, "label": "linodego-test-instance-wo-disk", "group": "", + "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["10.20.30.40"], "ipv6": "1234::5678/64", + "image": null, "region": "us-west", "specs": {"disk": 25600, "memory": 1024, + "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu": 90, "network_in": + 10, "network_out": 10, "transfer_quota": 80, "io": 10000}, "backups": {"enabled": + false, "schedule": {"day": null, "window": null}, "last_successful": null}, + "hypervisor": "kvm", "watchdog_enabled": true, "tags": []}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "632" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Date: + - Thu, 02 Apr 2020 13:34:23 GMT + Retry-After: + - "80" + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Ratelimit-Remaining: + - "1584" + X-Ratelimit-Reset: + - "1585834544" + X-Spec-Version: + - 4.60.0 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"linodego-test-config","devices":{}}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego 0.12.0 https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/19977966/configs + method: POST + response: + body: '{"id": 21359003, "label": "linodego-test-config", "helpers": {"updatedb_disabled": + true, "distro": true, "modules_dep": true, "network": true, "devtmpfs_automount": + true}, "kernel": "linode/latest-64bit", "comments": "", "memory_limit": 0, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "root_device": "/dev/sda", + "devices": {"sda": null, "sdb": null, "sdc": null, "sdd": null, "sde": null, + "sdf": null, "sdg": null, "sdh": null}, "initrd": null, "run_level": "default", + "virt_mode": "paravirt"}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "516" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Date: + - Thu, 02 Apr 2020 13:34:24 GMT + Retry-After: + - "80" + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Ratelimit-Remaining: + - "1583" + X-Ratelimit-Reset: + - "1585834545" + X-Spec-Version: + - 4.60.0 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego 0.12.0 https://github.com/linode/linodego + X-Filter: + - '{"+order":"desc","+order_by":"created","entity.id":19977966,"entity.type":"linode","seen":false}' + url: https://api.linode.com/v4beta/account/events?page=1 + method: GET + response: + body: '{"data": [{"id": 79314392, "created": "2018-01-02T03:04:05", "seen": false, + "read": false, "percent_complete": null, "time_remaining": null, "rate": null, + "duration": null, "action": "linode_config_create", "username": "pccampbell", + "entity": {"label": "linodego-test-instance-wo-disk", "id": 19977966, "type": + "linode", "url": "/v4/linode/instances/19977966"}, "status": "notification", + "secondary_entity": {"id": 21359003, "type": "linode_config", "label": "linodego-test-config", + "url": "/v4/linode/instances/19977966/configs/21359003"}}, {"id": 79314390, + "created": "2018-01-02T03:04:05", "seen": false, "read": false, "percent_complete": + 100, "time_remaining": 0, "rate": null, "duration": 5.0, "action": "linode_create", + "username": "pccampbell", "entity": {"label": "linodego-test-instance-wo-disk", + "id": 19977966, "type": "linode", "url": "/v4/linode/instances/19977966"}, "status": + "finished", "secondary_entity": null}], "page": 1, "pages": 1, "results": 2}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=0, s-maxage=0, no-cache, no-store + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "968" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Date: + - Thu, 02 Apr 2020 13:34:39 GMT + Retry-After: + - "64" + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - events:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Ratelimit-Remaining: + - "1582" + X-Ratelimit-Reset: + - "1585834544" + X-Spec-Version: + - 4.60.0 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"image":"linode/alpine3.11","root_pass":"R34lBAdP455"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego 0.12.0 https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/19977966/rebuild + method: POST + response: + body: '{"id": 19977966, "label": "linodego-test-instance-wo-disk", "group": "", + "status": "rebuilding", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["10.20.30.40"], "ipv6": "1234::5678/64", + "image": "linode/alpine3.11", "region": "us-west", "specs": {"disk": 25600, + "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu": + 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000}, + "backups": {"enabled": false, "schedule": {"day": null, "window": null}, "last_successful": + null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": []}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "645" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Date: + - Thu, 02 Apr 2020 13:34:40 GMT + Retry-After: + - "64" + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Ratelimit-Remaining: + - "1581" + X-Ratelimit-Reset: + - "1585834545" + X-Spec-Version: + - 4.60.0 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego 0.12.0 https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/19977966 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - private, max-age=60, s-maxage=60 + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Date: + - Thu, 02 Apr 2020 13:34:40 GMT + Retry-After: + - "63" + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "1600" + X-Ratelimit-Remaining: + - "1580" + X-Ratelimit-Reset: + - "1585834544" + X-Spec-Version: + - 4.60.0 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/instances_test.go b/test/integration/instances_test.go index c805539d0..0d91e6261 100644 --- a/test/integration/instances_test.go +++ b/test/integration/instances_test.go @@ -289,6 +289,31 @@ func TestListInstanceVolumes(t *testing.T) { } } +func TestRebuildInstance(t *testing.T) { + client, instance, _, teardown, err := setupInstanceWithoutDisks(t, "fixtures/TestRebuildInstance") + defer teardown() + + if err != nil { + t.Error(err) + } + + _, err = client.WaitForEventFinished(context.Background(), instance.ID, linodego.EntityLinode, linodego.ActionLinodeCreate, *instance.Created, 180) + + if err != nil { + t.Errorf("Error waiting for instance created: %s", err) + } + + rebuildOpts := linodego.InstanceRebuildOptions{ + Image: "linode/alpine3.11", + RootPass: "R34lBAdP455", + } + instance, err = client.RebuildInstance(context.Background(), instance.ID, rebuildOpts) + + if err != nil { + t.Error(err) + } +} + func setupInstance(t *testing.T, fixturesYaml string) (*linodego.Client, *linodego.Instance, func(), error) { if t != nil { t.Helper()