github.com/kubeshop/testkube@v1.17.23/pkg/tcl/repositorytcl/testworkflow/interface.go (about) 1 // Copyright 2024 Testkube. 2 // 3 // Licensed as a Testkube Pro file under the Testkube Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/kubeshop/testkube/blob/main/licenses/TCL.txt 8 9 package testworkflow 10 11 import ( 12 "context" 13 "io" 14 "time" 15 16 "github.com/kubeshop/testkube/pkg/api/v1/testkube" 17 ) 18 19 const PageDefaultLimit int = 100 20 21 type Filter interface { 22 Name() string 23 NameDefined() bool 24 LastNDays() int 25 LastNDaysDefined() bool 26 StartDate() time.Time 27 StartDateDefined() bool 28 EndDate() time.Time 29 EndDateDefined() bool 30 Statuses() []testkube.TestWorkflowStatus 31 StatusesDefined() bool 32 Page() int 33 PageSize() int 34 TextSearchDefined() bool 35 TextSearch() string 36 Selector() string 37 } 38 39 //go:generate mockgen -destination=./mock_repository.go -package=testworkflow "github.com/kubeshop/testkube/pkg/tcl/repositorytcl/testworkflow" Repository 40 type Repository interface { 41 // Get gets execution result by id or name 42 Get(ctx context.Context, id string) (testkube.TestWorkflowExecution, error) 43 // GetByNameAndTestWorkflow gets execution result by name 44 GetByNameAndTestWorkflow(ctx context.Context, name, workflowName string) (testkube.TestWorkflowExecution, error) 45 // GetLatestByTestWorkflow gets latest execution result by workflow 46 GetLatestByTestWorkflow(ctx context.Context, workflowName string) (*testkube.TestWorkflowExecution, error) 47 // GetRunning get list of executions that are still running 48 GetRunning(ctx context.Context) ([]testkube.TestWorkflowExecution, error) 49 // GetLatestByTestWorkflows gets latest execution results by workflow names 50 GetLatestByTestWorkflows(ctx context.Context, workflowNames []string) (executions []testkube.TestWorkflowExecutionSummary, err error) 51 // GetExecutionsTotals gets executions total stats using a filter, use filter with no data for all 52 GetExecutionsTotals(ctx context.Context, filter ...Filter) (totals testkube.ExecutionsTotals, err error) 53 // GetExecutions gets executions using a filter, use filter with no data for all 54 GetExecutions(ctx context.Context, filter Filter) ([]testkube.TestWorkflowExecution, error) 55 // GetExecutions gets executions using a filter, use filter with no data for all 56 GetExecutionsSummary(ctx context.Context, filter Filter) ([]testkube.TestWorkflowExecutionSummary, error) 57 // Insert inserts new execution result 58 Insert(ctx context.Context, result testkube.TestWorkflowExecution) error 59 // Update updates execution 60 Update(ctx context.Context, result testkube.TestWorkflowExecution) error 61 // UpdateResult updates execution result 62 UpdateResult(ctx context.Context, id string, result *testkube.TestWorkflowResult) (err error) 63 // UpdateOutput updates list of output references in the execution result 64 UpdateOutput(ctx context.Context, id string, output []testkube.TestWorkflowOutput) (err error) 65 // DeleteByTestWorkflow deletes execution results by workflow 66 DeleteByTestWorkflow(ctx context.Context, workflowName string) error 67 // DeleteAll deletes all execution results 68 DeleteAll(ctx context.Context) error 69 // DeleteByTestWorkflows deletes execution results by workflows 70 DeleteByTestWorkflows(ctx context.Context, workflowNames []string) (err error) 71 // GetTestWorkflowMetrics get metrics based on the TestWorkflow results 72 GetTestWorkflowMetrics(ctx context.Context, name string, limit, last int) (metrics testkube.ExecutionsMetrics, err error) 73 } 74 75 //go:generate mockgen -destination=./mock_output_repository.go -package=testworkflow "github.com/kubeshop/testkube/pkg/tcl/repositorytcl/testworkflow" OutputRepository 76 type OutputRepository interface { 77 // PresignSaveLog builds presigned storage URL to save the output in Minio 78 PresignSaveLog(ctx context.Context, id, workflowName string) (string, error) 79 // PresignReadLog builds presigned storage URL to read the output from Minio 80 PresignReadLog(ctx context.Context, id, workflowName string) (string, error) 81 // SaveLog streams the output from the workflow to Minio 82 SaveLog(ctx context.Context, id, workflowName string, reader io.Reader) error 83 // ReadLog streams the output from Minio 84 ReadLog(ctx context.Context, id, workflowName string) (io.Reader, error) 85 // HasLog checks if there is an output in Minio 86 HasLog(ctx context.Context, id, workflowName string) (bool, error) 87 }