runner: keep export handoffs nonterminal through recovery
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
func TestRunAndExplicitWaitDoNotReturnDuringExportRecovery(t *testing.T) {
|
||||
for _, mode := range []string{"run --wait", "wait"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
active := runInProgress
|
||||
if mode == "wait" {
|
||||
active = runUnfinished
|
||||
}
|
||||
initial := protocol.Message{RunDetail: &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 7, Status: protocol.RunStatusWaiting, ExportPendingSequence: 2}}}
|
||||
polls, finished := 0, false
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
err := (App{}).awaitRuns(ctx, []protocol.Message{initial}, nil, func(request protocol.Message) (protocol.Message, error) {
|
||||
polls++
|
||||
if request.Type != protocol.GetRun || request.RunID != 7 {
|
||||
t.Errorf("unexpected request: %+v", request)
|
||||
}
|
||||
return protocol.Message{RunDetail: &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 7, Status: "succeeded"}}}, nil
|
||||
}, active, func(message protocol.Message) error {
|
||||
if message.RunDetail.Status != "succeeded" {
|
||||
t.Errorf("wait returned before actual terminal: %+v", message.RunDetail)
|
||||
}
|
||||
finished = true
|
||||
return nil
|
||||
})
|
||||
if err != nil || polls != 1 || !finished {
|
||||
t.Fatalf("export wait ended early: polls=%d finished=%v error=%v", polls, finished, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user