Skip to content

Commit 5c885b2

Browse files
authored
Merge branch 'GoogleCloudPlatform:main' into feat-apigee-instance-update
2 parents 2ae2fe1 + c4eadf3 commit 5c885b2

File tree

1,395 files changed

+35461
-14134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,395 files changed

+35461
-14134
lines changed

.ci/gcb-generate-diffs-new.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ steps:
293293
- COMMIT_SHA=$COMMIT_SHA
294294

295295
# Long timeout to enable waiting on VCR test
296-
timeout: 20000s
296+
timeout: 64800s
297297
options:
298298
machineType: 'N1_HIGHCPU_32'
299299

.ci/gcb-pr-downstream-generation-and-test.yml

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
---
22
steps:
3-
- name: 'gcr.io/cloud-builders/gcloud'
4-
id: "Stop Other Ongoing Build"
5-
entrypoint: 'bash'
6-
args:
7-
- -c
8-
- |
9-
on_going_build=($(gcloud builds list --ongoing --format='value[separator=","](id,substitutions.REVISION_ID)' --filter="substitutions.TRIGGER_NAME:$TRIGGER_NAME substitutions._PR_NUMBER:$_PR_NUMBER" | xargs))
10-
for (( i=0; i<${#on_going_build[@]}; i++ )); do
11-
IFS="," read -r -a fields <<< "${on_going_build[i]}"
12-
if [ "$i" -gt "0" ] && [ "${fields[1]}" != $COMMIT_SHA ]; then # skip current
13-
echo "Cancelling build ${fields[0]}"
14-
15-
gcloud builds cancel ${fields[0]}
16-
fi
17-
done
18-
193
# The GCB / GH integration uses a shallow clone of the repo. We need to convert
204
# that to a full clone in order to work with it properly.
215
# https://cloud.google.com/source-repositories/docs/integrating-with-cloud-build#unshallowing_clones
@@ -235,7 +219,7 @@ steps:
235219
- $COMMIT_SHA
236220
- $BUILD_ID
237221
- $PROJECT_ID
238-
- "18" # Build step
222+
- "19" # Build step
239223
- terraform-google-conversion
240224

241225
- name: 'gcr.io/graphite-docker-images/go-plus'

.ci/infra/terraform/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ module "project-services" {
279279
"looker.googleapis.com",
280280
"managedidentities.googleapis.com",
281281
"memcache.googleapis.com",
282+
"memorystore.googleapis.com",
282283
"metastore.googleapis.com",
283284
"migrationcenter.googleapis.com",
284285
"ml.googleapis.com",

.ci/magician/cmd/check_cassettes.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ func execCheckCassettes(commit string, vt *vcr.Tester, ctlr *source.Controller)
103103
}
104104
vt.SetRepoPath(provider.Beta, providerRepo.Path)
105105

106-
result, err := vt.Run(vcr.Replaying, provider.Beta, nil)
106+
result, err := vt.Run(vcr.RunOptions{
107+
Mode: vcr.Replaying,
108+
Version: provider.Beta,
109+
})
107110
if err != nil {
108111
fmt.Println("Error running VCR: ", err)
109112
}

.ci/magician/cmd/generate_comment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ func buildDiffProcessor(diffProcessorPath, providerLocalPath string, env map[str
435435
}
436436
}
437437
if _, err := rnr.Run("make", []string{"build"}, env); err != nil {
438-
return fmt.Errorf("Error running make build in %s: %v\n", diffProcessorPath, err)
438+
return fmt.Errorf("error running make build in %s: %v", diffProcessorPath, err)
439439
}
440440
return rnr.PopDir()
441441
}

.ci/magician/cmd/request_service_reviewers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func execRequestServiceReviewers(prNumber string, gh GithubClient, enrolledTeams
107107
}
108108

109109
exitCode := 0
110-
for githubTeam, _ := range githubTeamsSet {
110+
for githubTeam := range githubTeamsSet {
111111
members, err := gh.GetTeamMembers("GoogleCloudPlatform", githubTeam)
112112
if err != nil {
113113
fmt.Printf("Error fetching members for GoogleCloudPlatform/%s: %s", githubTeam, err)

.ci/magician/cmd/scheduled_pr_reminders.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func execScheduledPrReminders(gh *github.Client) error {
189189
},
190190
)
191191
if err != nil {
192-
return fmt.Errorf("Error posting comment to PR %d: %w", *pr.Number, err)
192+
return fmt.Errorf("error posting comment to PR %d: %w", *pr.Number, err)
193193
}
194194
}
195195
}
@@ -208,7 +208,7 @@ func execScheduledPrReminders(gh *github.Client) error {
208208
},
209209
)
210210
if err != nil {
211-
return fmt.Errorf("Error closing PR %d: %w", *pr.Number, err)
211+
return fmt.Errorf("error closing PR %d: %w", *pr.Number, err)
212212
}
213213
}
214214
}

