From 49cc6df02f342c00ef221322d8b2c7e3899f32ee Mon Sep 17 00:00:00 2001 From: Gemma Hou Date: Thu, 14 Mar 2024 02:27:21 +0000 Subject: [PATCH] remove debugInfo --- config/tests/samples/create/harness.go | 2 +- ...InSeries_fixtures_computenodetemplate.yaml | 84 ++++++++----------- tests/e2e/unified_test.go | 38 +++++++-- 3 files changed, 68 insertions(+), 56 deletions(-) diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index c74752efc65..109e968ca8c 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -322,7 +322,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: recorder.ModeReplayOnly, RealTransport: ret.Transport, } r, err := recorder.NewWithOptions(opts) 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 23b92fd40a7..c36072ba289 100644 --- a/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml +++ b/pkg/test/resourcefixture/testdata/vcr/cassette/TestAllInSeries_fixtures_computenodetemplate.yaml @@ -1,17 +1,3 @@ -# 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: @@ -61,7 +47,7 @@ interactions: - application/json; charset=UTF-8 status: 404 Not Found code: 404 - duration: 214.994989ms + duration: 197.569162ms - id: 1 request: proto: HTTP/1.1 @@ -92,17 +78,17 @@ interactions: body: | { "kind": "compute#operation", - "id": "6628313260286154337", - "name": "operation-1710467214059-613a92eb1a9a2-e761c6e4-c35dd456", + "id": "809028059089735866", + "name": "operation-1710468692787-613a986d53f56-f2fc7213-0b60c8ac", "operationType": "compute.nodeTemplates.insert", "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111", - "targetId": "1840433634538821217", + "targetId": "8740527968291262650", "status": "RUNNING", "user": "user@google.com", "progress": 0, - "insertTime": "2024-03-14T18:46:54.656-07:00", - "startTime": "2024-03-14T18:46:54.697-07:00", - "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710467214059-613a92eb1a9a2-e761c6e4-c35dd456", + "insertTime": "2024-03-14T19:11:33.089-07:00", + "startTime": "2024-03-14T19:11:33.130-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710468692787-613a986d53f56-f2fc7213-0b60c8ac", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1" } headers: @@ -110,7 +96,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 765.124261ms + duration: 444.535917ms - id: 2 request: proto: HTTP/1.1 @@ -127,7 +113,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-1710467214059-613a92eb1a9a2-e761c6e4-c35dd456?alt=json&prettyPrint=false + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710468692787-613a986d53f56-f2fc7213-0b60c8ac?alt=json&prettyPrint=false method: GET response: proto: HTTP/2.0 @@ -137,13 +123,13 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"kind":"compute#operation","id":"6628313260286154337","name":"operation-1710467214059-613a92eb1a9a2-e761c6e4-c35dd456","operationType":"compute.nodeTemplates.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111","targetId":"1840433634538821217","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-14T18:46:54.656-07:00","startTime":"2024-03-14T18:46:54.697-07:00","endTime":"2024-03-14T18:46:54.994-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710467214059-613a92eb1a9a2-e761c6e4-c35dd456","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' + body: '{"kind":"compute#operation","id":"809028059089735866","name":"operation-1710468692787-613a986d53f56-f2fc7213-0b60c8ac","operationType":"compute.nodeTemplates.insert","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111","targetId":"8740527968291262650","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-14T19:11:33.089-07:00","startTime":"2024-03-14T19:11:33.130-07:00","endTime":"2024-03-14T19:11:33.417-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710468692787-613a986d53f56-f2fc7213-0b60c8ac","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: 346.050124ms + duration: 155.709356ms - id: 3 request: proto: HTTP/1.1 @@ -173,14 +159,14 @@ interactions: body: | { "kind": "compute#nodeTemplate", - "id": "1840433634538821217", - "creationTimestamp": "2024-03-14T18:46:54.668-07:00", + "id": "8740527968291262650", + "creationTimestamp": "2024-03-14T19:11:33.102-07:00", "name": "computenodetemplate-uniqueid111111", "description": "Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.", "nodeAffinityLabels": { + "cnrm-test": "true", "managed-by-cnrm": "true", - "memory_guarantee": "false", - "cnrm-test": "true" + "memory_guarantee": "false" }, "status": "READY", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", @@ -199,7 +185,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 170.297617ms + duration: 167.271382ms - id: 4 request: proto: HTTP/1.1 @@ -229,14 +215,14 @@ interactions: body: | { "kind": "compute#nodeTemplate", - "id": "1840433634538821217", - "creationTimestamp": "2024-03-14T18:46:54.668-07:00", + "id": "8740527968291262650", + "creationTimestamp": "2024-03-14T19:11:33.102-07:00", "name": "computenodetemplate-uniqueid111111", "description": "Node template for sole tenant nodes running in us-central1, with 96vCPUs and any amount of memory on any machine type.", "nodeAffinityLabels": { "cnrm-test": "true", - "managed-by-cnrm": "true", - "memory_guarantee": "false" + "memory_guarantee": "false", + "managed-by-cnrm": "true" }, "status": "READY", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1", @@ -255,7 +241,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 172.725397ms + duration: 158.168515ms - id: 5 request: proto: HTTP/1.1 @@ -285,13 +271,13 @@ interactions: body: | { "kind": "compute#nodeTemplate", - "id": "1840433634538821217", - "creationTimestamp": "2024-03-14T18:46:54.668-07:00", + "id": "8740527968291262650", + "creationTimestamp": "2024-03-14T19:11:33.102-07:00", "name": "computenodetemplate-uniqueid111111", "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", "memory_guarantee": "false", + "managed-by-cnrm": "true", "cnrm-test": "true" }, "status": "READY", @@ -311,7 +297,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 139.970247ms + duration: 130.205646ms - id: 6 request: proto: HTTP/1.1 @@ -341,17 +327,17 @@ interactions: body: | { "kind": "compute#operation", - "id": "7418327646336849534", - "name": "operation-1710467217500-613a92ee627a5-f1e1baa3-4ae62678", + "id": "9145340086322073784", + "name": "operation-1710468695674-613a987014c9b-95256e64-4948256e", "operationType": "compute.nodeTemplates.delete", "targetLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111", - "targetId": "1840433634538821217", + "targetId": "8740527968291262650", "status": "RUNNING", "user": "user@google.com", "progress": 0, - "insertTime": "2024-03-14T18:46:57.768-07:00", - "startTime": "2024-03-14T18:46:57.795-07:00", - "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710467217500-613a92ee627a5-f1e1baa3-4ae62678", + "insertTime": "2024-03-14T19:11:35.953-07:00", + "startTime": "2024-03-14T19:11:35.994-07:00", + "selfLink": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710468695674-613a987014c9b-95256e64-4948256e", "region": "https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1" } headers: @@ -359,7 +345,7 @@ interactions: - application/json; charset=UTF-8 status: 200 OK code: 200 - duration: 405.508656ms + duration: 465.449049ms - id: 7 request: proto: HTTP/1.1 @@ -376,7 +362,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-1710467217500-613a92ee627a5-f1e1baa3-4ae62678?alt=json&prettyPrint=false + url: https://compute.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710468695674-613a987014c9b-95256e64-4948256e?alt=json&prettyPrint=false method: GET response: proto: HTTP/2.0 @@ -386,10 +372,10 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"kind":"compute#operation","id":"7418327646336849534","name":"operation-1710467217500-613a92ee627a5-f1e1baa3-4ae62678","operationType":"compute.nodeTemplates.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111","targetId":"1840433634538821217","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-14T18:46:57.768-07:00","startTime":"2024-03-14T18:46:57.795-07:00","endTime":"2024-03-14T18:46:58.153-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710467217500-613a92ee627a5-f1e1baa3-4ae62678","region":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1"}' + body: '{"kind":"compute#operation","id":"9145340086322073784","name":"operation-1710468695674-613a987014c9b-95256e64-4948256e","operationType":"compute.nodeTemplates.delete","targetLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/nodeTemplates/computenodetemplate-uniqueid111111","targetId":"8740527968291262650","status":"DONE","user":"user@google.com","progress":100,"insertTime":"2024-03-14T19:11:35.953-07:00","startTime":"2024-03-14T19:11:35.994-07:00","endTime":"2024-03-14T19:11:36.373-07:00","selfLink":"https://www.googleapis.com/compute/beta/projects/cnrm-user/regions/us-central1/operations/operation-1710468695674-613a987014c9b-95256e64-4948256e","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: 152.277906ms + duration: 128.679846ms diff --git a/tests/e2e/unified_test.go b/tests/e2e/unified_test.go index 7019c65f1df..2ecdc9e3d71 100644 --- a/tests/e2e/unified_test.go +++ b/tests/e2e/unified_test.go @@ -21,6 +21,7 @@ import ( "gopkg.in/dnaeon/go-vcr.v3/cassette" "gopkg.in/dnaeon/go-vcr.v3/recorder" "k8s.io/klog/v2" + "net/http" "os" "path/filepath" "strings" @@ -133,6 +134,12 @@ func TestAllInSeries(t *testing.T) { } }) + replaceFunc := func(s string) string { + result := strings.Replace(s, uniqueID, "uniqueid111111", -1) + result = strings.Replace(result, project.ProjectID, "cnrm-user", -1) + return result + } + hook := func(i *cassette.Interaction) error { var requestHeadersToRemove = []string{ "Authorization", @@ -156,12 +163,6 @@ func TestAllInSeries(t *testing.T) { delete(i.Response.Headers, header) } - replaceFunc := func(s string) string { - result := strings.Replace(s, uniqueID, "uniqueid111111", -1) - result = strings.Replace(result, project.ProjectID, "cnrm-user", -1) - return result - } - i.Request.Body = replaceFunc(i.Request.Body) i.Response.Body = replaceFunc(i.Response.Body) i.Request.URL = replaceFunc(i.Request.URL) @@ -194,6 +195,31 @@ func TestAllInSeries(t *testing.T) { return nil } h.VCRRecorder.AddHook(hook, recorder.BeforeSaveHook) + + //errorInteractionMismatch := func(request cassette.Request, field string, expected string, got string) { + // t.Errorf( + // "[VCR] Error with interaction: %s %s. Field %s does not match: expected: %s, got: %s.", + // request.Method, + // request.URL, + // field, + // expected, + // got, + // ) + //} + h.VCRRecorder.SetMatcher(func(r *http.Request, i cassette.Request) bool { + modifiedURL := replaceFunc(r.URL.String()) + + if r.Method != i.Method { + klog.Fatalf("[VCR] Fail") + return false + } + + if modifiedURL != i.URL { + klog.Fatalf("[VCR] Fail") + return false + } + return true + }) } primaryResource, opt := loadFixture(project)