Skip to content

Commit

Permalink
Add ExecutionStatusInterrupted, set it in ExecutionScheduler.Run
Browse files Browse the repository at this point in the history
This is needed to be able to read the test run status via the API, e.g.
in the Cloud.
  • Loading branch information
Ivan Mirić authored and oleiade committed Jan 10, 2022
1 parent 1ad2e74 commit bc403e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions core/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,13 @@ func (e *ExecutionScheduler) Run(
executorsCount := len(e.executors)
logger := e.logger.WithField("phase", "local-execution-scheduler-run")
e.initProgress.Modify(pb.WithConstLeft("Run"))
defer e.state.MarkEnded()
var interrupted bool
defer func() {
e.state.MarkEnded()
if interrupted {
e.state.SetExecutionStatus(lib.ExecutionStatusInterrupted)
}
}()

if e.state.IsPaused() {
logger.Debug("Execution is paused, waiting for resume or interrupt...")
Expand Down Expand Up @@ -423,7 +429,7 @@ func (e *ExecutionScheduler) Run(
}
}
if err := executor.CancelReason(execCtx); err != nil && common.IsInterruptError(err) {
// The execution was interupted
interrupted = true
return err
}
return firstErr
Expand Down
1 change: 1 addition & 0 deletions lib/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const (
ExecutionStatusRunning
ExecutionStatusTeardown
ExecutionStatusEnded
ExecutionStatusInterrupted
)

// ExecutionState contains a few different things:
Expand Down
7 changes: 4 additions & 3 deletions lib/execution_status_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bc403e7

Please sign in to comment.