From e2341a40a9a57ca6a1fb05eb1be66dd52e064745 Mon Sep 17 00:00:00 2001 From: nicufk <89570185+nicufk@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:02:36 +0300 Subject: [PATCH] fix: do not store output in test suite execution result (#4409) * fix: do not store output in test suite execution result * fix: clean execution result in the BatchResults as well * fix: add apis spec note and check for nil --- api/v1/testkube.yaml | 2 +- .../model_test_suite_execution_extended.go | 14 ++++++++++++++ pkg/repository/testresult/mongo.go | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api/v1/testkube.yaml b/api/v1/testkube.yaml index 6faf1a6d48e..425fcad903d 100644 --- a/api/v1/testkube.yaml +++ b/api/v1/testkube.yaml @@ -3432,7 +3432,7 @@ components: description: object name and namespace execution: $ref: "#/components/schemas/Execution" - description: test step execution + description: "test step execution, NOTE: the execution output will be empty, retrieve it directly form the test execution" TestSuiteStepExecutionResultV2: description: execution result returned from executor diff --git a/pkg/api/v1/testkube/model_test_suite_execution_extended.go b/pkg/api/v1/testkube/model_test_suite_execution_extended.go index 6ed2ab60b3f..e8234a4a21d 100644 --- a/pkg/api/v1/testkube/model_test_suite_execution_extended.go +++ b/pkg/api/v1/testkube/model_test_suite_execution_extended.go @@ -243,3 +243,17 @@ func (e *TestSuiteExecution) EscapeDots() *TestSuiteExecution { func (e *TestSuiteExecution) UnscapeDots() *TestSuiteExecution { return e.convertDots(utils.UnescapeDots) } + +func (e *TestSuiteExecution) CleanStepsOutput() *TestSuiteExecution { + for i := range e.StepResults { + if e.StepResults[i].Execution != nil && e.StepResults[i].Execution.ExecutionResult != nil { + e.StepResults[i].Execution.ExecutionResult.Output = "" + for j := range e.ExecuteStepResults[i].Execute { + if e.ExecuteStepResults[i].Execute[j].Execution != nil && e.ExecuteStepResults[i].Execute[j].Execution.ExecutionResult != nil { + e.ExecuteStepResults[i].Execute[j].Execution.ExecutionResult.Output = "" + } + } + } + } + return e +} diff --git a/pkg/repository/testresult/mongo.go b/pkg/repository/testresult/mongo.go index d1d00415708..712aa6fafb8 100644 --- a/pkg/repository/testresult/mongo.go +++ b/pkg/repository/testresult/mongo.go @@ -222,12 +222,14 @@ func (r *MongoRepository) GetExecutions(ctx context.Context, filter Filter) (res func (r *MongoRepository) Insert(ctx context.Context, result testkube.TestSuiteExecution) (err error) { result.EscapeDots() + result.CleanStepsOutput() _, err = r.Coll.InsertOne(ctx, result) return } func (r *MongoRepository) Update(ctx context.Context, result testkube.TestSuiteExecution) (err error) { result.EscapeDots() + result.CleanStepsOutput() _, err = r.Coll.ReplaceOne(ctx, bson.M{"id": result.Id}, result) return }