Skip to content

Commit 9ab437d

Browse files
authored
Improve test data ingestion (#14944)
1 parent c42046f commit 9ab437d

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
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

0 commit comments

Comments
 (0)