@@ -364,6 +364,22 @@ func (submitter *Submitter) submitRun(
364364 return readyRuns , err
365365}
366366
367+ func (submitter * Submitter ) updateSubmittedRunIds (
368+ submittedRuns map [string ]* TestRun ,
369+ launchedRuns * galasaapi.TestRuns ,
370+ ) {
371+ for _ , currentRun := range launchedRuns .GetRuns () {
372+ runName := currentRun .GetName ()
373+
374+ submittedRun , ok := submittedRuns [runName ]
375+ if ok {
376+ if submittedRun .RunId == "" && currentRun .HasRasRunId () {
377+ submittedRun .RunId = currentRun .GetRasRunId ()
378+ }
379+ }
380+ }
381+ }
382+
367383func (submitter * Submitter ) runsFetchCurrentStatus (
368384 groupName string ,
369385 submittedRuns map [string ]* TestRun ,
@@ -377,6 +393,9 @@ func (submitter *Submitter) runsFetchCurrentStatus(
377393 return
378394 }
379395
396+ // Launched runs will now have run IDs, so record the run IDs for the submitted runs
397+ submitter .updateSubmittedRunIds (submittedRuns , currentGroup )
398+
380399 // a copy to find lost runs
381400 checkRuns := DeepClone (submittedRuns )
382401
@@ -390,49 +409,7 @@ func (submitter *Submitter) runsFetchCurrentStatus(
390409
391410 // now check to see if it is finished
392411 if currentRun .GetStatus () == "finished" {
393-
394- finishedRuns [runName ] = checkRun
395-
396- checkRun .Status = * currentRun .Status
397-
398- delete (submittedRuns , runName )
399-
400- result := "unknown"
401- if currentRun .HasResult () {
402- result = currentRun .GetResult ()
403- }
404- checkRun .Result = result
405-
406- // Extract the ras run result to get the method names if a report is requested
407- rasRunID := currentRun .RasRunId
408- if fetchRas && rasRunID != nil {
409-
410- var rasRun * galasaapi.Run
411- rasRun , err = submitter .launcher .GetRunsById (* rasRunID )
412- if err != nil {
413- log .Printf ("runsFetchCurrentStatus - Failed to retrieve RAS run for %v - %v\n " , checkRun .Name , err )
414- } else {
415- checkRun .Tests = make ([]TestMethod , 0 )
416-
417- testStructure := rasRun .GetTestStructure ()
418- log .Printf ("runsFetchCurrentStatus - testStructure- %v" , testStructure )
419-
420- for _ , testMethod := range testStructure .GetMethods () {
421- test := TestMethod {
422- Method : testMethod .GetMethodName (),
423- Result : testMethod .GetResult (),
424- }
425-
426- checkRun .Tests = append (checkRun .Tests , test )
427- }
428- }
429- }
430-
431- if checkRun .GherkinUrl != "" {
432- log .Printf ("Run %v has finished(%v) - %v (Gherkin)\n " , runName , result , checkRun .GherkinFeature )
433- } else {
434- log .Printf ("Run %v has finished(%v) - %v/%v/%v - %s\n " , runName , result , checkRun .Stream , checkRun .Bundle , checkRun .Class , currentRun .GetStatus ())
435- }
412+ submitter .markRunFinished (checkRun , currentRun .GetResult (), submittedRuns , finishedRuns , fetchRas )
436413 } else {
437414 // Check to see if there was a status change
438415 if checkRun .Status != currentRun .GetStatus () {
@@ -448,12 +425,102 @@ func (submitter *Submitter) runsFetchCurrentStatus(
448425 }
449426
450427 // Now deal with the lost runs
451- for runName , lostRun := range checkRuns {
452- lostRuns [runName ] = lostRun
453- delete (submittedRuns , runName )
454- log .Printf ("Run %v was lost - %v/%v/%v\n " , runName , lostRun .Stream , lostRun .Bundle , lostRun .Class )
428+ submitter .processLostRuns (checkRuns , submittedRuns , finishedRuns , lostRuns , fetchRas )
429+ }
430+
431+ func (submitter * Submitter ) processLostRuns (
432+ runsToCheck map [string ]* TestRun ,
433+ submittedRuns map [string ]* TestRun ,
434+ finishedRuns map [string ]* TestRun ,
435+ lostRuns map [string ]* TestRun ,
436+ fetchRas bool ,
437+ ) {
438+ var err error
439+
440+ for runName , possiblyLostRun := range runsToCheck {
441+ isRunLost := true
442+
443+ if possiblyLostRun .RunId != "" {
444+ // Check the RAS to see if the run has been saved
445+ var rasRun * galasaapi.Run
446+ rasRun , err = submitter .launcher .GetRunsById (possiblyLostRun .RunId )
447+ if err != nil {
448+ log .Printf ("processLostRuns - Failed to retrieve RAS run for %v - %v\n " , possiblyLostRun .Name , err )
449+ } else {
450+ if rasRun != nil {
451+ // The run was found in the RAS, not in the DSS
452+ isRunLost = false
453+
454+ testStructure := rasRun .GetTestStructure ()
455+ runStatus := testStructure .GetStatus ()
456+ if runStatus == "finished" {
457+
458+ // The run has finished, so we no longer need to check its status
459+ submitter .markRunFinished (possiblyLostRun , testStructure .GetResult (), submittedRuns , finishedRuns , fetchRas )
460+ }
461+ }
462+ }
463+ }
464+
465+ // The run wasn't found in the DSS or the RAS, so mark it as lost
466+ if isRunLost {
467+ lostRuns [runName ] = possiblyLostRun
468+ delete (submittedRuns , runName )
469+ log .Printf ("Run %v was lost - %v/%v/%v\n " , runName , possiblyLostRun .Stream , possiblyLostRun .Bundle , possiblyLostRun .Class )
470+ }
455471 }
472+ }
473+
474+ func (submitter * Submitter ) markRunFinished (
475+ runToMarkFinished * TestRun ,
476+ result string ,
477+ submittedRuns map [string ]* TestRun ,
478+ finishedRuns map [string ]* TestRun ,
479+ fetchRas bool ,
480+ ) {
481+ var err error
456482
483+ runName := runToMarkFinished .Name
484+ finishedRuns [runName ] = runToMarkFinished
485+ delete (submittedRuns , runName )
486+
487+ if result == "" {
488+ result = "unknown"
489+ }
490+
491+ runToMarkFinished .Result = result
492+ runToMarkFinished .Status = "finished"
493+
494+ // Extract the ras run result to get the method names if a report is requested
495+ rasRunID := runToMarkFinished .RunId
496+ if fetchRas && rasRunID != "" {
497+
498+ var rasRun * galasaapi.Run
499+ rasRun , err = submitter .launcher .GetRunsById (rasRunID )
500+ if err != nil {
501+ log .Printf ("runsFetchCurrentStatus - Failed to retrieve RAS run for %v - %v\n " , runName , err )
502+ } else {
503+ runToMarkFinished .Tests = make ([]TestMethod , 0 )
504+
505+ testStructure := rasRun .GetTestStructure ()
506+ log .Printf ("runsFetchCurrentStatus - testStructure- %v" , testStructure )
507+
508+ for _ , testMethod := range testStructure .GetMethods () {
509+ test := TestMethod {
510+ Method : testMethod .GetMethodName (),
511+ Result : testMethod .GetResult (),
512+ }
513+
514+ runToMarkFinished .Tests = append (runToMarkFinished .Tests , test )
515+ }
516+ }
517+ }
518+
519+ if runToMarkFinished .GherkinUrl != "" {
520+ log .Printf ("Run %v has finished(%v) - %v (Gherkin)\n " , runName , result , runToMarkFinished .GherkinFeature )
521+ } else {
522+ log .Printf ("Run %v has finished(%v) - %v/%v/%v - %s\n " , runName , runToMarkFinished .Result , runToMarkFinished .Stream , runToMarkFinished .Bundle , runToMarkFinished .Class , runToMarkFinished .Status )
523+ }
457524}
458525
459526func (submitter * Submitter ) createReports (params utils.RunsSubmitCmdValues ,
0 commit comments