Skip to content

Commit

Permalink
fix: add test workflow running context model
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin committed Jul 8, 2024
1 parent d54ca82 commit 2b7b2b6
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 20 deletions.
75 changes: 69 additions & 6 deletions api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7043,6 +7043,63 @@ components:
type: string
description: Context value depending from its type

TestWorkflowRunningContext:
description: running context for test workflow execution
type: object
required:
- interface
- actor
properties:
interface:
$ref: "#/components/schemas/TestWorkflowRunningContextInterface"
actor:
$ref: "#/components/schemas/TestWorkflowRunningContextActor"
caller:
$ref: "#/components/schemas/TestWorkflowRunningContextCaller"

TestWorkflowRunningContextCaller:
description: running context caller for test workflow execution
type: object
required:
- callerResourceType
- callerResourceName
- callerResourceExecutionID
- fullExecutionPath
properties:
callerResourceType:
$ref: "#/components/schemas/TestWorkflowRunningContextCallerResourceType"
callerResourceName:
type: string
description: caller resource name
callerResourceExecutionID:
type: string
description: caller resource execution id
fullExecutionPath:
type: string
description: all test workflow execution ids starting from the root

TestWorkflowRunningContextInterface:
description: supported interfaces for test workflow running context
type: string
enum:
- cli
- ui
- api

TestWorkflowRunningContextActor:
description: supported actors for test workflow running context
type: string
enum:
- cron
- testrigger
- user

TestWorkflowRunningContextCallerResourceType:
description: supported caller resource types for test workflow running context
type: string
enum:
- testworkflow

Webhook:
description: CRD based webhook data
type: object
Expand Down Expand Up @@ -7876,8 +7933,10 @@ components:
description: whether webhooks on the executions of this test workflow are disabled
default: false
runningContext:
$ref: "#/components/schemas/RunningContext"
description: running context for the test suite execution
type: array
description: running context for the test workflow execution
items:
$ref: "#/components/schemas/TestWorkflowRunningContext"

