Skip to content

Commit

Permalink
feat(sever): for test runs, split the failed state into more descript…
Browse files Browse the repository at this point in the history
…ive statuses (#2310)

Co-authored-by: Jorge Padilla <jorge.esteban.padilla@gmail.com>
  • Loading branch information
schoren and jorgeepc committed Apr 5, 2023
1 parent 36e42e7 commit c186fbf
Show file tree
Hide file tree
Showing 26 changed files with 384 additions and 265 deletions.
4 changes: 3 additions & 1 deletion api/tests.yaml
Expand Up @@ -128,7 +128,9 @@ components:
AWAITING_TRACE,
AWAITING_TEST_RESULTS,
FINISHED,
FAILED,
TRIGGER_FAILED,
TRACE_FAILED,
ASSERTION_FAILED,
]
description: Current execution state
lastErrorState:
Expand Down
7 changes: 4 additions & 3 deletions cli/actions/run_test_action.go
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/kubeshop/tracetest/cli/formatters"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/ui"
"github.com/kubeshop/tracetest/cli/utils"
"github.com/kubeshop/tracetest/server/model/yaml"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -440,7 +441,7 @@ func (a runTestAction) transactionRun(ctx context.Context, transaction openapi.T
fmt.Print(formattedOutput)

if params.WaitForResult {
if tro.Run.GetState() == "FAILED" {
if utils.RunStateIsFailed(tro.Run.GetState()) {
// It failed, so we have to return an error status
os.Exit(1)
}
Expand Down Expand Up @@ -579,7 +580,7 @@ func (a runTestAction) isTestReady(ctx context.Context, testID, testRunId string
return &openapi.TestRun{}, fmt.Errorf("could not execute GetTestRun request: %w", err)
}

if *run.State == "FAILED" || *run.State == "FINISHED" {
if utils.RunStateIsFinished(run.GetState()) {
return run, nil
}

Expand All @@ -598,7 +599,7 @@ func (a runTestAction) isTransactionReady(ctx context.Context, transactionID, tr
return nil, fmt.Errorf("could not execute GetTestRun request: %w", err)
}

if *run.State == "FAILED" || *run.State == "FINISHED" {
if utils.RunStateIsFinished(run.GetState()) {
return run, nil
}

Expand Down
3 changes: 2 additions & 1 deletion cli/formatters/test_run.go
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/kubeshop/tracetest/cli/config"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/utils"
"github.com/pterm/pterm"
)

Expand Down Expand Up @@ -77,7 +78,7 @@ func (f testRun) json(output TestRunOutput) string {
}

func (f testRun) pretty(output TestRunOutput) string {
if output.Run.State != nil && *output.Run.State == "FAILED" {
if utils.RunStateIsFailed(output.Run.GetState()) {
return f.getColoredText(false, f.formatMessage("Failed to execute test: %s", *output.Run.LastErrorState))
}

Expand Down
3 changes: 2 additions & 1 deletion cli/formatters/transaction_run.go
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/kubeshop/tracetest/cli/config"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/utils"
"github.com/pterm/pterm"
)

Expand Down Expand Up @@ -78,7 +79,7 @@ func (f transactionRun) json(output TransactionRunOutput) string {
}

func (f transactionRun) pretty(output TransactionRunOutput) string {
if output.Run.GetState() == "FAILED" {
if utils.RunStateIsFailed(output.Run.GetState()) {
errorMessage := ""
if len(output.Run.Steps) > 0 {
lastStep := output.Run.Steps[len(output.Run.Steps)-1]
Expand Down

0 comments on commit c186fbf

Please sign in to comment.