Skip to content

Commit

Permalink
fix: do not store output in test suite execution result (#4409)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicufk committed Oct 2, 2023
1 parent 07469be commit e2341a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/api/v1/testkube/model_test_suite_execution_extended.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions pkg/repository/testresult/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e2341a4

Please sign in to comment.