@@ -16,67 +16,97 @@ import (
16
16
type TestSuiteRun struct {
17
17
// ID is the identifier of the test run.
18
18
ID int `json:"id"`
19
+
19
20
// SuiteName is the name of the test suite that is run.
20
21
SuiteName string `json:"suiteName"`
22
+
21
23
// Result is the outcome of the entire test suite run.
22
24
Result Result `json:"result"`
25
+
23
26
// Tests counts the total amount of tests in the suite.
24
27
Tests int `json:"tests"`
28
+
25
29
// Flaky is set to true if one or more tests only succeed
26
30
// after being retried.
27
31
Flaky bool `json:"flaky"`
32
+
28
33
// Params passed in to a run.
29
34
Params RunParams `json:"params"`
35
+
30
36
// Scheduled is the time when the test was triggered, e.g.
31
37
// through a http call.
32
38
Scheduled time.Time `json:"scheduled"`
39
+
33
40
// Start is the time when the test run first started executing.
34
41
Start time.Time `json:"start"`
42
+
35
43
// End is the time when the test run finished executing.
36
44
End time.Time `json:"end"`
45
+
37
46
// DurationInMS is the test run execution times summed up.
38
47
DurationInMS int64 `json:"durationInMs"`
48
+
39
49
// SetupLogs are the logs that are written during the setup phase.
40
50
SetupLogs string `json:"setupLogs"`
51
+
41
52
// InitiatedBy is a reference to the initiator of this run (e.g. github web hook)
42
53
InitiatedBy string `json:"initiatedBy"`
43
54
44
- Reference string `json:"reference"`
55
+ Reference string `json:"reference"`
56
+
45
57
IdempotencyKey string `json:"idempotencyKey"`
58
+
46
59
// Environment is additional information on where the tests are run (e.g. cluster name).
47
60
Environment string `json:"environment"`
61
+
48
62
// TestResults contains the detailed test results of each test.
49
63
TestResults []TestRun `json:"testResults"`
50
64
}
51
65
52
66
type ScheduledRun struct {
53
67
// Name is the name of the schedule.
54
68
Name string
69
+
55
70
// TestSuiteName is the name of the test suite to be run.
56
71
TestSuiteName string
72
+
57
73
// Schedule defines how often a run is scheduled. For the format see
58
74
// https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format
59
75
Schedule string
76
+
60
77
// TestFilter allows enabling/filtering only certain tests of a testsuite to be run
61
78
TestFilter * regexp.Regexp
62
79
63
- // TODO: make it possible to stop scheduled runs after a # of runs or after a certain amount of time
64
- StopAfter string
80
+ // RunCount is the number of times a scheduled run has run in the past.
81
+ RunCount int
82
+
83
+ // MaxRuns allows you to set a limit on how often a scheduled run is executed.
84
+ // If set to 0 it will run forever.
85
+ MaxRuns int
86
+
65
87
// EntryID identifies the cronjob
66
88
EntryID cron.EntryID
67
89
}
68
90
69
91
type RunParams struct {
70
92
// InitiatedBy e.g. jenkins, manual user initiated, scheduled run
71
93
InitiatedBy string
94
+
72
95
// Reference can be set when starting a new test suite run to identify
73
- // a test run by a user provided value.
74
- Reference string
96
+ // a test run by a user provided value, e.g. a when started in the web ui
97
+ // you can add something like "manual test by user foo" to easily find this
98
+ // run later.
99
+ Reference string
100
+
75
101
MaxTestAttempts int
76
102
77
103
// IdempotencyKey is an optional param and if set avoids starting more than
78
104
// one test run with this key (within 72 hours of the first occurence).
79
105
IdempotencyKey string
106
+
107
+ // Timeout defines how long a test can run before it is cancelled.
108
+ Timeout time.Duration
109
+
80
110
// TestFilter filters out a subset of the tests and skips the remaining ones.
81
111
TestFilter * regexp.Regexp
82
112
}
@@ -187,26 +217,37 @@ func (tsr TestSuiteRun) TestSuiteDuration() int64 {
187
217
}
188
218
189
219
type TestRun struct {
190
- SuiteName string `json:"suiteName"`
191
- SuiteRunID int `json:"suiteRunId"`
192
- Name string `json:"name"`
220
+ SuiteName string `json:"suiteName"`
221
+
222
+ SuiteRunID int `json:"suiteRunId"`
223
+
224
+ Name string `json:"name"`
225
+
193
226
// Result is the outcome of the test run.
194
227
Result Result `json:"result"`
228
+
195
229
// Test run attempt counter
196
230
Attempt int `json:"attempt"`
231
+
197
232
// SoftFailure if set to true, does not fail a test suite when the test run fails.
198
233
SoftFailure bool `json:"softFailure"`
234
+
199
235
// Logs contains log messages written by the test itself.
200
236
Logs string `json:"logs"`
237
+
201
238
// Start marks the start time of the test run.
202
239
Start time.Time `json:"start"`
240
+
203
241
// End marks the end time of the test run.
204
242
End time.Time `json:"end"`
243
+
205
244
// DurationInMS is the duration of the test run in milliseconds (end-start).
206
245
DurationInMS int64 `json:"durationInMs"`
246
+
207
247
// Spans are timings that can be created within a test that give more information
208
248
// on how long certain parts of a test took.
209
249
Spans []* Span `json:"spans"`
250
+
210
251
// Context contains additional testrun specific information that is collected during and
211
252
// after a test run either by the test itself (`t.SetContext`) or via plugins. This can
212
253
// e.g. contain correlation ids or links to external services that may help debugging a test run
@@ -300,15 +341,21 @@ type TestFunc func(t TB)
300
341
type TestSuite struct {
301
342
// Name of the testsuite
302
343
Name string `json:"name"`
344
+
303
345
// TestRetries is the amount of times a test is retried when failing.
304
346
MaxTestAttempts int
347
+
305
348
// Namespace allows grouping of test suites, e.g. by team name.
306
349
Namespace string
307
- Setup func () error
350
+
351
+ Setup func () error
352
+
308
353
// Description is used provided markdown text that describes the test suite.
309
354
Description string
310
- Teardown func () error
311
- Tests map [string ]TestFunc
355
+
356
+ Teardown func () error
357
+
358
+ Tests map [string ]TestFunc
312
359
// lock *sync.Mutex
313
360
}
314
361
0 commit comments