Skip to content

Commit efdd2ff

Browse files
committed
add new planned fields to models
1 parent 6a2cbe7 commit efdd2ff

File tree

1 file changed

+58
-11
lines changed

1 file changed

+58
-11
lines changed

internal/model/models.go

+58-11
Original file line numberDiff line numberDiff line change
@@ -16,67 +16,97 @@ import (
1616
type TestSuiteRun struct {
1717
// ID is the identifier of the test run.
1818
ID int `json:"id"`
19+
1920
// SuiteName is the name of the test suite that is run.
2021
SuiteName string `json:"suiteName"`
22+
2123
// Result is the outcome of the entire test suite run.
2224
Result Result `json:"result"`
25+
2326
// Tests counts the total amount of tests in the suite.
2427
Tests int `json:"tests"`
28+
2529
// Flaky is set to true if one or more tests only succeed
2630
// after being retried.
2731
Flaky bool `json:"flaky"`
32+
2833
// Params passed in to a run.
2934
Params RunParams `json:"params"`
35+
3036
// Scheduled is the time when the test was triggered, e.g.
3137
// through a http call.
3238
Scheduled time.Time `json:"scheduled"`
39+
3340
// Start is the time when the test run first started executing.
3441
Start time.Time `json:"start"`
42+
3543
// End is the time when the test run finished executing.
3644
End time.Time `json:"end"`
45+
3746
// DurationInMS is the test run execution times summed up.
3847
DurationInMS int64 `json:"durationInMs"`
48+
3949
// SetupLogs are the logs that are written during the setup phase.
4050
SetupLogs string `json:"setupLogs"`
51+
4152
// InitiatedBy is a reference to the initiator of this run (e.g. github web hook)
4253
InitiatedBy string `json:"initiatedBy"`
4354

44-
Reference string `json:"reference"`
55+
Reference string `json:"reference"`
56+
4557
IdempotencyKey string `json:"idempotencyKey"`
58+
4659
// Environment is additional information on where the tests are run (e.g. cluster name).
4760
Environment string `json:"environment"`
61+
4862
// TestResults contains the detailed test results of each test.
4963
TestResults []TestRun `json:"testResults"`
5064
}
5165

5266
type ScheduledRun struct {
5367
// Name is the name of the schedule.
5468
Name string
69+
5570
// TestSuiteName is the name of the test suite to be run.
5671
TestSuiteName string
72+
5773
// Schedule defines how often a run is scheduled. For the format see
5874
// https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format
5975
Schedule string
76+
6077
// TestFilter allows enabling/filtering only certain tests of a testsuite to be run
6178
TestFilter *regexp.Regexp
6279

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+
6587
// EntryID identifies the cronjob
6688
EntryID cron.EntryID
6789
}
6890

6991
type RunParams struct {
7092
// InitiatedBy e.g. jenkins, manual user initiated, scheduled run
7193
InitiatedBy string
94+
7295
// 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+
75101
MaxTestAttempts int
76102

77103
// IdempotencyKey is an optional param and if set avoids starting more than
78104
// one test run with this key (within 72 hours of the first occurence).
79105
IdempotencyKey string
106+
107+
// Timeout defines how long a test can run before it is cancelled.
108+
Timeout time.Duration
109+
80110
// TestFilter filters out a subset of the tests and skips the remaining ones.
81111
TestFilter *regexp.Regexp
82112
}
@@ -187,26 +217,37 @@ func (tsr TestSuiteRun) TestSuiteDuration() int64 {
187217
}
188218

189219
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+
193226
// Result is the outcome of the test run.
194227
Result Result `json:"result"`
228+
195229
// Test run attempt counter
196230
Attempt int `json:"attempt"`
231+
197232
// SoftFailure if set to true, does not fail a test suite when the test run fails.
198233
SoftFailure bool `json:"softFailure"`
234+
199235
// Logs contains log messages written by the test itself.
200236
Logs string `json:"logs"`
237+
201238
// Start marks the start time of the test run.
202239
Start time.Time `json:"start"`
240+
203241
// End marks the end time of the test run.
204242
End time.Time `json:"end"`
243+
205244
// DurationInMS is the duration of the test run in milliseconds (end-start).
206245
DurationInMS int64 `json:"durationInMs"`
246+
207247
// Spans are timings that can be created within a test that give more information
208248
// on how long certain parts of a test took.
209249
Spans []*Span `json:"spans"`
250+
210251
// Context contains additional testrun specific information that is collected during and
211252
// after a test run either by the test itself (`t.SetContext`) or via plugins. This can
212253
// 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)
300341
type TestSuite struct {
301342
// Name of the testsuite
302343
Name string `json:"name"`
344+
303345
// TestRetries is the amount of times a test is retried when failing.
304346
MaxTestAttempts int
347+
305348
// Namespace allows grouping of test suites, e.g. by team name.
306349
Namespace string
307-
Setup func() error
350+
351+
Setup func() error
352+
308353
// Description is used provided markdown text that describes the test suite.
309354
Description string
310-
Teardown func() error
311-
Tests map[string]TestFunc
355+
356+
Teardown func() error
357+
358+
Tests map[string]TestFunc
312359
// lock *sync.Mutex
313360
}
314361

0 commit comments

Comments
 (0)