Skip to content

Commit 1bd4eb0

Browse files
authored
Sync feature branch resource identity generation (#14963)
2 parents 0943cd6 + 4079bfd commit 1bd4eb0

File tree

163 files changed

+4894
-1171
lines changed

Some content is hidden

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

163 files changed

+4894
-1171
lines changed

.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

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: 10 additions & 1 deletion
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",
@@ -189,7 +194,7 @@ func execTestEAPVCR(changeNumber, genPath, kokoroArtifactsDir string, rnr ExecRu
189194
Version: provider.Private.String(),
190195
Head: head,
191196
}
192-
comment, err := formatPostReplay(postReplayData)
197+
comment, err := formatPostReplayEAP(postReplayData)
193198
if err != nil {
194199
return fmt.Errorf("error formatting post replay comment: %w", err)
195200
}
@@ -290,3 +295,7 @@ View the [build log](https://storage.cloud.google.com/ci-vcr-logs/%s/refs/heads/
290295
func init() {
291296
rootCmd.AddCommand(testEAPVCRCmd)
292297
}
298+
299+
func formatPostReplayEAP(data postReplay) (string, error) {
300+
return formatComment("post_replay_eap.tmpl", postReplayEAPTmplText, data)
301+
}

0 commit comments

Comments
 (0)