.ci/magician/cmd/test_terraform_vcr.go

+34-15
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var ttvEnvironmentVariables = [...]string{
5656
}
5757

5858
type analytics struct {
59-
ReplayingResult *vcr.Result
59+
ReplayingResult vcr.Result
6060
RunFullVCR bool
6161
AffectedServices []string
6262
}
@@ -67,7 +67,7 @@ type nonExercisedTests struct {
6767
}
6868

6969
type withReplayFailedTests struct {
70-
ReplayingResult *vcr.Result
70+
ReplayingResult vcr.Result
7171
}
7272

7373
type withoutReplayFailedTests struct {
@@ -77,8 +77,8 @@ type withoutReplayFailedTests struct {
7777
}
7878

7979
type recordReplay struct {
80-
RecordingResult *vcr.Result
81-
ReplayingAfterRecordingResult *vcr.Result
80+
RecordingResult vcr.Result
81+
ReplayingAfterRecordingResult vcr.Result
8282
HasTerminatedTests bool
8383
RecordingErr error
8484
AllRecordingPassed bool
@@ -244,7 +244,12 @@ func execTestTerraformVCR(prNumber, mmCommitSha, buildID, projectID, buildStep,
244244
return fmt.Errorf("error posting comment: %w", err)
245245
}
246246

247-
recordingResult, recordingErr := vt.RunParallel(vcr.Recording, provider.Beta, testDirs, replayingResult.FailedTests)
247+
recordingResult, recordingErr := vt.RunParallel(vcr.RunOptions{
248+
Mode: vcr.Recording,
249+
Version: provider.Beta,
250+
TestDirs: testDirs,
251+
Tests: replayingResult.FailedTests,
252+
})
248253
if recordingErr != nil {
249254
testState = "failure"
250255
} else {
@@ -265,10 +270,15 @@ func execTestTerraformVCR(prNumber, mmCommitSha, buildID, projectID, buildStep,
265270
return nil
266271
}
267272

268-
var replayingAfterRecordingResult *vcr.Result
273+
replayingAfterRecordingResult := vcr.Result{}
269274
var replayingAfterRecordingErr error
270275
if len(recordingResult.PassedTests) > 0 {
271-
replayingAfterRecordingResult, replayingAfterRecordingErr = vt.RunParallel(vcr.Replaying, provider.Beta, testDirs, recordingResult.PassedTests)
276+
replayingAfterRecordingResult, replayingAfterRecordingErr = vt.RunParallel(vcr.RunOptions{
277+
Mode: vcr.Replaying,
278+
Version: provider.Beta,
279+
TestDirs: testDirs,
280+
Tests: recordingResult.PassedTests,
281+
})
272282
if replayingAfterRecordingErr != nil {
273283
testState = "failure"
274284
}
@@ -323,7 +333,7 @@ func execTestTerraformVCR(prNumber, mmCommitSha, buildID, projectID, buildStep,
323333

324334
var addedTestsRegexp = regexp.MustCompile(`(?m)^\+func (Test\w+)\(t \*testing.T\) {`)
325335

326-
func notRunTests(gaDiff, betaDiff string, result *vcr.Result) ([]string, []string) {
336+
func notRunTests(gaDiff, betaDiff string, result vcr.Result) ([]string, []string) {
327337
fmt.Println("Checking for new acceptance tests that were not run")
328338
addedGaTests := addedTestsRegexp.FindAllStringSubmatch(gaDiff, -1)
329339
addedBetaTests := addedTestsRegexp.FindAllStringSubmatch(betaDiff, -1)
@@ -388,20 +398,27 @@ func modifiedPackages(changedFiles []string) (map[string]struct{}, bool) {
388398
return services, runFullVCR
389399
}
390400

391-
func runReplaying(runFullVCR bool, services map[string]struct{}, vt *vcr.Tester) (*vcr.Result, []string, error) {
392-
var result *vcr.Result
401+
func runReplaying(runFullVCR bool, services map[string]struct{}, vt *vcr.Tester) (vcr.Result, []string, error) {
402+
result := vcr.Result{}
393403
var testDirs []string
394404
var replayingErr error
395405
if runFullVCR {
396-
fmt.Println("run full VCR tests")
397-
result, replayingErr = vt.Run(vcr.Replaying, provider.Beta, nil)
406+
fmt.Println("runReplaying: full VCR tests")
407+
result, replayingErr = vt.Run(vcr.RunOptions{
408+
Mode: vcr.Replaying,
409+
Version: provider.Beta,
410+
})
398411
} else if len(services) > 0 {
399-
result = &vcr.Result{}
412+
fmt.Printf("runReplaying: %d specific services: %v\n", len(services), services)
400413
for service := range services {
401414
servicePath := "./" + filepath.Join("google-beta", "services", service)
402415
testDirs = append(testDirs, servicePath)
403416
fmt.Println("run VCR tests in ", service)
404-
serviceResult, serviceReplayingErr := vt.Run(vcr.Replaying, provider.Beta, []string{servicePath})
417+
serviceResult, serviceReplayingErr := vt.Run(vcr.RunOptions{
418+
Mode: vcr.Replaying,
419+
Version: provider.Beta,
420+
TestDirs: []string{servicePath},
421+
})
405422
if serviceReplayingErr != nil {
406423
replayingErr = serviceReplayingErr
407424
}
@@ -410,12 +427,14 @@ func runReplaying(runFullVCR bool, services map[string]struct{}, vt *vcr.Tester)
410427
result.FailedTests = append(result.FailedTests, serviceResult.FailedTests...)
411428
result.Panics = append(result.Panics, serviceResult.Panics...)
412429
}
430+
} else {
431+
fmt.Println("runReplaying: no impacted services")
413432
}
414433

415434
return result, testDirs, replayingErr
416435
}
417436

418-
func handlePanics(prNumber, buildID, buildStatusTargetURL, mmCommitSha string, result *vcr.Result, mode vcr.Mode, gh GithubClient) (bool, error) {
437+
func handlePanics(prNumber, buildID, buildStatusTargetURL, mmCommitSha string, result vcr.Result, mode vcr.Mode, gh GithubClient) (bool, error) {
419438
if len(result.Panics) > 0 {
420439
comment := fmt.Sprintf(`$\textcolor{red}{\textsf{The provider crashed while running the VCR tests in %s mode}}$
421440
$\textcolor{red}{\textsf{Please fix it to complete your PR}}$

.ci/magician/cmd/test_terraform_vcr_test.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ func TestModifiedPackagesFromDiffs(t *testing.T) {
7575
func TestNotRunTests(t *testing.T) {
7676
cases := map[string]struct {
7777
gaDiff, betaDiff string
78-
result *vcr.Result
78+
result vcr.Result
7979
wantNotRunBeta []string
8080
wantNotRunGa []string
8181
}{
8282
"no diff": {
8383
gaDiff: "",
8484
betaDiff: "",
85-
result: &vcr.Result{
85+
result: vcr.Result{
8686
PassedTests: []string{"TestAccOne"},
8787
FailedTests: []string{"TestAccTwo"},
8888
},
@@ -92,7 +92,7 @@ func TestNotRunTests(t *testing.T) {
9292
"no added tests": {
9393
gaDiff: "+// some change",
9494
betaDiff: "+// some change",
95-
result: &vcr.Result{
95+
result: vcr.Result{
9696
PassedTests: []string{"TestAccOne"},
9797
FailedTests: []string{"TestAccTwo"},
9898
},
@@ -102,7 +102,7 @@ func TestNotRunTests(t *testing.T) {
102102
"test added and passed": {
103103
gaDiff: "+func TestAccTwo(t *testing.T) {",
104104
betaDiff: "+func TestAccTwo(t *testing.T) {",
105-
result: &vcr.Result{
105+
result: vcr.Result{
106106
PassedTests: []string{"TestAccTwo"},
107107
FailedTests: []string{},
108108
},
@@ -114,7 +114,7 @@ func TestNotRunTests(t *testing.T) {
114114
+func TestAccThree(t *testing.T) {`,
115115
betaDiff: `+func TestAccTwo(t *testing.T) {
116116
+func TestAccThree(t *testing.T) {`,
117-
result: &vcr.Result{
117+
result: vcr.Result{
118118
PassedTests: []string{"TestAccTwo", "TestAccThree"},
119119
FailedTests: []string{},
120120
},
@@ -124,7 +124,7 @@ func TestNotRunTests(t *testing.T) {
124124
"test added and failed": {
125125
gaDiff: "+func TestAccTwo(t *testing.T) {",
126126
betaDiff: "+func TestAccTwo(t *testing.T) {",
127-
result: &vcr.Result{
127+
result: vcr.Result{
128128
PassedTests: []string{},
129129
FailedTests: []string{"TestAccTwo"},
130130
},
@@ -134,7 +134,7 @@ func TestNotRunTests(t *testing.T) {
134134
"tests removed and run": {
135135
gaDiff: "-func TestAccOne(t *testing.T) {",
136136
betaDiff: "-func TestAccTwo(t *testing.T) {",
137-
result: &vcr.Result{
137+
result: vcr.Result{
138138
PassedTests: []string{"TestAccOne"},
139139
FailedTests: []string{"TestAccTwo"},
140140
},
@@ -144,7 +144,7 @@ func TestNotRunTests(t *testing.T) {
144144
"test added and not run": {
145145
gaDiff: "+func TestAccThree(t *testing.T) {",
146146
betaDiff: "+func TestAccFour(t *testing.T) {",
147-
result: &vcr.Result{
147+
result: vcr.Result{
148148
PassedTests: []string{"TestAccOne"},
149149
FailedTests: []string{"TestAccTwo"},
150150
},
@@ -156,7 +156,7 @@ func TestNotRunTests(t *testing.T) {
156156
+func TestAccThree(t *testing.T) {`,
157157
betaDiff: `+func TestAccTwo(t *testing.T) {
158158
+func TestAccThree(t *testing.T) {`,
159-
result: &vcr.Result{
159+
result: vcr.Result{
160160
PassedTests: []string{"TestAccOne"},
161161
FailedTests: []string{"TestAccFour"},
162162
},
@@ -166,7 +166,7 @@ func TestNotRunTests(t *testing.T) {
166166
"tests removed and not run": {
167167
gaDiff: "-func TestAccThree(t *testing.T) {",
168168
betaDiff: "-func TestAccFour(t *testing.T) {",
169-
result: &vcr.Result{
169+
result: vcr.Result{
170170
PassedTests: []string{"TestAccOne"},
171171
FailedTests: []string{"TestAccTwo"},
172172
},
@@ -176,7 +176,7 @@ func TestNotRunTests(t *testing.T) {
176176
"tests added but commented out": {
177177
gaDiff: "+//func TestAccThree(t *testing.T) {",
178178
betaDiff: "+//func TestAccFour(t *testing.T) {",
179-
result: &vcr.Result{
179+
result: vcr.Result{
180180
PassedTests: []string{"TestAccOne"},
181181
FailedTests: []string{"TestAccTwo"},
182182
},
@@ -189,7 +189,7 @@ func TestNotRunTests(t *testing.T) {
189189
+func TestAccCloudRunService_cloudRunServiceMulticontainerExample(t *testing.T) {`,
190190
betaDiff: `diff --git a/google-beta/services/alloydb/resource_alloydb_backup_generated_test.go b/google-beta/services/alloydb/resource_alloydb_backup_generated_test.go
191191
+func TestAccAlloydbBackup_alloydbBackupFullTestNewExample(t *testing.T) {`,
192-
result: &vcr.Result{
192+
result: vcr.Result{
193193
PassedTests: []string{},
194194
FailedTests: []string{},
195195
},
@@ -199,7 +199,7 @@ func TestNotRunTests(t *testing.T) {
199199
"always count GA-only added tests": {
200200
gaDiff: "+func TestAccOne(t *testing.T) {",
201201
betaDiff: "",
202-
result: &vcr.Result{
202+
result: vcr.Result{
203203
PassedTests: []string{"TestAccOne"},
204204
FailedTests: []string{"TestAccTwo"},
205205
},
@@ -226,7 +226,7 @@ func TestAnalyticsComment(t *testing.T) {
226226
{
227227
name: "run full vcr is false and no affected services",
228228
data: analytics{
229-
ReplayingResult: &vcr.Result{
229+
ReplayingResult: vcr.Result{
230230
PassedTests: []string{"a", "b", "c"},
231231
SkippedTests: []string{"d", "e"},
232232
FailedTests: []string{"f"},
@@ -257,7 +257,7 @@ func TestAnalyticsComment(t *testing.T) {
257257
{
258258
name: "run full vcr is false and has affected services",
259259
data: analytics{
260-
ReplayingResult: &vcr.Result{
260+
ReplayingResult: vcr.Result{
261261
PassedTests: []string{"a", "b", "c"},
262262
SkippedTests: []string{"d", "e"},
263263
FailedTests: []string{"f"},
@@ -292,7 +292,7 @@ func TestAnalyticsComment(t *testing.T) {
292292
{
293293
name: "run full vcr is true",
294294
data: analytics{
295-
ReplayingResult: &vcr.Result{
295+
ReplayingResult: vcr.Result{
296296
PassedTests: []string{"a", "b", "c"},
297297
SkippedTests: []string{"d", "e"},
298298
FailedTests: []string{"f"},
@@ -427,7 +427,7 @@ func TestWithReplayFailedTests(t *testing.T) {
427427
{
428428
name: "with failed tests",
429429
data: withReplayFailedTests{
430-
ReplayingResult: &vcr.Result{
430+
ReplayingResult: vcr.Result{
431431
FailedTests: []string{"a", "b"},
432432
},
433433
},
@@ -525,11 +525,11 @@ func TestRecordReplay(t *testing.T) {
525525
{
526526
name: "ReplayingAfterRecordingResult has failed tests",
527527
data: recordReplay{
528-
RecordingResult: &vcr.Result{
528+
RecordingResult: vcr.Result{
529529
PassedTests: []string{"a", "b", "c"},
530530
FailedTests: []string{"d", "e"},
531531
},
532-
ReplayingAfterRecordingResult: &vcr.Result{
532+
ReplayingAfterRecordingResult: vcr.Result{
533533
PassedTests: []string{"a"},
534534
FailedTests: []string{"b", "c"},
535535
},
@@ -572,10 +572,10 @@ func TestRecordReplay(t *testing.T) {
572572
{
573573
name: "ReplayingAfterRecordingResult does not have failed tests",
574574
data: recordReplay{
575-
RecordingResult: &vcr.Result{
575+
RecordingResult: vcr.Result{
576576
PassedTests: []string{"a", "b", "c"},
577577
},
578-
ReplayingAfterRecordingResult: &vcr.Result{
578+
ReplayingAfterRecordingResult: vcr.Result{
579579
PassedTests: []string{"a", "b", "c"},
580580
},
581581
AllRecordingPassed: true,

0 commit comments

Comments
 (0)