TestWorkflowWithExecution:
type: object
Expand Down Expand Up @@ -7970,8 +8029,10 @@ components:
- true
- false
runningContext:
$ref: "#/components/schemas/RunningContext"
description: running context for the test suite execution
type: array
description: running context for the test workflow execution
items:
$ref: "#/components/schemas/TestWorkflowRunningContext"
required:
- id
- name
Expand Down Expand Up @@ -8005,8 +8066,10 @@ components:
workflow:
$ref: "#/components/schemas/TestWorkflowSummary"
runningContext:
$ref: "#/components/schemas/RunningContext"
description: running context for the test suite execution
type: array
description: running context for the test workflow execution
items:
$ref: "#/components/schemas/TestWorkflowRunningContext"
required:
- id
- name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func printPrettyOutput(ui *ui.UI, execution testkube.TestWorkflowExecution) {
ui.Warn("Execution number: ", fmt.Sprintf("%d", execution.Number))
}
ui.Warn("Requested at: ", execution.ScheduledAt.String())
if execution.RunningContext != nil {
for _, ctx := range execution.RunningContext {
ui.Warn("Running context: ")
ui.Warn("Type: ", execution.RunningContext.Type_)
ui.Warn("Context: ", execution.RunningContext.Context)
ui.Warn("Type: ", string(*ctx.Interface_))
ui.Warn("Context: ", string(*ctx.Actor))
}
if execution.Result != nil && execution.Result.Status != nil {
ui.Warn("Status: ", string(*execution.Result.Status))
Expand Down
10 changes: 7 additions & 3 deletions cmd/kubectl-testkube/commands/testworkflows/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ func NewRunTestWorkflowCmd() *cobra.Command {
}

name := args[0]
interface_ := testkube.CLI_TestWorkflowRunningContextInterface
actor := testkube.USER_TestWorkflowRunningContextActor
execution, err := client.ExecuteTestWorkflow(name, testkube.TestWorkflowExecutionRequest{
Name: executionName,
Config: config,
DisableWebhooks: disableWebhooks,
RunningContext: &testkube.RunningContext{
Type_: string(testkube.RunningContextTypeUserCLI),
Context: runningContext,
RunningContext: []testkube.TestWorkflowRunningContext{
{
Interface_: &interface_,
Actor: &actor,
},
},
})
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/api/v1/testkube/model_test_workflow_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type TestWorkflowExecution struct {
// test workflow execution name started the test workflow execution
TestWorkflowExecutionName string `json:"testWorkflowExecutionName,omitempty"`
// whether webhooks on the executions of this test workflow are disabled
DisableWebhooks bool `json:"disableWebhooks,omitempty"`
RunningContext *RunningContext `json:"runningContext,omitempty"`
DisableWebhooks bool `json:"disableWebhooks,omitempty"`
// running context for the test workflow execution
RunningContext []TestWorkflowRunningContext `json:"runningContext,omitempty"`
}
5 changes: 3 additions & 2 deletions pkg/api/v1/testkube/model_test_workflow_execution_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type TestWorkflowExecutionRequest struct {
// test workflow execution name started the test workflow execution
TestWorkflowExecutionName string `json:"testWorkflowExecutionName,omitempty"`
// whether webhooks on the executions of this test workflow are disabled
DisableWebhooks bool `json:"disableWebhooks,omitempty"`
RunningContext *RunningContext `json:"runningContext,omitempty"`
DisableWebhooks bool `json:"disableWebhooks,omitempty"`
// running context for the test workflow execution
RunningContext []TestWorkflowRunningContext `json:"runningContext,omitempty"`
}
9 changes: 5 additions & 4 deletions pkg/api/v1/testkube/model_test_workflow_execution_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ type TestWorkflowExecutionSummary struct {
// when the execution has been scheduled to run
ScheduledAt time.Time `json:"scheduledAt,omitempty"`
// when the execution result's status has changed last time (queued, passed, failed)
StatusAt time.Time `json:"statusAt,omitempty"`
Result *TestWorkflowResultSummary `json:"result,omitempty"`
Workflow *TestWorkflowSummary `json:"workflow"`
RunningContext *RunningContext `json:"runningContext,omitempty"`
StatusAt time.Time `json:"statusAt,omitempty"`
Result *TestWorkflowResultSummary `json:"result,omitempty"`
Workflow *TestWorkflowSummary `json:"workflow"`
// running context for the test workflow execution
RunningContext []TestWorkflowRunningContext `json:"runningContext,omitempty"`
}
17 changes: 17 additions & 0 deletions pkg/api/v1/testkube/model_test_workflow_running_context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Testkube API
*
* Testkube provides a Kubernetes-native framework for test definition, execution and results
*
* API version: 1.0.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package testkube

// running context for test workflow execution
type TestWorkflowRunningContext struct {
Interface_ *TestWorkflowRunningContextInterface `json:"interface"`
Actor *TestWorkflowRunningContextActor `json:"actor"`
Caller *TestWorkflowRunningContextCaller `json:"caller,omitempty"`
}
20 changes: 20 additions & 0 deletions pkg/api/v1/testkube/model_test_workflow_running_context_actor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Testkube API
*
* Testkube provides a Kubernetes-native framework for test definition, execution and results
*
* API version: 1.0.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package testkube

// TestWorkflowRunningContextActor : supported actors for test workflow running context
type TestWorkflowRunningContextActor string

// List of TestWorkflowRunningContextActor
const (
CRON_TestWorkflowRunningContextActor TestWorkflowRunningContextActor = "cron"
TESTRIGGER_TestWorkflowRunningContextActor TestWorkflowRunningContextActor = "testrigger"
USER_TestWorkflowRunningContextActor TestWorkflowRunningContextActor = "user"
)
21 changes: 21 additions & 0 deletions pkg/api/v1/testkube/model_test_workflow_running_context_caller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Testkube API
*
* Testkube provides a Kubernetes-native framework for test definition, execution and results
*
* API version: 1.0.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package testkube

// running context caller for test workflow execution
type TestWorkflowRunningContextCaller struct {
CallerResourceType *TestWorkflowRunningContextCallerResourceType `json:"callerResourceType"`
// caller resource name
CallerResourceName string `json:"callerResourceName"`
// caller resource execution id
CallerResourceExecutionID string `json:"callerResourceExecutionID"`
// all test workflow execution ids starting from the root
FullExecutionPath string `json:"fullExecutionPath"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Testkube API
*
* Testkube provides a Kubernetes-native framework for test definition, execution and results
*
* API version: 1.0.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package testkube

// TestWorkflowRunningContextCallerResourceType : supported caller resource types for test workflow running context
type TestWorkflowRunningContextCallerResourceType string

// List of TestWorkflowRunningContextCallerResourceType
const (
TESTWORKFLOW_TestWorkflowRunningContextCallerResourceType TestWorkflowRunningContextCallerResourceType = "testworkflow"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Testkube API
*
* Testkube provides a Kubernetes-native framework for test definition, execution and results
*
* API version: 1.0.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package testkube

// TestWorkflowRunningContextInterface : supported interfaces for test workflow running context
type TestWorkflowRunningContextInterface string

// List of TestWorkflowRunningContextInterface
const (
CLI_TestWorkflowRunningContextInterface TestWorkflowRunningContextInterface = "cli"
UI_TestWorkflowRunningContextInterface TestWorkflowRunningContextInterface = "ui"
API_TestWorkflowRunningContextInterface TestWorkflowRunningContextInterface = "api"
)

0 comments on commit 2b7b2b6

Please sign in to comment.