Skip to content

Commit 57569d4

Browse files
authored
Merge pull request #163 from vjt/feature/143
Add support for cleanup steps
2 parents 4d6d981 + 23654f4 commit 57569d4

File tree

37 files changed

+688
-285
lines changed

37 files changed

+688
-285
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"JobName": "test job",
3+
"Runs": 1,
4+
"RunInterval": "3s",
5+
"Tags": [
6+
"test",
7+
"csv"
8+
],
9+
"TestDescriptors": [
10+
{
11+
"TargetManagerName": "TargetList",
12+
"TargetManagerAcquireParameters": {
13+
"Targets": [
14+
{
15+
"FQDN": "example.org",
16+
"ID": "1234"
17+
}
18+
]
19+
},
20+
"TargetManagerReleaseParameters": {},
21+
"TestFetcherName": "literal",
22+
"TestFetcherFetchParameters": {
23+
"TestName": "Literal test",
24+
"Steps": [
25+
{
26+
"name": "cmd",
27+
"label": "echoStep",
28+
"parameters": {
29+
"executable": [
30+
"/bin/echo"
31+
],
32+
"args": [
33+
"Title={{ Title .FQDN }}, ToUpper={{ ToUpper .FQDN }}"
34+
]
35+
}
36+
}
37+
]
38+
},
39+
"CleanupFetcherName": "literal",
40+
"CleanupFetcherFetchParameters": {
41+
"Steps": [
42+
{
43+
"name": "cmd",
44+
"label": "echoCleanup",
45+
"parameters": {
46+
"executable": [
47+
"/bin/echo"
48+
],
49+
"args": [
50+
"THIS IS A CLEANUP STEP"
51+
]
52+
}
53+
}
54+
]
55+
}
56+
}
57+
],
58+
"Reporting": {
59+
"RunReporters": [
60+
{
61+
"Name": "TargetSuccess",
62+
"Parameters": {
63+
"SuccessExpression": "=100%"
64+
}
65+
}
66+
]
67+
}
68+
}

docker/contest/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fi
3939

