@@ -14,6 +14,7 @@ import (
1414 "context"
1515 "fmt"
1616 "os"
17+ "time"
1718
1819 "github.com/cockroachdb/cockroach/pkg/cmd/internal/issues"
1920 "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
@@ -98,14 +99,18 @@ func (g *githubIssues) shouldPost(t test.Test) (bool, string) {
9899}
99100
100101func (g * githubIssues ) createPostRequest (
101- t test.Test , firstFailure failure , message string ,
102- ) issues.PostRequest {
102+ testName string ,
103+ start time.Time ,
104+ end time.Time ,
105+ spec * registry.TestSpec ,
106+ firstFailure failure ,
107+ message string ,
108+ ) (issues.PostRequest , error ) {
103109 var mention []string
104110 var projColID int
105111
106- spec := t .Spec ().(* registry.TestSpec )
107112 issueOwner := spec .Owner
108- issueName := t . Name ()
113+ issueName := testName
109114
110115 messagePrefix := ""
111116 var infraFlake bool
@@ -114,15 +119,15 @@ func (g *githubIssues) createPostRequest(
114119 case failureContainsError (firstFailure , errClusterProvisioningFailed ):
115120 issueOwner = registry .OwnerDevInf
116121 issueName = "cluster_creation"
117- messagePrefix = fmt .Sprintf ("test %s was skipped due to " , t . Name () )
122+ messagePrefix = fmt .Sprintf ("test %s was skipped due to " , testName )
118123 infraFlake = true
119124 case failureContainsError (firstFailure , rperrors .ErrSSH255 ):
120125 issueOwner = registry .OwnerTestEng
121126 issueName = "ssh_problem"
122- messagePrefix = fmt .Sprintf ("test %s failed due to " , t . Name () )
127+ messagePrefix = fmt .Sprintf ("test %s failed due to " , testName )
123128 infraFlake = true
124129 case failureContainsError (firstFailure , errDuringPostAssertions ):
125- messagePrefix = fmt .Sprintf ("test %s failed during post test assertions (see test-post-assertions.log) due to " , t . Name () )
130+ messagePrefix = fmt .Sprintf ("test %s failed during post test assertions (see test-post-assertions.log) due to " , testName )
126131 }
127132
128133 // Issues posted from roachtest are identifiable as such, and they are also release blockers
@@ -134,7 +139,7 @@ func (g *githubIssues) createPostRequest(
134139
135140 teams , err := g .teamLoader ()
136141 if err != nil {
137- t . Fatalf ( "could not load teams: %v" , err )
142+ return issues. PostRequest {} , err
138143 }
139144
140145 if sl , ok := teams .GetAliasesForPurpose (ownerToAlias (issueOwner ), team .PurposeRoachtest ); ok {
@@ -152,7 +157,7 @@ func (g *githubIssues) createPostRequest(
152157 branch = "<unknown branch>"
153158 }
154159
155- artifacts := fmt .Sprintf ("/%s" , t . Name () )
160+ artifacts := fmt .Sprintf ("/%s" , testName )
156161
157162 clusterParams := map [string ]string {
158163 roachtestPrefix ("cloud" ): spec .Cluster .Cloud ,
@@ -202,7 +207,7 @@ func (g *githubIssues) createPostRequest(
202207 "https://cockroachlabs.atlassian.net/l/c/SSSBr8c7" ,
203208 )(renderer )
204209 },
205- }
210+ }, nil
206211}
207212
208213func (g * githubIssues ) MaybePost (t * testImpl , l * logger.Logger , message string ) error {
@@ -212,10 +217,15 @@ func (g *githubIssues) MaybePost(t *testImpl, l *logger.Logger, message string)
212217 return nil
213218 }
214219
220+ postRequest , err := g .createPostRequest (t .Name (), t .start , t .end , t .spec , t .firstFailure (), message )
221+ if err != nil {
222+ return err
223+ }
224+
215225 return g .issuePoster (
216226 context .Background (),
217227 l ,
218228 issues .UnitTestFormatter ,
219- g . createPostRequest ( t , t . firstFailure (), message ) ,
229+ postRequest ,
220230 )
221231}
0 commit comments