Skip to content

Commit

Permalink
remove debugInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Mar 15, 2024
1 parent b048a7b commit 49cc6df
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 56 deletions.
2 changes: 1 addition & 1 deletion config/tests/samples/create/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -92,25 +78,25 @@ 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": "[email protected]",
"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:
Content-Type:
- application/json; charset=UTF-8
status: 200 OK
code: 200
duration: 765.124261ms
duration: 444.535917ms
- id: 2
request:
proto: HTTP/1.1
Expand All @@ -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
Expand All @@ -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":"[email protected]","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":"[email protected]","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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -341,25 +327,25 @@ 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": "[email protected]",
"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:
Content-Type:
- application/json; charset=UTF-8
status: 200 OK
code: 200
duration: 405.508656ms
duration: 465.449049ms
- id: 7
request:
proto: HTTP/1.1
Expand All @@ -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
Expand All @@ -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":"[email protected]","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":"[email protected]","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
38 changes: 32 additions & 6 deletions tests/e2e/unified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 49cc6df

Please sign in to comment.