4040
# Run integration tests collecting coverage only for the business logic (pkg directory)
4141
i=1
42-
for tag in integration integration_storage; do
42+
for tag in integration integration_admin integration_storage; do
4343
echo "Running integration tests with tag \"${tag}\""
4444
for d in $(go list -tags=${tag} ./tests/... | grep -Ev "integ$|common$|vendor"); do
4545
pflag=""

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ require (
3131
go.uber.org/atomic v1.9.0
3232
go.uber.org/zap v1.19.1
3333
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
34+
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc
3435
gopkg.in/yaml.v2 v2.4.0
3536
gopkg.in/yaml.v3 v3.0.1
3637
)
@@ -81,12 +82,11 @@ require (
8182
github.com/xdg-go/stringprep v1.0.2 // indirect
8283
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
8384
go.uber.org/multierr v1.7.0 // indirect
84-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
85+
golang.org/x/net v0.1.0 // indirect
8586
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
86-
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
87-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
88-
golang.org/x/text v0.3.7 // indirect
89-
golang.org/x/tools v0.1.12 // indirect
87+
golang.org/x/sys v0.1.0 // indirect
88+
golang.org/x/term v0.1.0 // indirect
89+
golang.org/x/text v0.4.0 // indirect
9090
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
9191
google.golang.org/grpc v1.31.0 // indirect
9292
google.golang.org/protobuf v1.28.0 // indirect

go.sum

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
153153
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
154154
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
155155
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
156-
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
157156
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
157+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
158158
github.com/google/go-safeweb v0.0.0-20211026121254-697f59a9d57f h1:yA8MLwNYjLVI8VZn7MEfiKFBx1vuuZVPuc9fcwytiz8=
159159
github.com/google/go-safeweb v0.0.0-20211026121254-697f59a9d57f/go.mod h1:Y/uYEmZs5exq8iiX9djfwjg1IkSo4183aw7DTSkb6KU=
160160
github.com/google/goexpect v0.0.0-20200703111054-623d5ca06f56 h1:sXtmz0BQBeXxoxCNb376WLx6r9HKVTJvD4PQQ/kL604=
@@ -395,6 +395,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
395395
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
396396
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
397397
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
398+
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU=
399+
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
398400
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
399401
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
400402
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -416,7 +418,7 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
416418
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
417419
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
418420
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
419-
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
421+
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
420422
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
421423
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
422424
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -454,8 +456,8 @@ golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qx
454456
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
455457
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
456458
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
457-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
458-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
459+
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
460+
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
459461
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
460462
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
461463
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -528,21 +530,23 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc
528530
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
529531
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
530532
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
531-
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg=
532-
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
533+
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
534+
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
533535
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
534536
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
535-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
536537
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
538+
golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw=
539+
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
537540
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
538541
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
539542
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
540543
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
541544
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
542545
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
543546
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
544-
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
545547
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
548+
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
549+
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
546550
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
547551
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
548552
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -591,8 +595,7 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc
591595
golang.org/x/tools v0.0.0-20200915201639-f4cefd1cb5ba/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
592596
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
593597
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
594-
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
595-
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
598+
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
596599
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
597600
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
598601
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

pkg/event/testevent/test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func New(header *Header, data *Data) Event {
5454
type Query struct {
5555
event.Query
5656
RunID types.RunID
57-
TestName string
57+
TestNames []string
5858
TestStepLabel string
5959
}
6060

@@ -88,7 +88,7 @@ type queryFieldJobID types.JobID
8888
type queryFieldEventNames []event.Name
8989
type queryFieldEmittedStartTime time.Time
9090
type queryFieldEmittedEndTime time.Time
91-
type queryFieldTestName string
91+
type queryFieldTestNames []string
9292
type queryFieldTestStepLabel string
9393
type queryFieldRunID types.RunID
9494

@@ -122,10 +122,10 @@ func (value queryFieldEmittedEndTime) queryFieldPointer(query *Query) interface{
122122
}
123123

124124
// QueryTestName sets the TestName field of the Query object
125-
func QueryTestName(testName string) QueryField {
126-
return queryFieldTestName(testName)
125+
func QueryTestNames(testNames []string) QueryField {
126+
return queryFieldTestNames(testNames)
127127
}
128-
func (value queryFieldTestName) queryFieldPointer(query *Query) interface{} { return &query.TestName }
128+
func (value queryFieldTestNames) queryFieldPointer(query *Query) interface{} { return &query.TestNames }
129129

130130
// QueryTestStepLabel sets the TestStepLabel field of the Query object
131131
func QueryTestStepLabel(testStepLabel string) QueryField {

pkg/job/events.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,13 @@ type PauseEventPayload struct {
9292
NextTestAttempt *time.Time `json:"NTA,omitempty"`
9393
// If we are sleeping before the run, this will specify when the run should begin.
9494
StartAt *time.Time `json:"S,omitempty"`
95-
// Otherwise, if test execution is in progress targets and runner state will be populated.
96-
Targets []*target.Target `json:"TT,omitempty"`
97-
TestRunnerState json.RawMessage `json:"TRS,omitempty"`
95+
// Otherwise, if test execution is in progress targets and runner states will be populated.
96+
Targets []*target.Target `json:"TT,omitempty"`
97+
// Tests are run by the job runner serially. These two objects are interlinked, but by the
98+
// nature of the serial run inside the job runner they cannot diverge, because they are saved
99+
// together at the same time and as well restored together at the same time.
100+
TestRunnerState json.RawMessage `json:"TRS,omitempty"`
101+
CleanupRunnerState json.RawMessage `json:"CRS,omitempty"`
98102
}
99103

100104
func (pp *PauseEventPayload) String() string {

pkg/job/job.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,28 @@ func (d *Descriptor) Validate() error {
6666
// version against the supported one
6767
func (d *Descriptor) CheckVersion() error {
6868
if d.Version == "" {
69-
return fmt.Errorf("Version Error: Empty Job Descriptor Version Field!")
69+
return fmt.Errorf("version Error: Empty Job Descriptor Version Field")
7070
}
7171
// Convert the version string into 2 numbers
7272
versionNums := strings.Split(d.Version, ".")
7373
if len(versionNums) != 2 {
74-
return fmt.Errorf("Version Error: Incorrect Job Descriptor Version %v", d.Version)
74+
return fmt.Errorf("version Error: Incorrect Job Descriptor Version %v", d.Version)
7575
}
7676
majorVersion, err := strconv.Atoi(versionNums[0])
7777
if err != nil {
78-
return fmt.Errorf("Version Error: %w", err)
78+
return fmt.Errorf("version Error: %w", err)
7979
}
8080
minorVersion, err := strconv.Atoi(versionNums[1])
8181
if err != nil {
82-
return fmt.Errorf("Version Error: %w", err)
82+
return fmt.Errorf("version Error: %w", err)
8383
}
8484

8585
// checks the major, minor numbers against the supported version
8686
// If the major don't match of the minor is ahead of the currently supported
8787
// , return an error msg
8888
if majorVersion != int(JobDescriptorMajorVersion) || minorVersion > int(JobDescriptorMinorVersion) {
8989
return fmt.Errorf(
90-
"Version Error: The Job Descriptor Version %s is not compatible with the server: %d.%d",
90+
"version Error: The Job Descriptor Version %s is not compatible with the server: %d.%d",
9191
d.Version,
9292
JobDescriptorMajorVersion,
9393
JobDescriptorMinorVersion,

pkg/job/job_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestEmptyVersion(t *testing.T) {
3232
require.EqualError(
3333
t,
3434
emptyVersionJD.CheckVersion(),
35-
"Version Error: Empty Job Descriptor Version Field!",
35+
"version Error: Empty Job Descriptor Version Field",
3636
)
3737
}
3838

@@ -41,12 +41,12 @@ func TestIncompatibleVersions(t *testing.T) {
4141

4242
cases = append(cases, Case{
4343
fmt.Sprintf("%d.%d", JobDescriptorMajorVersion, JobDescriptorMinorVersion+1),
44-
"Version Error: The Job Descriptor Version %s is not compatible with the server: %s",
44+
"version Error: The Job Descriptor Version %s is not compatible with the server: %s",
4545
})
4646

4747
cases = append(cases, Case{
4848
fmt.Sprintf("%d.%d", JobDescriptorMajorVersion+1, JobDescriptorMinorVersion),
49-
"Version Error: The Job Descriptor Version %s is not compatible with the server: %s",
49+
"version Error: The Job Descriptor Version %s is not compatible with the server: %s",
5050
})
5151

5252
for _, c := range cases {
@@ -61,13 +61,13 @@ func TestIncompatibleVersions(t *testing.T) {
6161

6262
func TestInvalidVersion(t *testing.T) {
6363
cases := []Case{
64-
{"1.", "Version Error: strconv.Atoi: parsing \"\": invalid syntax"},
65-
{".0", "Version Error: strconv.Atoi: parsing \"\": invalid syntax"},
66-
{".", "Version Error: strconv.Atoi: parsing \"\": invalid syntax"},
67-
{"1.a", "Version Error: strconv.Atoi: parsing \"a\": invalid syntax"},
68-
{"a.0", "Version Error: strconv.Atoi: parsing \"a\": invalid syntax"},
69-
{"123", "Version Error: Incorrect Job Descriptor Version 123"},
70-
{"abc", "Version Error: Incorrect Job Descriptor Version abc"},
64+
{"1.", "version Error: strconv.Atoi: parsing \"\": invalid syntax"},
65+
{".0", "version Error: strconv.Atoi: parsing \"\": invalid syntax"},
66+
{".", "version Error: strconv.Atoi: parsing \"\": invalid syntax"},
67+
{"1.a", "version Error: strconv.Atoi: parsing \"a\": invalid syntax"},
68+
{"a.0", "version Error: strconv.Atoi: parsing \"a\": invalid syntax"},
69+
{"123", "version Error: Incorrect Job Descriptor Version 123"},
70+
{"abc", "version Error: Incorrect Job Descriptor Version abc"},
7171
}
7272

7373
for _, c := range cases {

pkg/jobmanager/bundles.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func newReportingBundles(registry *pluginregistry.PluginRegistry, jobDescriptor
5656
return runReporterBundles, finalReporterBundles, nil
5757
}
5858

59+
// newBundlesFromSteps creates bundles for the test
5960
func newBundlesFromSteps(ctx xcontext.Context, descriptors []*test.TestStepDescriptor, registry *pluginregistry.PluginRegistry) ([]test.TestStepBundle, error) {
6061

6162
// look up test step plugins in the plugin registry
@@ -83,22 +84,17 @@ func newBundlesFromSteps(ctx xcontext.Context, descriptors []*test.TestStepDescr
8384

8485
}
8586

86-
// newStepBundles creates bundles for the test
87-
func newStepBundles(ctx xcontext.Context, descriptors test.TestStepsDescriptors, registry *pluginregistry.PluginRegistry) ([]test.TestStepBundle, error) {
88-
89-
testStepBundles, err := newBundlesFromSteps(ctx, descriptors.TestSteps, registry)
90-
if err != nil {
91-
return nil, fmt.Errorf("could not create test steps bundle: %w", err)
92-
}
93-
94-
// verify that there are not duplicated labels
95-
labels := make(map[string]bool)
96-
for _, bundle := range testStepBundles {
87+
func validateNoDuplicateLabels(stepBundles []test.TestStepBundle) error {
88+
// verify that there are not duplicated labels across all test and cleanup steps.
89+
// This is required later in the execution stage.
90+
labels := make(map[string]struct{})
91+
for _, bundle := range stepBundles {
9792
if _, ok := labels[bundle.TestStepLabel]; ok {
98-
return nil, fmt.Errorf("found duplicated labels: %s", bundle.TestStepLabel)
93+
return fmt.Errorf("found duplicated labels across test/cleanup steps: %s", bundle.TestStepLabel)
9994
}
100-
labels[bundle.TestStepLabel] = true
95+
labels[bundle.TestStepLabel] = struct{}{}
10196
}
97+
10298
// TODO: verify that test variables refer to existing steps
103-
return testStepBundles, nil
99+
return nil
104100
}

0 commit comments

Comments
 (0)