Skip to content

Commit fef5d1d

Browse files
authored
feat: passing running context for test and test suite (#122)
1 parent c400593 commit fef5d1d

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

apis/tests/v3/test_types.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ type ArtifactRequest struct {
9898
Dirs []string `json:"dirs,omitempty"`
9999
}
100100

101+
// running context for test or test suite execution
102+
type RunningContext struct {
103+
// One of possible context types
104+
Type_ string `json:"type"`
105+
// Context value depending from its type
106+
Context string `json:"context,omitempty"`
107+
}
108+
101109
// test execution request body
102110
type ExecutionRequest struct {
103111
// test execution custom name
@@ -153,9 +161,21 @@ type ExecutionRequest struct {
153161
// config map references
154162
EnvConfigMaps []EnvReference `json:"envConfigMaps,omitempty"`
155163
// secret references
156-
EnvSecrets []EnvReference `json:"envSecrets,omitempty"`
164+
EnvSecrets []EnvReference `json:"envSecrets,omitempty"`
165+
RunningContext *RunningContext `json:"runningContext,omitempty"`
157166
}
158167

168+
type RunningContextType string
169+
170+
const (
171+
RunningContextTypeUserCLI RunningContextType = "user-cli"
172+
RunningContextTypeUserUI RunningContextType = "user-ui"
173+
RunningContextTypeTestSuite RunningContextType = "testsuite"
174+
RunningContextTypeTestTrigger RunningContextType = "testtrigger"
175+
RunningContextTypeScheduler RunningContextType = "scheduler"
176+
RunningContextTypeEmpty RunningContextType = ""
177+
)
178+
159179
// Reference to env resource
160180
type EnvReference struct {
161181
v1.LocalObjectReference `json:"reference"`

apis/testsuite/v2/testsuite_types.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ type TestSuiteStepDelay struct {
7373
Duration int32 `json:"duration,omitempty"`
7474
}
7575

76+
// running context for test or test suite execution
77+
type RunningContext struct {
78+
// One of possible context types
79+
Type_ string `json:"type"`
80+
// Context value depending from its type
81+
Context string `json:"context,omitempty"`
82+
}
83+
7684
// test suite execution request body
7785
type TestSuiteExecutionRequest struct {
7886
// test execution custom name
@@ -93,9 +101,21 @@ type TestSuiteExecutionRequest struct {
93101
// https proxy for executor containers
94102
HttpsProxy string `json:"httpsProxy,omitempty"`
95103
// timeout for test suite execution
96-
Timeout int32 `json:"timeout,omitempty"`
104+
Timeout int32 `json:"timeout,omitempty"`
105+
RunningContext *RunningContext `json:"runningContext,omitempty"`
97106
}
98107

108+
type RunningContextType string
109+
110+
const (
111+
RunningContextTypeUserCLI RunningContextType = "user-cli"
112+
RunningContextTypeUserUI RunningContextType = "user-ui"
113+
RunningContextTypeTestSuite RunningContextType = "testsuite"
114+
RunningContextTypeTestTrigger RunningContextType = "testtrigger"
115+
RunningContextTypeScheduler RunningContextType = "scheduler"
116+
RunningContextTypeEmpty RunningContextType = ""
117+
)
118+
99119
type TestSuiteExecutionStatus string
100120

101121
// List of TestSuiteExecutionStatus

controllers/tests/test_controller.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ func (r *TestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
7979
return ctrl.Result{}, nil
8080
}
8181

82-
data, err := json.Marshal(testsv3.ExecutionRequest{})
82+
data, err := json.Marshal(testsv3.ExecutionRequest{
83+
RunningContext: &testsv3.RunningContext{
84+
Type_: string(testsv3.RunningContextTypeScheduler),
85+
Context: test.Spec.Schedule,
86+
},
87+
})
8388
if err != nil {
8489
return ctrl.Result{}, err
8590
}

controllers/testsuite/testsuite_controller.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ func (r *TestSuiteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
7979
return ctrl.Result{}, nil
8080
}
8181

82-
data, err := json.Marshal(testsuitev2.TestSuiteExecutionRequest{})
82+
data, err := json.Marshal(testsuitev2.TestSuiteExecutionRequest{
83+
RunningContext: &testsuitev2.RunningContext{
84+
Type_: string(testsuitev2.RunningContextTypeScheduler),
85+
Context: testSuite.Spec.Schedule,
86+
},
87+
})
88+
8389
if err != nil {
8490
return ctrl.Result{}, err
8591
}

0 commit comments

Comments
 (0)