/
test_suites_pipeline.go
47 lines (37 loc) 路 1.17 KB
/
test_suites_pipeline.go
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
package executor
import (
"context"
"github.com/kubeshop/tracetest/server/executor/testrunner"
"github.com/kubeshop/tracetest/server/pkg/pipeline"
"github.com/kubeshop/tracetest/server/test"
"github.com/kubeshop/tracetest/server/testsuite"
"github.com/kubeshop/tracetest/server/variableset"
)
type TestSuitesPipeline struct {
*pipeline.Pipeline[Job]
runs testSuiteRunRepo
}
type testSuiteRunRepo interface {
CreateRun(context.Context, testsuite.TestSuiteRun) (testsuite.TestSuiteRun, error)
}
func NewTestSuitePipeline(
pipeline *pipeline.Pipeline[Job],
runs testSuiteRunRepo,
) *TestSuitesPipeline {
return &TestSuitesPipeline{
Pipeline: pipeline,
runs: runs,
}
}
func (p *TestSuitesPipeline) Run(ctx context.Context, tran testsuite.TestSuite, metadata test.RunMetadata, variableSet variableset.VariableSet, requiredGates *[]testrunner.RequiredGate) testsuite.TestSuiteRun {
tranRun := tran.NewRun()
tranRun.Metadata = metadata
tranRun.VariableSet = variableSet
tranRun.RequiredGates = requiredGates
tranRun, _ = p.runs.CreateRun(ctx, tranRun)
job := NewJob()
job.TestSuite = tran
job.TestSuiteRun = tranRun
p.Pipeline.Begin(ctx, job)
return tranRun
}