diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index db07bae31c..c74752efc6 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -24,6 +24,8 @@ import ( "testing" "time" + "gopkg.in/dnaeon/go-vcr.v3/recorder" + "github.com/go-logr/logr" "github.com/google/go-cmp/cmp" transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" @@ -75,6 +77,8 @@ type Harness struct { // gcpAccessToken is set to the oauth2 token to use for GCP, primarily when GCP is mocked. gcpAccessToken string kccConfig kccmanager.Config + + VCRRecorder *recorder.Recorder } type httpRoundTripperKeyType int @@ -237,6 +241,8 @@ func NewHarness(ctx context.Context, t *testing.T) *Harness { kccConfig.GCPAccessToken = h.gcpAccessToken } else if targetGCP := os.Getenv("E2E_GCP_TARGET"); targetGCP == "real" { t.Logf("targeting real GCP") + } else if targetGCP := os.Getenv("E2E_GCP_TARGET"); targetGCP == "vcr" { + t.Logf("creating vcr test") } else { t.Fatalf("E2E_GCP_TARGET=%q not supported", targetGCP) } @@ -306,17 +312,40 @@ func NewHarness(ctx context.Context, t *testing.T) *Harness { kccConfig.HTTPClient = &http.Client{Transport: t} } - // Intercept (and log) TF requests - transport_tpg.DefaultHTTPClientTransformer = func(ctx context.Context, inner *http.Client) *http.Client { - ret := inner - if t := ctx.Value(httpRoundTripperKey); t != nil { - ret = &http.Client{Transport: t.(http.RoundTripper)} + if targetGCP := os.Getenv("E2E_GCP_TARGET"); targetGCP == "vcr" { + transport_tpg.DefaultHTTPClientTransformer = func(ctx context.Context, inner *http.Client) *http.Client { + ret := inner + if t := ctx.Value(httpRoundTripperKey); t != nil { + ret = &http.Client{Transport: t.(http.RoundTripper)} + } + dir := "pkg/test/resourcefixture/testdata/vcr/cassette/" + testName := strings.ReplaceAll(t.Name(), "/", "_") + opts := &recorder.Options{ + CassetteName: filepath.Join(dir, testName), + Mode: recorder.ModeRecordOnly, + RealTransport: ret.Transport, + } + r, err := recorder.NewWithOptions(opts) + if err != nil { + t.Fatalf("[VCR] Failed create vcr recorder: %v", err) + } + h.VCRRecorder = r + ret = &http.Client{Transport: h.VCRRecorder} + return ret } - if len(eventSinks) != 0 { - t := test.NewHTTPRecorder(ret.Transport, eventSinks...) - ret = &http.Client{Transport: t} + } else { + // Intercept (and log) TF requests + transport_tpg.DefaultHTTPClientTransformer = func(ctx context.Context, inner *http.Client) *http.Client { + ret := inner + if t := ctx.Value(httpRoundTripperKey); t != nil { + ret = &http.Client{Transport: t.(http.RoundTripper)} + } + if len(eventSinks) != 0 { + t := test.NewHTTPRecorder(ret.Transport, eventSinks...) + ret = &http.Client{Transport: t} + } + return ret } - return ret } // Intercept (and log) TF oauth requests diff --git a/go.mod b/go.mod index 67ff1dee77..25d77831b2 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,7 @@ require ( golang.org/x/time v0.5.0 google.golang.org/api v0.160.0 google.golang.org/protobuf v1.32.0 + gopkg.in/dnaeon/go-vcr.v3 v3.1.2 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.27.11 k8s.io/apiextensions-apiserver v0.27.9 diff --git a/go.sum b/go.sum index 7be39ab6cd..8ffb9d57a5 100644 --- a/go.sum +++ b/go.sum @@ -1473,6 +1473,8 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/dnaeon/go-vcr.v3 v3.1.2 h1:F1smfXBqQqwpVifDfUBQG6zzaGjzT+EnVZakrOdr5wA= +gopkg.in/dnaeon/go-vcr.v3 v3.1.2/go.mod h1:2IMOnnlx9I6u9x+YBsM3tAMx6AlOxnJ0pWxQAzZ79Ag= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= diff --git a/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml new file mode 100644 index 0000000000..ec66458852 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml @@ -0,0 +1,529 @@ +--- +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 + User-Agent: + - Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q?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-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q' was not found", + "errors": [ + { + "message": "The resource 'projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q' was not found", + "domain": "global", + "reason": "notFound", + "debugInfo": "java.lang.Exception\n\tat com.google.cloud.control.common.publicerrors.PublicErrorProtoUtils.newErrorBuilder(PublicErrorProtoUtils.java:2158)\n\tat com.google.cloud.control.common.publicerrors.PublicErrorProtoUtils.newErrorBuilder(PublicErrorProtoUtils.java:2150)\n\tat com.google.cloud.control.common.publicerrors.PublicErrorProtoUtils.createResourceNotFoundError(PublicErrorProtoUtils.java:194)\n\tat com.google.cloud.control.entities.clhbridge.ClhBridgeEntityLoader.lambda$getEntityByReference$0(ClhBridgeEntityLoader.java:164)\n\tat java.base/java.util.Optional.orElseThrow(Unknown Source)\n\tat com.google.cloud.control.entities.clhbridge.ClhBridgeEntityLoader.getEntityByReference(ClhBridgeEntityLoader.java:161)\n\tat com.google.cloud.control.services.clhbridge.ClhBridgeGetResourceAction$Handler.runAttempt(ClhBridgeGetResourceAction.java:390)\n\tat com.google.cloud.control.services.clhbridge.ClhBridgeGetResourceAction$Handler.runAttempt(ClhBridgeGetResourceAction.java:267)\n\tat com.google.cloud.cluster.metastore.RetryingMetastoreTransactionExecutor$1.runAttempt(RetryingMetastoreTransactionExecutor.java:94)\n\tat com.google.cloud.cluster.metastore.MetastoreRetryLoop.runHandler(MetastoreRetryLoop.java:523)\n\t...Stack trace is shortened.\n" + } + ] + } + } + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:31 GMT + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 404 Not Found + code: 404 + duration: 400.888332ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 417 + 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-ecutmuuaqyhab6sxwf7q","nodeAffinityLabels":{"cnrm-test":"true","managed-by-cnrm":"true","memory_guarantee":"false"},"nodeTypeFlexibility":{"cpus":"96","memory":"any"},"region":"projects/cnrm-yuhou/global/regions/us-central1"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/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": "5139217832128448639", + "name": "operation-1710438031884-613a2634d0282-3478b363-e0af1d97", + "operationType": "compute.nodeTemplates.insert", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q", + "targetId": "6493056936179566719", + "status": "RUNNING", + "user": "yuhou@google.com", + "progress": 0, + "insertTime": "2024-03-14T10:40:32.186-07:00", + "startTime": "2024-03-14T10:40:32.237-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/operations/operation-1710438031884-613a2634d0282-3478b363-e0af1d97", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1" + } + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:32 GMT + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 462.916981ms + - 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: + User-Agent: + - google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/operations/operation-1710438031884-613a2634d0282-3478b363-e0af1d97?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":"5139217832128448639","name":"operation-1710438031884-613a2634d0282-3478b363-e0af1d97","operationType":"compute.nodeTemplates.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q","targetId":"6493056936179566719","status":"DONE","user":"yuhou@google.com","progress":100,"insertTime":"2024-03-14T10:40:32.186-07:00","startTime":"2024-03-14T10:40:32.237-07:00","endTime":"2024-03-14T10:40:32.557-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/operations/operation-1710438031884-613a2634d0282-3478b363-e0af1d97","region":"https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1"}' + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:32 GMT + Etag: + - 1vemYvWuEDeqfn1kfmHKCImCsU0=/NcvrT1ClOcogrjM0_klTx3TguZ8= + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 169.399533ms + - 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 + User-Agent: + - Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q?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": "6493056936179566719", + "creationTimestamp": "2024-03-14T10:40:32.200-07:00", + "name": "computenodetemplate-ecutmuuaqyhab6sxwf7q", + "description": "Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.", + "nodeAffinityLabels": { + "managed-by-cnrm": "true", + "cnrm-test": "true", + "memory_guarantee": "false" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q", + "nodeTypeFlexibility": { + "cpus": "96", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:33 GMT + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 187.773865ms + - 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 + User-Agent: + - Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q?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": "6493056936179566719", + "creationTimestamp": "2024-03-14T10:40:32.200-07:00", + "name": "computenodetemplate-ecutmuuaqyhab6sxwf7q", + "description": "Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.", + "nodeAffinityLabels": { + "managed-by-cnrm": "true", + "cnrm-test": "true", + "memory_guarantee": "false" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q", + "nodeTypeFlexibility": { + "cpus": "96", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:33 GMT + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 175.398443ms + - 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 + User-Agent: + - Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q?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": "6493056936179566719", + "creationTimestamp": "2024-03-14T10:40:32.200-07:00", + "name": "computenodetemplate-ecutmuuaqyhab6sxwf7q", + "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" + }, + "status": "READY", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q", + "nodeTypeFlexibility": { + "cpus": "96", + "memory": "any" + }, + "serverBinding": { + "type": "RESTART_NODE_ON_ANY_SERVER" + }, + "cpuOvercommitType": "NONE" + } + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:34 GMT + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 120.547305ms + - id: 6 + 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 + User-Agent: + - Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q?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": "7466036151650781308", + "name": "operation-1710438034990-613a2637c6612-777550f0-3427cc56", + "operationType": "compute.nodeTemplates.delete", + "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q", + "targetId": "6493056936179566719", + "status": "RUNNING", + "user": "yuhou@google.com", + "progress": 0, + "insertTime": "2024-03-14T10:40:35.246-07:00", + "startTime": "2024-03-14T10:40:35.264-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/operations/operation-1710438034990-613a2637c6612-777550f0-3427cc56", + "region": "https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1" + } + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:35 GMT + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 427.334726ms + - 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: + User-Agent: + - google-api-go-client/0.5 Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/dev + X-Goog-Api-Client: + - gl-go/1.21.5 gdcl/0.160.0 + url: https://compute.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/operations/operation-1710438034990-613a2637c6612-777550f0-3427cc56?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":"7466036151650781308","name":"operation-1710438034990-613a2637c6612-777550f0-3427cc56","operationType":"compute.nodeTemplates.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/nodeTemplates/computenodetemplate-ecutmuuaqyhab6sxwf7q","targetId":"6493056936179566719","status":"DONE","user":"yuhou@google.com","progress":100,"insertTime":"2024-03-14T10:40:35.246-07:00","startTime":"2024-03-14T10:40:35.264-07:00","endTime":"2024-03-14T10:40:35.573-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1/operations/operation-1710438034990-613a2637c6612-777550f0-3427cc56","region":"https://www.googleapis.com/compute/beta/projects/cnrm-yuhou/regions/us-central1"}' + headers: + Cache-Control: + - private + Content-Type: + - application/json; charset=UTF-8 + Date: + - Thu, 14 Mar 2024 17:40:35 GMT + Etag: + - 2MJ_12wFKqT8OoVT31IKuaAwXAQ=/mgH6ljY_zd1ysot_F3HGai5q11Y= + Server: + - ESF + Vary: + - Origin + - X-Origin + - Referer + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 162.588352ms diff --git a/tests/e2e/unified_test.go b/tests/e2e/unified_test.go index 4433ffcb39..e4e454a83a 100644 --- a/tests/e2e/unified_test.go +++ b/tests/e2e/unified_test.go @@ -120,6 +120,16 @@ func TestAllInSeries(t *testing.T) { h := create.NewHarness(ctx, t) project := h.Project + if os.Getenv("E2E_GCP_TARGET") == "vcr" { + // Stop recording after tests finish and write to cassette + t.Cleanup(func() { + err := h.VCRRecorder.Stop() + if err != nil { + t.Errorf("[VCR] Failed stop vcr recorder: %v", err) + } + }) + } + primaryResource, opt := loadFixture(project) exportResources := []*unstructured.Unstructured{primaryResource}