Skip to content

Commit 918cbfc

Browse files
authored
Merge branch 'FEATURE-BRANCH-resource-identity-generation' into mmv1/identity-generation
2 parents 6c3343b + 1bd4eb0 commit 918cbfc

File tree

348 files changed

+13727
-1631
lines changed

Some content is hidden

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

348 files changed

+13727
-1631
lines changed

.ci/infra/terraform/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ module "project-services" {
334334
"resourceviews.googleapis.com",
335335
"run.googleapis.com",
336336
"runtimeconfig.googleapis.com",
337+
"saasservicemgmt.googleapis.com",
337338
"secretmanager.googleapis.com",
338339
"securesourcemanager.googleapis.com",
339340
"securetoken.googleapis.com",

.ci/magician/cmd/collect_nightly_test_status.go

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,25 @@ import (
3030
)
3131

3232
const (
33-
NightlyDataBucket = "nightly-test-data"
33+
nightlyDataBucket = "nightly-test-data"
34+
tcTimeFormat = "20060102T150405Z0700"
3435
)
3536

3637
var cntsRequiredEnvironmentVariables = [...]string{
3738
"TEAMCITY_TOKEN",
3839
}
3940

4041
type TestInfo struct {
41-
Name string `json:"name"`
42-
Status string `json:"status"`
43-
Service string `json:"service"`
44-
ErrorMessage string `json:"error_message"`
45-
LogLink string `json"log_link`
46-
ProviderVersion string `json:"provider_version"`
47-
QueuedDate string `json:"queuedDate"`
48-
StartDate string `json:"startDate"`
49-
FinishDate string `json:"finishDate"`
50-
Duration int `json:"duration"`
42+
Name string `json:"name"`
43+
Status string `json:"status"`
44+
Service string `json:"service"`
45+
ErrorMessage string `json:"error_message"`
46+
LogLink string `json:"log_link"`
47+
ProviderVersion string `json:"provider_version"`
48+
QueuedDate time.Time `json:"queued_date"`
49+
StartDate time.Time `json:"start_date"`
50+
FinishDate time.Time `json:"finish_date"`
51+
Duration int `json:"duration"`
5152
}
5253

5354
// collectNightlyTestStatusCmd represents the collectNightlyTestStatus command
@@ -168,17 +169,31 @@ func createTestReport(pVersion provider.Version, tc TeamcityClient, gcs Cloudsto
168169
if testResult.Status == "FAILURE" || testResult.Status == "UNKNOWN" {
169170
errorMessage = convertErrorMessage(testResult.ErrorMessage)
170171
}
172+
173+
queuedTime, err := time.Parse(tcTimeFormat, build.QueuedDate)
174+
if err != nil {
175+
return fmt.Errorf("failed to parse QueuedDate: %v", err)
176+
}
177+
startTime, err := time.Parse(tcTimeFormat, build.StartDate)
178+
if err != nil {
179+
return fmt.Errorf("failed to parse StartDate: %v", err)
180+
}
181+
finishTime, err := time.Parse(tcTimeFormat, build.FinishDate)
182+
if err != nil {
183+
return fmt.Errorf("failed to parse FinishDate: %v", err)
184+
}
185+
171186
testInfoList = append(testInfoList, TestInfo{
172187
Name: testResult.Name,
173188
Status: testResult.Status,
174189
Service: serviceName,
175190
ErrorMessage: errorMessage,
176191
LogLink: logLink,
177-
ProviderVersion: pVersion.String(),
192+
ProviderVersion: strings.ToUpper(pVersion.String()),
178193
Duration: testResult.Duration,
179-
QueuedDate: build.QueuedDate,
180-
StartDate: build.StartDate,
181-
FinishDate: build.FinishDate,
194+
QueuedDate: queuedTime,
195+
StartDate: startTime,
196+
FinishDate: finishTime,
182197
})
183198
}
184199
}
@@ -193,7 +208,7 @@ func createTestReport(pVersion provider.Version, tc TeamcityClient, gcs Cloudsto
193208

194209
// Upload test status data file to gcs bucket
195210
objectName := fmt.Sprintf("test-metadata/%s/%s", pVersion.String(), testStatusFileName)
196-
err = gcs.WriteToGCSBucket(NightlyDataBucket, objectName, testStatusFileName)
211+
err = gcs.WriteToGCSBucket(nightlyDataBucket, objectName, testStatusFileName)
197212
if err != nil {
198213
return err
199214
}

.ci/magician/cmd/create_test_failure_ticket.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func getTestInfoList(pVersion provider.Version, date time.Time, gcs Cloudstorage
268268
objectName := fmt.Sprintf("test-metadata/%s/%s", pVersion.String(), testStatusFileName)
269269

270270
var testInfoList []TestInfo
271-
err := gcs.DownloadFile(NightlyDataBucket, objectName, testStatusFileName)
271+
err := gcs.DownloadFile(nightlyDataBucket, objectName, testStatusFileName)
272272
if err != nil {
273273
return testInfoList, err
274274
}
@@ -506,13 +506,13 @@ func storeErrorMessage(pVersion provider.Version, gcs CloudstorageClient, errorM
506506

507507
// upload file to GCS
508508
objectName := fmt.Sprintf("test-errors/%s/%s/%s", pVersion.String(), date, fileName)
509-
err = gcs.WriteToGCSBucket(NightlyDataBucket, objectName, fileName)
509+
err = gcs.WriteToGCSBucket(nightlyDataBucket, objectName, fileName)
510510
if err != nil {
511511
return "", fmt.Errorf("failed to upload error message file %s to GCS bucket: %w", objectName, err)
512512
}
513513

514514
// compute object view path
515-
link := fmt.Sprintf("https://storage.cloud.google.com/%s/%s", NightlyDataBucket, objectName)
515+
link := fmt.Sprintf("https://storage.cloud.google.com/%s/%s", nightlyDataBucket, objectName)
516516
return link, nil
517517
}
518518

.ci/magician/cmd/templates/vcr/post_replay.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ None
3131
{{end}}
3232
</blockquote>
3333
</details>
34+
3435
{{ if gt (len .ReplayingResult.FailedTests) 0 -}}
3536
#### Action taken
3637
<details>
@@ -52,4 +53,4 @@ None
5253
{{- end}}
5354

5455
View the [build log](https://storage.cloud.google.com/{{.LogBucket}}/{{.Version}}/refs/heads/{{.Head}}/artifacts/{{.BuildID}}/build-log/replaying_test.log)
55-
{{- end}}
56+
{{- end}}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{{- if or (gt (len .NotRunBetaTests) 0) (gt (len .NotRunGATests) 0)}}
2+
#### Non-exercised tests
3+
4+
{{if gt (len .NotRunBetaTests) 0 -}}
5+
{{color "red" "Tests were added that are skipped in VCR:"}}
6+
{{range .NotRunBetaTests}}{{. | printf "- %s\n"}}{{end}}
7+
{{end}}
8+
9+
{{if gt (len .NotRunGATests) 0 -}}
10+
{{color "red" "Tests were added that are GA-only additions and require manual runs:"}}
11+
{{range .NotRunGATests}}{{. | printf "- %s\n"}}{{end}}
12+
{{end}}
13+
{{end}}
14+
#### Tests analytics
15+
Total tests: {{add (add (len .ReplayingResult.PassedTests) (len .ReplayingResult.SkippedTests)) (len .ReplayingResult.FailedTests) }}
16+
Passed tests: {{len .ReplayingResult.PassedTests}}
17+
Skipped tests: {{len .ReplayingResult.SkippedTests}}
18+
Affected tests: {{len .ReplayingResult.FailedTests}}
19+
20+
Affected service packages:
21+
{{if .RunFullVCR}}
22+
All service packages are affected
23+
{{else if gt (len .AffectedServices) 0}}
24+
{{range .AffectedServices}}
25+
`{{.}}` {{/* remove trailing whitespace */ -}}
26+
{{end}}
27+
{{else}}
28+
None
29+
{{end}}
30+
{{ if gt (len .ReplayingResult.FailedTests) 0 -}}
31+
#### Action taken
32+
Found {{len .ReplayingResult.FailedTests}} affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Affected tests:
33+
{{range .ReplayingResult.FailedTests}}
34+
`{{.}}` {{/* remove trailing whitespace */ -}}
35+
{{end}}
36+
37+
[Get to know how VCR tests work](https://googlecloudplatform.github.io/magic-modules/develop/test/test/)
38+
{{ else -}}
39+
{{- if .ReplayingErr -}}
40+
{{color "red" "Errors occurred during REPLAYING mode. Please fix them to complete your PR."}}
41+
{{- else -}}
42+
{{color "green" "All tests passed!"}}
43+
{{- end}}
44+
45+
View the [build log](https://storage.cloud.google.com/{{.LogBucket}}/{{.Version}}/refs/heads/{{.Head}}/artifacts/{{.BuildID}}/build-log/replaying_test.log)
46+
{{- end}}

.ci/magician/cmd/test_eap_vcr.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import (
1515
"github.com/spf13/cobra"
1616
)
1717

18+
var (
19+
//go:embed templates/vcr/post_replay_eap.tmpl
20+
postReplayEAPTmplText string
21+
)
22+
1823
var tevRequiredEnvironmentVariables = [...]string{
1924
"GEN_PATH",
2025
"GOCACHE",
@@ -31,7 +36,6 @@ var tevRequiredEnvironmentVariables = [...]string{
3136
"GOOGLE_IMPERSONATE_SERVICE_ACCOUNT",
3237
"KOKORO_ARTIFACTS_DIR",
3338
"HOME",
34-
"MODIFIED_FILE_PATH",
3539
"PATH",
3640
"USER",
3741
}
@@ -125,7 +129,7 @@ The following environment variables are required:
125129
return fmt.Errorf("wrong number of arguments %d, expected 1", len(args))
126130
}
127131

128-
return execTestEAPVCR(args[0], env["GEN_PATH"], env["KOKORO_ARTIFACTS_DIR"], env["MODIFIED_FILE_PATH"], rnr, vt)
132+
return execTestEAPVCR(args[0], env["GEN_PATH"], env["KOKORO_ARTIFACTS_DIR"], rnr, vt)
129133
},
130134
}
131135

@@ -137,7 +141,7 @@ func listTEVEnvironmentVariables() string {
137141
return result
138142
}
139143

140-
func execTestEAPVCR(changeNumber, genPath, kokoroArtifactsDir, modifiedFilePath string, rnr ExecRunner, vt *vcr.Tester) error {
144+
func execTestEAPVCR(changeNumber, genPath, kokoroArtifactsDir string, rnr ExecRunner, vt *vcr.Tester) error {
141145
vt.SetRepoPath(provider.Private, genPath)
142146
if err := rnr.PushDir(genPath); err != nil {
143147
return fmt.Errorf("error changing to gen path: %w", err)
@@ -190,7 +194,7 @@ func execTestEAPVCR(changeNumber, genPath, kokoroArtifactsDir, modifiedFilePath
190194
Version: provider.Private.String(),
191195
Head: head,
192196
}
193-
comment, err := formatPostReplay(postReplayData)
197+
comment, err := formatPostReplayEAP(postReplayData)
194198
if err != nil {
195199
return fmt.Errorf("error formatting post replay comment: %w", err)
196200
}
@@ -291,3 +295,7 @@ View the [build log](https://storage.cloud.google.com/ci-vcr-logs/%s/refs/heads/
291295
func init() {
292296
rootCmd.AddCommand(testEAPVCRCmd)
293297
}
298+
299+
func formatPostReplayEAP(data postReplay) (string, error) {
300+
return formatComment("post_replay_eap.tmpl", postReplayEAPTmplText, data)
301+
}

0 commit comments

Comments
 (0)