@@ -62,9 +62,15 @@ func init() {
62
62
var (
63
63
errTestsFailed = fmt .Errorf ("some tests failed" )
64
64
65
- // reference error used by main.go at the end of a run of tests
65
+ // errSomeClusterProvisioningFailed error sent after a run in
66
+ // [testRunner.Run] if any worker encountered a cluster provisioning error.
67
+ // Used in main.go to determine the run exit code.
66
68
errSomeClusterProvisioningFailed = fmt .Errorf ("some clusters could not be created" )
67
69
70
+ // errGithubPostFailed error sent after a run in [testRunner.Run] if any
71
+ // worker encountered an error when trying to POST to GitHub
72
+ errGithubPostFailed = fmt .Errorf ("failed to POST to GitHub" )
73
+
68
74
prometheusNameSpace = "roachtest"
69
75
// prometheusScrapeInterval should be consistent with the scrape interval defined in
70
76
// https://grafana.testeng.crdb.io/prometheus/config
@@ -174,8 +180,11 @@ type testRunner struct {
174
180
completed []completedTestInfo
175
181
}
176
182
177
- // Counts cluster creation errors across all workers.
183
+ // numClusterErrs Counts cluster creation errors across all workers.
178
184
numClusterErrs int32
185
+
186
+ // numGithubPostErrs Counts GitHub post errors across all workers
187
+ numGithubPostErrs int32
179
188
}
180
189
181
190
type perfMetricsCollector struct {
@@ -308,6 +317,7 @@ func (r *testRunner) Run(
308
317
clustersOpt clustersOpt ,
309
318
topt testOpts ,
310
319
lopt loggingOpt ,
320
+ github GithubPoster ,
311
321
) error {
312
322
// Validate options.
313
323
if len (tests ) == 0 {
@@ -411,6 +421,7 @@ func (r *testRunner) Run(
411
421
topt ,
412
422
childLogger ,
413
423
n * count ,
424
+ github ,
414
425
)
415
426
416
427
if err != nil {
@@ -448,14 +459,25 @@ func (r *testRunner) Run(
448
459
passFailLine := r .generateReport ()
449
460
shout (ctx , l , lopt .stdout , passFailLine )
450
461
462
+ // For the errors that don't short-circuit the pipeline run, return a joined
463
+ // error and leave case handling to the caller
464
+ var err error
465
+ if r .numGithubPostErrs > 0 {
466
+ shout (ctx , l , lopt .stdout , "%d errors occurred while posting to github" , r .numGithubPostErrs )
467
+ err = errors .Join (err , errGithubPostFailed )
468
+ }
451
469
if r .numClusterErrs > 0 {
452
470
shout (ctx , l , lopt .stdout , "%d clusters could not be created" , r .numClusterErrs )
453
- return errSomeClusterProvisioningFailed
471
+ err = errors . Join ( err , errSomeClusterProvisioningFailed )
454
472
}
455
-
456
473
if len (r .status .fail ) > 0 {
457
- return errTestsFailed
474
+ shout (ctx , l , lopt .stdout , "%d tests failed" , r .status .fail )
475
+ err = errors .Join (err , errTestsFailed )
476
+ }
477
+ if err != nil {
478
+ return err
458
479
}
480
+
459
481
// To ensure all prometheus metrics have been scraped, ensure shutdown takes
460
482
// at least one scrapeInterval, unless the roachtest fails or gets cancelled.
461
483
requiredShutDownTime := prometheusScrapeInterval
@@ -596,6 +618,7 @@ func (r *testRunner) runWorker(
596
618
topt testOpts ,
597
619
l * logger.Logger ,
598
620
maxTotalFailures int ,
621
+ github GithubPoster ,
599
622
) error {
600
623
stdout := lopt .stdout
601
624
@@ -841,18 +864,22 @@ func (r *testRunner) runWorker(
841
864
runID : generateRunID (clustersOpt ),
842
865
}
843
866
t .ReplaceL (testL )
844
- github := newGithubIssues (r .config .disableIssue , c , vmCreateOpts )
845
-
867
+ issueInfo := newGithubIssueInfo (c , vmCreateOpts )
846
868
// handleClusterCreationFailure can be called when the `err` given
847
869
// occurred for reasons related to creating or setting up a
848
870
// cluster for a test.
849
- handleClusterCreationFailure := func (err error ) {
850
- t .Error (errClusterProvisioningFailed (err ))
851
-
852
- params := getTestParameters (t , github .cluster , github .vmCreateOpts )
871
+ handleClusterCreationFailure := func (clusterCreateErr error ) {
872
+ t .Error (errClusterProvisioningFailed (clusterCreateErr ))
873
+
874
+ // Technically don't need the issueInfo struct here because we have access
875
+ // to the clusterImpl and vm.CreateOpts in runWorker()
876
+ // but not in runTests() so keeping the invocation of getTestParameters()
877
+ // the same in both spots
878
+ params := getTestParameters (t , issueInfo .cluster , issueInfo .vmCreateOpts )
853
879
logTestParameters (l , params )
854
- if _ , err := github .MaybePost (t , l , t .failureMsg (), params ); err != nil {
855
- shout (ctx , l , stdout , "failed to post issue: %s" , err )
880
+ if _ , githubErr := github .MaybePost (t , issueInfo , l , t .failureMsg (), params ); githubErr != nil {
881
+ atomic .AddInt32 (& r .numGithubPostErrs , 1 )
882
+ shout (ctx , l , stdout , "failed to post issue: %s" , githubErr )
856
883
}
857
884
}
858
885
@@ -978,7 +1005,8 @@ func (r *testRunner) runWorker(
978
1005
wStatus .SetTest (t , testToRun )
979
1006
wStatus .SetStatus ("running test" )
980
1007
981
- r .runTest (ctx , t , testToRun .runNum , testToRun .runCount , c , stdout , testL , github )
1008
+ r .runTest (ctx , t , testToRun .runNum , testToRun .runCount , c , stdout , testL ,
1009
+ github , issueInfo )
982
1010
}
983
1011
}
984
1012
@@ -1135,7 +1163,8 @@ func (r *testRunner) runTest(
1135
1163
c * clusterImpl ,
1136
1164
stdout io.Writer ,
1137
1165
l * logger.Logger ,
1138
- github * githubIssues ,
1166
+ github GithubPoster ,
1167
+ issueInfo * githubIssueInfo ,
1139
1168
) {
1140
1169
testRunID := t .Name ()
1141
1170
if runCount > 1 {
@@ -1238,11 +1267,12 @@ func (r *testRunner) runTest(
1238
1267
}
1239
1268
1240
1269
output := fmt .Sprintf ("%s\n test artifacts and logs in: %s" , failureMsg , t .ArtifactsDir ())
1241
- params := getTestParameters (t , github .cluster , github .vmCreateOpts )
1270
+ params := getTestParameters (t , issueInfo .cluster , issueInfo .vmCreateOpts )
1242
1271
logTestParameters (l , params )
1243
- issue , err := github .MaybePost (t , l , output , params )
1272
+ issue , err := github .MaybePost (t , issueInfo , l , output , params )
1244
1273
if err != nil {
1245
1274
shout (ctx , l , stdout , "failed to post issue: %s" , err )
1275
+ atomic .AddInt32 (& r .numGithubPostErrs , 1 )
1246
1276
}
1247
1277
1248
1278
// If an issue was created (or comment added) on GitHub,
0 commit comments