-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresult.go
More file actions
77 lines (68 loc) · 1.87 KB
/
Copy pathresult.go
File metadata and controls
77 lines (68 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package probe
import (
"sync"
"time"
)
// StatusType represents the status of execution
type StatusType int
const (
StatusSuccess StatusType = iota
StatusError
StatusWarning
StatusSkipped
)
// StepRepeatCounter tracks the execution results of repeated steps
type StepRepeatCounter struct {
SuccessCount int
FailureCount int
Name string
LastResult bool
RepeatTotal int // Total number of times the step should be repeated
EchoOutputs []string // Formatted echo output captured per iteration
}
// StepResult represents the result of a step execution
type StepResult struct {
Index int
Name string
Status StatusType
StartedAt time.Time
RT string
RTSec float64
WaitTime string
TestOutput string
EchoOutput string
Report string
HasTest bool
RetryAttempt int // Number of attempts made (0 = retry not performed, 1 = succeeded first try)
RetryMax int // Maximum retry attempts configured
RepeatCounter *StepRepeatCounter // For repeat execution information
}
// JobResult stores execution results for a job
type JobResult struct {
JobName string
JobID string
Status string
StartTime time.Time
EndTime time.Time
Success bool
StepResults []StepResult // Store all step results for this job
mutex sync.Mutex
}
// Result manages execution results for multiple jobs
type Result struct {
Jobs map[string]*JobResult
}
// NewResult creates a new Result instance
func NewResult() *Result {
return &Result{
Jobs: make(map[string]*JobResult),
}
}
// AddStepResult adds a StepResult to the specified job result
func (rs *Result) AddStepResult(jobID string, stepResult StepResult) {
if jr, exists := rs.Jobs[jobID]; exists {
jr.mutex.Lock()
defer jr.mutex.Unlock()
jr.StepResults = append(jr.StepResults, stepResult)
}
}