From 0abbb6d743f675f6fed42caed460fed1f009f4b3 Mon Sep 17 00:00:00 2001 From: Gemma Hou Date: Mon, 18 Mar 2024 17:08:18 +0000 Subject: [PATCH] replay --- config/tests/samples/create/harness.go | 12 +- go.mod | 2 +- go.sum | 2 + ...AllInSeries_fixtures_computenodegroup.seed | 1 + ...AllInSeries_fixtures_computenodegroup.yaml | 1032 +++++++++++++++++ ...InSeries_fixtures_computenodetemplate.seed | 1 + ...InSeries_fixtures_computenodetemplate.yaml | 106 +- tests/e2e/unified_test.go | 59 +- 8 files changed, 1157 insertions(+), 58 deletions(-) create mode 100644 pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.seed create mode 100644 pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.yaml create mode 100644 pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.seed diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index 20f343a90d..350c29e8f5 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -312,6 +312,16 @@ func NewHarness(ctx context.Context, t *testing.T) *Harness { } if targetGCP := os.Getenv("E2E_GCP_TARGET"); targetGCP == "vcr" { + // Initialize VCR for TF requests + input := os.Getenv("VCR_MODE") + var VCRMode recorder.Mode + if input == "recording" { + VCRMode = recorder.ModeRecordOnly + } else if input == "replaying" { + VCRMode = recorder.ModeReplayOnly + } else { + t.Fatalf("[VCR] Input mode is not supported.") + } transport_tpg.DefaultHTTPClientTransformer = func(ctx context.Context, inner *http.Client) *http.Client { ret := inner if t := ctx.Value(httpRoundTripperKey); t != nil { @@ -321,7 +331,7 @@ func NewHarness(ctx context.Context, t *testing.T) *Harness { testName := strings.ReplaceAll(t.Name(), "/", "_") opts := &recorder.Options{ CassetteName: filepath.Join(dir, testName), - Mode: recorder.ModeRecordOnly, + Mode: VCRMode, RealTransport: ret.Transport, } r, err := recorder.NewWithOptions(opts) diff --git a/go.mod b/go.mod index d867d1c458..30389664df 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/time v0.5.0 google.golang.org/api v0.160.0 - google.golang.org/protobuf v1.32.0 + google.golang.org/protobuf v1.33.0 gopkg.in/dnaeon/go-vcr.v3 v3.2.0 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.27.11 diff --git a/go.sum b/go.sum index 4c33ac7dc5..daf1d0235a 100644 --- a/go.sum +++ b/go.sum @@ -1465,6 +1465,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.seed b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.seed new file mode 100644 index 0000000000..97668609be --- /dev/null +++ b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.seed @@ -0,0 +1 @@ +3476787804606094540 \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.yaml b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.yaml new file mode 100644 index 0000000000..dbfe7a109d --- /dev/null +++ b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodegroup.yaml @@ -0,0 +1,1032 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "error": { + "code": 404, + "message": "The resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4' was not found", + "errors": [ + { + "message": "The resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4' was not found", + "domain": "global", + "reason": "notFound", + "debugInfo": "fake debug info" + } + ] + } + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 404 Not Found + code: 404 + duration: 250.784193ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 249 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: | + {"cpuOvercommitType":"NONE","name":"computenodetemplate-1lw6j5242jzz4","nodeAffinityLabels":{"cnrm-test":"true","managed-by-cnrm":"true"},"nodeTypeFlexibility":{"cpus":"any","memory":"any"},"region":"projects/cnrm-user/global/regions/us-central1"} + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates?alt=json + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#operation", + "id": "1372874681422749413", + "name": "operation-1710825482341-613fc9925cd19-fc7fd665-bb53daee", + "operationType": "compute.nodeTemplates.insert", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "targetId": "378601877091426021", + "status": "RUNNING", + "user": "user@google.com", + "progress": 0, + "insertTime": "2024-03-18T22:18:02.624-07:00", + "startTime": "2024-03-18T22:18:02.659-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825482341-613fc9925cd19-fc7fd665-bb53daee", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 443.200545ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825482341-613fc9925cd19-fc7fd665-bb53daee?alt=json&prettyPrint=false + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"kind":"compute#operation","id":"1372874681422749413","name":"operation-1710825482341-613fc9925cd19-fc7fd665-bb53daee","operationType":"compute.nodeTemplates.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4","targetId":"378601877091426021","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-18T22:18:02.624-07:00","startTime":"2024-03-18T22:18:02.659-07:00","endTime":"2024-03-18T22:18:02.975-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825482341-613fc9925cd19-fc7fd665-bb53daee","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 147.756008ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeTemplate", + "id": "378601877091426021", + "creationTimestamp": "2024-03-18T22:18:02.633-07:00", + "name": "computenodetemplate-1lw6j5242jzz4", + "nodeAffinityLabels": { + "managed-by-cnrm": "true", + "cnrm-test": "true" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "nodeTypeFlexibility": { + "cpus": "any", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 118.605713ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeTemplate", + "id": "378601877091426021", + "creationTimestamp": "2024-03-18T22:18:02.633-07:00", + "name": "computenodetemplate-1lw6j5242jzz4", + "nodeAffinityLabels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "nodeTypeFlexibility": { + "cpus": "any", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 125.814072ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "error": { + "code": 404, + "message": "The resource 'projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4' was not found", + "errors": [ + { + "message": "The resource 'projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4' was not found", + "domain": "global", + "reason": "notFound", + "debugInfo": "fake debug info" + } + ] + } + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 404 Not Found + code: 404 + duration: 303.689095ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 311 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: | + {"description":"A single sole-tenant node in the us-central1-b zone.","maintenancePolicy":"DEFAULT","name":"computenodegroup-1lw6j5242jzz4","nodeTemplate":"projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4","size":1,"zone":"projects/cnrm-user/global/zones/us-central1-b"} + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups?alt=json&initialNodeCount=1 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#operation", + "id": "622352768766877411", + "name": "operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb", + "zone": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b", + "operationType": "compute.nodeGroups.insert", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4", + "targetId": "8712311562164281059", + "status": "RUNNING", + "user": "user@google.com", + "progress": 0, + "insertTime": "2024-03-18T22:18:04.752-07:00", + "startTime": "2024-03-18T22:18:04.811-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 551.580309ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb?alt=json&prettyPrint=false + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"kind":"compute#operation","id":"622352768766877411","name":"operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb","zone":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b","operationType":"compute.nodeGroups.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4","targetId":"8712311562164281059","status":"RUNNING","user":"user@google.com","progress":0,"insertTime":"2024-03-18T22:18:04.752-07:00","startTime":"2024-03-18T22:18:04.811-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb"}' + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 154.887688ms + - id: 8 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb?alt=json&prettyPrint=false + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"kind":"compute#operation","id":"622352768766877411","name":"operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb","zone":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b","operationType":"compute.nodeGroups.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4","targetId":"8712311562164281059","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-18T22:18:04.752-07:00","startTime":"2024-03-18T22:18:04.811-07:00","endTime":"2024-03-18T22:18:12.361-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825484382-613fc9944ef9e-f8acf076-1d2534bb"}' + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 152.968858ms + - id: 9 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeGroup", + "id": "8712311562164281059", + "creationTimestamp": "2024-03-18T22:18:04.767-07:00", + "name": "computenodegroup-1lw6j5242jzz4", + "description": "A single sole-tenant node in the us-central1-b zone.", + "nodeTemplate": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "zone": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4", + "status": "READY", + "size": 1, + "autoscalingPolicy": { + "mode": "OFF", + "minNodes": 0 + }, + "maintenancePolicy": "DEFAULT", + "fingerprint": "LSmS6Zp3fxc=", + "shareSettings": { + "shareType": "LOCAL" + }, + "maintenanceInterval": "AS_NEEDED" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 150.337348ms + - id: 10 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeGroup", + "id": "8712311562164281059", + "creationTimestamp": "2024-03-18T22:18:04.767-07:00", + "name": "computenodegroup-1lw6j5242jzz4", + "description": "A single sole-tenant node in the us-central1-b zone.", + "nodeTemplate": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "zone": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4", + "status": "READY", + "size": 1, + "autoscalingPolicy": { + "mode": "OFF", + "minNodes": 0 + }, + "maintenancePolicy": "DEFAULT", + "fingerprint": "LSmS6Zp3fxc=", + "shareSettings": { + "shareType": "LOCAL" + }, + "maintenanceInterval": "AS_NEEDED" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 171.652405ms + - id: 11 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeTemplate", + "id": "378601877091426021", + "creationTimestamp": "2024-03-18T22:18:02.633-07:00", + "name": "computenodetemplate-1lw6j5242jzz4", + "nodeAffinityLabels": { + "managed-by-cnrm": "true", + "cnrm-test": "true" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "nodeTypeFlexibility": { + "cpus": "any", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 179.659883ms + - id: 12 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeGroup", + "id": "8712311562164281059", + "creationTimestamp": "2024-03-18T22:18:04.767-07:00", + "name": "computenodegroup-1lw6j5242jzz4", + "description": "A single sole-tenant node in the us-central1-b zone.", + "nodeTemplate": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "zone": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4", + "status": "READY", + "size": 1, + "autoscalingPolicy": { + "mode": "OFF", + "minNodes": 0 + }, + "maintenancePolicy": "DEFAULT", + "fingerprint": "LSmS6Zp3fxc=", + "shareSettings": { + "shareType": "LOCAL" + }, + "maintenanceInterval": "AS_NEEDED" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 179.894403ms + - id: 13 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "error": { + "code": 400, + "message": "The node_template resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4' is already being used by 'projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4'", + "errors": [ + { + "message": "The node_template resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4' is already being used by 'projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4'", + "domain": "global", + "reason": "resourceInUseByAnotherResource", + "debugInfo": "fake debug info" + } + ] + } + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 400 Bad Request + code: 400 + duration: 321.124713ms + - id: 14 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4?alt=json + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#operation", + "id": "3758286529640046326", + "name": "operation-1710825497199-613fc9a08823d-31afbd3e-05865717", + "zone": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b", + "operationType": "compute.nodeGroups.delete", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4", + "targetId": "8712311562164281059", + "status": "RUNNING", + "user": "user@google.com", + "progress": 0, + "insertTime": "2024-03-18T22:18:17.469-07:00", + "startTime": "2024-03-18T22:18:17.496-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825497199-613fc9a08823d-31afbd3e-05865717" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 408.04276ms + - id: 15 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825497199-613fc9a08823d-31afbd3e-05865717?alt=json&prettyPrint=false + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"kind":"compute#operation","id":"3758286529640046326","name":"operation-1710825497199-613fc9a08823d-31afbd3e-05865717","zone":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b","operationType":"compute.nodeGroups.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4","targetId":"8712311562164281059","status":"RUNNING","user":"user@google.com","progress":0,"insertTime":"2024-03-18T22:18:17.469-07:00","startTime":"2024-03-18T22:18:17.496-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825497199-613fc9a08823d-31afbd3e-05865717"}' + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 106.236394ms + - id: 16 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeTemplate", + "id": "378601877091426021", + "creationTimestamp": "2024-03-18T22:18:02.633-07:00", + "name": "computenodetemplate-1lw6j5242jzz4", + "nodeAffinityLabels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "nodeTypeFlexibility": { + "cpus": "any", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 156.466977ms + - id: 17 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "error": { + "code": 400, + "message": "The node_template resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4' is already being used by 'projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4'", + "errors": [ + { + "message": "The node_template resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4' is already being used by 'projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4'", + "domain": "global", + "reason": "resourceInUseByAnotherResource", + "debugInfo": "fake debug info" + } + ] + } + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 400 Bad Request + code: 400 + duration: 333.344192ms + - id: 18 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#nodeTemplate", + "id": "378601877091426021", + "creationTimestamp": "2024-03-18T22:18:02.633-07:00", + "name": "computenodetemplate-1lw6j5242jzz4", + "nodeAffinityLabels": { + "managed-by-cnrm": "true", + "cnrm-test": "true" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "nodeTypeFlexibility": { + "cpus": "any", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 142.06572ms + - id: 19 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825497199-613fc9a08823d-31afbd3e-05865717?alt=json&prettyPrint=false + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"kind":"compute#operation","id":"3758286529640046326","name":"operation-1710825497199-613fc9a08823d-31afbd3e-05865717","zone":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b","operationType":"compute.nodeGroups.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/nodeGroups/computenodegroup-1lw6j5242jzz4","targetId":"8712311562164281059","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-18T22:18:17.469-07:00","startTime":"2024-03-18T22:18:17.496-07:00","endTime":"2024-03-18T22:18:21.710-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/zones/us-central1-b/operations/operation-1710825497199-613fc9a08823d-31afbd3e-05865717"}' + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 135.10852ms + - id: 20 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4?alt=json + method: DELETE + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: | + { + "kind": "compute#operation", + "id": "5274829315670056651", + "name": "operation-1710825508116-613fc9aaf17e0-85293008-70e4b8e5", + "operationType": "compute.nodeTemplates.delete", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4", + "targetId": "378601877091426021", + "status": "RUNNING", + "user": "user@google.com", + "progress": 0, + "insertTime": "2024-03-18T22:18:28.328-07:00", + "startTime": "2024-03-18T22:18:28.352-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825508116-613fc9aaf17e0-85293008-70e4b8e5", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1" + } + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 357.367868ms + - id: 21 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: compute.googleapis.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825508116-613fc9aaf17e0-85293008-70e4b8e5?alt=json&prettyPrint=false + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"kind":"compute#operation","id":"5274829315670056651","name":"operation-1710825508116-613fc9aaf17e0-85293008-70e4b8e5","operationType":"compute.nodeTemplates.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-1lw6j5242jzz4","targetId":"378601877091426021","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-18T22:18:28.328-07:00","startTime":"2024-03-18T22:18:28.352-07:00","endTime":"2024-03-18T22:18:28.723-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825508116-613fc9aaf17e0-85293008-70e4b8e5","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' + headers: + Content-Type: + - application/json; charset=UTF-8 + status: 200 OK + code: 200 + duration: 124.509172ms diff --git a/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.seed b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.seed new file mode 100644 index 0000000000..ca1f23815c --- /dev/null +++ b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.seed @@ -0,0 +1 @@ +3838530829430228066 \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml index bf1c62a6c0..23fb4e0cc6 100644 --- a/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml +++ b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml @@ -31,7 +31,7 @@ interactions: headers: Content-Type: - application/json - url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111?alt=json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc?alt=json method: GET response: proto: HTTP/2.0 @@ -45,10 +45,10 @@ interactions: { "error": { "code": 404, - "message": "The resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111' was not found", + "message": "The resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc' was not found", "errors": [ { - "message": "The resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111' was not found", + "message": "The resource 'projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc' was not found", "domain": "global", "reason": "notFound", "debugInfo": "fake debug info" @@ -61,20 +61,20 @@ interactions: - application/json; charset=UTF-8 status: 404 Not Found code: 404 - duration: 217.52251ms + duration: 193.443983ms - id: 1 request: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - content_length: 417 + content_length: 409 transfer_encoding: [] trailer: {} host: compute.googleapis.com remote_addr: "" request_uri: "" body: | - {"cpuOvercommitType":"NONE","description":"Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.","name":"computenodetemplate-uniqueid111111","nodeAffinityLabels":{"cnrm-test":"true","managed-by-cnrm":"true","memory_guarantee":"false"},"nodeTypeFlexibility":{"cpus":"96","memory":"any"},"region":"projects/cnrm-user/global/regions/us-central1"} + {"cpuOvercommitType":"NONE","description":"Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.","name":"computenodetemplate-eh8yabhagpgc","nodeAffinityLabels":{"cnrm-test":"true","managed-by-cnrm":"true","memory_guarantee":"false"},"nodeTypeFlexibility":{"cpus":"96","memory":"any"},"region":"projects/cnrm-user/global/regions/us-central1"} form: {} headers: Content-Type: @@ -92,17 +92,17 @@ interactions: body: | { "kind": "compute#operation", - "id": "1302384153447785103", - "name": "operation-1710742623772-613e94e645e42-0e46b5eb-36d6a6e7", + "id": "5449225809889107670", + "name": "operation-1710825528762-613fc9bea1fe3-55490b87-cb1b4ec4", "operationType": "compute.nodeTemplates.insert", - "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111", - "targetId": "1885163588622639759", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc", + "targetId": "2755123117236199126", "status": "RUNNING", "user": "user@google.com", "progress": 0, - "insertTime": "2024-03-17T23:17:04.077-07:00", - "startTime": "2024-03-17T23:17:04.115-07:00", - "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710742623772-613e94e645e42-0e46b5eb-36d6a6e7", + "insertTime": "2024-03-18T22:18:49.005-07:00", + "startTime": "2024-03-18T22:18:49.037-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825528762-613fc9bea1fe3-55490b87-cb1b4ec4", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1" } headers: @@ -110,7 +110,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 474.632907ms + duration: 400.705161ms - id: 2 request: proto: HTTP/1.1 @@ -127,7 +127,7 @@ interactions: headers: X-Goog-Api-Client: - gl-go/1.21.5 gdcl/0.160.0 - url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710742623772-613e94e645e42-0e46b5eb-36d6a6e7?alt=json&prettyPrint=false + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825528762-613fc9bea1fe3-55490b87-cb1b4ec4?alt=json&prettyPrint=false method: GET response: proto: HTTP/2.0 @@ -137,13 +137,13 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"kind":"compute#operation","id":"1302384153447785103","name":"operation-1710742623772-613e94e645e42-0e46b5eb-36d6a6e7","operationType":"compute.nodeTemplates.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111","targetId":"1885163588622639759","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-17T23:17:04.077-07:00","startTime":"2024-03-17T23:17:04.115-07:00","endTime":"2024-03-17T23:17:04.425-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710742623772-613e94e645e42-0e46b5eb-36d6a6e7","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' + body: '{"kind":"compute#operation","id":"5449225809889107670","name":"operation-1710825528762-613fc9bea1fe3-55490b87-cb1b4ec4","operationType":"compute.nodeTemplates.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc","targetId":"2755123117236199126","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-18T22:18:49.005-07:00","startTime":"2024-03-18T22:18:49.037-07:00","endTime":"2024-03-18T22:18:49.286-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825528762-613fc9bea1fe3-55490b87-cb1b4ec4","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' headers: Content-Type: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 154.077924ms + duration: 140.878279ms - id: 3 request: proto: HTTP/1.1 @@ -160,7 +160,7 @@ interactions: headers: Content-Type: - application/json - url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111?alt=json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc?alt=json method: GET response: proto: HTTP/2.0 @@ -173,18 +173,18 @@ interactions: body: | { "kind": "compute#nodeTemplate", - "id": "1885163588622639759", - "creationTimestamp": "2024-03-17T23:17:04.087-07:00", - "name": "computenodetemplate-uniqueid111111", + "id": "2755123117236199126", + "creationTimestamp": "2024-03-18T22:18:49.012-07:00", + "name": "computenodetemplate-eh8yabhagpgc", "description": "Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.", "nodeAffinityLabels": { "memory_guarantee": "false", - "managed-by-cnrm": "true", - "cnrm-test": "true" + "cnrm-test": "true", + "managed-by-cnrm": "true" }, "status": "READY", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", - "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc", "nodeTypeFlexibility": { "cpus": "96", "memory": "any" @@ -199,7 +199,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 250.057884ms + duration: 150.587478ms - id: 4 request: proto: HTTP/1.1 @@ -216,7 +216,7 @@ interactions: headers: Content-Type: - application/json - url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111?alt=json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc?alt=json method: GET response: proto: HTTP/2.0 @@ -229,18 +229,18 @@ interactions: body: | { "kind": "compute#nodeTemplate", - "id": "1885163588622639759", - "creationTimestamp": "2024-03-17T23:17:04.087-07:00", - "name": "computenodetemplate-uniqueid111111", + "id": "2755123117236199126", + "creationTimestamp": "2024-03-18T22:18:49.012-07:00", + "name": "computenodetemplate-eh8yabhagpgc", "description": "Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.", "nodeAffinityLabels": { + "memory_guarantee": "false", "cnrm-test": "true", - "managed-by-cnrm": "true", - "memory_guarantee": "false" + "managed-by-cnrm": "true" }, "status": "READY", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", - "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc", "nodeTypeFlexibility": { "cpus": "96", "memory": "any" @@ -255,7 +255,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 108.804931ms + duration: 151.268778ms - id: 5 request: proto: HTTP/1.1 @@ -272,7 +272,7 @@ interactions: headers: Content-Type: - application/json - url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111?alt=json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc?alt=json method: GET response: proto: HTTP/2.0 @@ -285,18 +285,18 @@ interactions: body: | { "kind": "compute#nodeTemplate", - "id": "1885163588622639759", - "creationTimestamp": "2024-03-17T23:17:04.087-07:00", - "name": "computenodetemplate-uniqueid111111", + "id": "2755123117236199126", + "creationTimestamp": "2024-03-18T22:18:49.012-07:00", + "name": "computenodetemplate-eh8yabhagpgc", "description": "Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.", "nodeAffinityLabels": { + "memory_guarantee": "false", "cnrm-test": "true", - "managed-by-cnrm": "true", - "memory_guarantee": "false" + "managed-by-cnrm": "true" }, "status": "READY", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", - "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc", "nodeTypeFlexibility": { "cpus": "96", "memory": "any" @@ -311,7 +311,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 172.9582ms + duration: 123.055182ms - id: 6 request: proto: HTTP/1.1 @@ -328,7 +328,7 @@ interactions: headers: Content-Type: - application/json - url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111?alt=json + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc?alt=json method: DELETE response: proto: HTTP/2.0 @@ -341,17 +341,17 @@ interactions: body: | { "kind": "compute#operation", - "id": "1935185951732687501", - "name": "operation-1710742626712-613e94e9139de-33ed3c19-1121ea67", + "id": "3629097340760268500", + "name": "operation-1710825530847-613fc9c09ef32-c8cf95aa-6131eb7f", "operationType": "compute.nodeTemplates.delete", - "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111", - "targetId": "1885163588622639759", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc", + "targetId": "2755123117236199126", "status": "RUNNING", "user": "user@google.com", "progress": 0, - "insertTime": "2024-03-17T23:17:06.938-07:00", - "startTime": "2024-03-17T23:17:06.965-07:00", - "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710742626712-613e94e9139de-33ed3c19-1121ea67", + "insertTime": "2024-03-18T22:18:51.095-07:00", + "startTime": "2024-03-18T22:18:51.117-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825530847-613fc9c09ef32-c8cf95aa-6131eb7f", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1" } headers: @@ -359,7 +359,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 363.349932ms + duration: 402.865302ms - id: 7 request: proto: HTTP/1.1 @@ -376,7 +376,7 @@ interactions: headers: X-Goog-Api-Client: - gl-go/1.21.5 gdcl/0.160.0 - url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710742626712-613e94e9139de-33ed3c19-1121ea67?alt=json&prettyPrint=false + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825530847-613fc9c09ef32-c8cf95aa-6131eb7f?alt=json&prettyPrint=false method: GET response: proto: HTTP/2.0 @@ -386,10 +386,10 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"kind":"compute#operation","id":"1935185951732687501","name":"operation-1710742626712-613e94e9139de-33ed3c19-1121ea67","operationType":"compute.nodeTemplates.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111","targetId":"1885163588622639759","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-17T23:17:06.938-07:00","startTime":"2024-03-17T23:17:06.965-07:00","endTime":"2024-03-17T23:17:07.308-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710742626712-613e94e9139de-33ed3c19-1121ea67","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' + body: '{"kind":"compute#operation","id":"3629097340760268500","name":"operation-1710825530847-613fc9c09ef32-c8cf95aa-6131eb7f","operationType":"compute.nodeTemplates.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-eh8yabhagpgc","targetId":"2755123117236199126","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-18T22:18:51.095-07:00","startTime":"2024-03-18T22:18:51.117-07:00","endTime":"2024-03-18T22:18:51.451-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710825530847-613fc9c09ef32-c8cf95aa-6131eb7f","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' headers: Content-Type: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 171.223683ms + duration: 129.001311ms diff --git a/tests/e2e/unified_test.go b/tests/e2e/unified_test.go index dca8fba41e..22509a659a 100644 --- a/tests/e2e/unified_test.go +++ b/tests/e2e/unified_test.go @@ -19,14 +19,17 @@ import ( "context" "encoding/json" "fmt" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" "gopkg.in/dnaeon/go-vcr.v3/cassette" "gopkg.in/dnaeon/go-vcr.v3/recorder" "io" "io/ioutil" "k8s.io/klog/v2" + "math/rand" "net/http" "os" "path/filepath" + "strconv" "strings" "testing" @@ -124,7 +127,10 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testName string, te // TODO(b/259496928): Randomize the resource names for parallel execution when/if needed. t.Run(fixture.Name, func(t *testing.T) { - uniqueID := testvariable.NewUniqueID() + var uniqueID string + if os.Getenv("E2E_GCP_TARGET") != "vcr" { + uniqueID = testvariable.NewUniqueID() + } loadFixture := func(project testgcp.GCPProject) (*unstructured.Unstructured, create.CreateDeleteTestOptions) { primaryResource := bytesToUnstructured(t, fixture.Create, uniqueID, project) @@ -162,6 +168,29 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testName string, te } if os.Getenv("E2E_GCP_TARGET") == "vcr" { + // Handle unique ID in tests by recording & replaying with a same seed, + // so the generated ID is same for certain test. + var seed int64 + var err error + + dir := "pkg/test/resourcefixture/testdata/vcr/cassette/" + name := strings.ReplaceAll(t.Name(), "/", "_") + fileName := filepath.Join(dir, fmt.Sprintf("%s.seed", name)) + + if h.VCRRecorder.Mode() == recorder.ModeRecordOnly { + seed = rand.Int63() + err = writeSeed(seed, fileName) + if err != nil { + t.Errorf("[VCR] Failed write seed: %v", err) + } + } else if h.VCRRecorder.Mode() == recorder.ModeReplayOnly { + seed, err = readSeed(fileName) + if err != nil { + t.Errorf("[VCR] Failed read seed: %v", err) + } + } + r := rand.New(rand.NewSource(seed)) + uniqueID = strconv.FormatUint(r.Uint64(), 36) // Stop recording after tests finish and write to cassette t.Cleanup(func() { err := h.VCRRecorder.Stop() @@ -171,8 +200,7 @@ func testFixturesInSeries(ctx context.Context, t *testing.T, testName string, te }) replaceFunc := func(s string) string { - result := strings.Replace(s, uniqueID, "uniqueid111111", -1) - result = strings.Replace(result, project.ProjectID, "cnrm-user", -1) + result := strings.Replace(s, project.ProjectID, "cnrm-user", -1) return result } @@ -525,3 +553,28 @@ func createPausedCC(ctx context.Context, t *testing.T, c client.Client) { t.Fatalf("error creating CC: %v", err) } } + +func writeSeed(seed int64, fileName string) error { + data := strconv.FormatInt(seed, 10) + err := os.WriteFile(fileName, []byte(data), 0644) + if err != nil { + return err + } + return nil +} + +func readSeed(fileName string) (int64, error) { + file, err := os.Open(fileName) + if err != nil { + return 0, err + } + defer file.Close() + + data, err := io.ReadAll(file) + if err != nil { + return 0, err + } + data = bytes.Trim(data, "\x00") + seed := string(data) + return tpgresource.StringToFixed64(seed) +}