From ae102ae648b6fd780e4b567b12f574e405615233 Mon Sep 17 00:00:00 2001 From: nicufk Date: Thu, 28 Sep 2023 11:33:38 +0300 Subject: [PATCH 1/3] fix: do not store output in test suite execution result --- .../v1/testkube/model_test_suite_execution_extended.go | 9 +++++++++ pkg/repository/testresult/mongo.go | 2 ++ 2 files changed, 11 insertions(+) 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..830012e4e3c 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,12 @@ 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 = "" + } + } + 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 } From 7be48b64457f1381b7afe0f590947ae7e35ab00d Mon Sep 17 00:00:00 2001 From: nicufk Date: Mon, 2 Oct 2023 11:10:14 +0300 Subject: [PATCH 2/3] fix: clean execution result in the BatchResults as well --- pkg/api/v1/testkube/model_test_suite_execution_extended.go | 3 +++ 1 file changed, 3 insertions(+) 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 830012e4e3c..26a3389a864 100644 --- a/pkg/api/v1/testkube/model_test_suite_execution_extended.go +++ b/pkg/api/v1/testkube/model_test_suite_execution_extended.go @@ -248,6 +248,9 @@ 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 { + e.ExecuteStepResults[i].Execute[j].Execution.ExecutionResult.Output = "" + } } } return e From 9c4fefc4c296cade6a536442ea2f6c77d474458a Mon Sep 17 00:00:00 2001 From: nicufk Date: Mon, 2 Oct 2023 11:19:03 +0300 Subject: [PATCH 3/3] fix: add apis spec note and check for nil --- api/v1/testkube.yaml | 2 +- pkg/api/v1/testkube/model_test_suite_execution_extended.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/v1/testkube.yaml b/api/v1/testkube.yaml index 3f94f8a259e..dc27259294b 100644 --- a/api/v1/testkube.yaml +++ b/api/v1/testkube.yaml @@ -3695,7 +3695,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 26a3389a864..e8234a4a21d 100644 --- a/pkg/api/v1/testkube/model_test_suite_execution_extended.go +++ b/pkg/api/v1/testkube/model_test_suite_execution_extended.go @@ -249,7 +249,9 @@ func (e *TestSuiteExecution) CleanStepsOutput() *TestSuiteExecution { 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 { - e.ExecuteStepResults[i].Execute[j].Execution.ExecutionResult.Output = "" + if e.ExecuteStepResults[i].Execute[j].Execution != nil && e.ExecuteStepResults[i].Execute[j].Execution.ExecutionResult != nil { + e.ExecuteStepResults[i].Execute[j].Execution.ExecutionResult.Output = "" + } } } }