Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions bundle/direct/dresources/job_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"
"sync/atomic"
"testing"
"time"

"github.com/databricks/cli/libs/structs/structpath"
"github.com/databricks/cli/libs/testserver"
Expand Down Expand Up @@ -232,11 +231,23 @@ func TestJobRunWaitReportsOnlyTheLastAttemptOfATask(t *testing.T) {
}

func TestJobRunWaitAbandonedLinksTheRun(t *testing.T) {
client := jobRunClient(t, &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning})

ctx, cancel := context.WithTimeout(t.Context(), time.Millisecond)
ctx, cancel := context.WithCancel(t.Context())
defer cancel()

// The first poll reports the run page and finds the run still going; the
// second cancels the wait. Driving the interrupt from the handler keeps it
// deterministic: the run page URL is always captured before the wait ends,
// instead of racing a wall-clock timeout against the first GetRun.
var gets atomic.Int32
client := jobRunServer(t, func(req testserver.Request) any {
if gets.Add(1) >= 2 {
cancel()
}
return jobs.Run{RunId: 123, JobId: 456, State: &jobs.RunState{
LifeCycleState: jobs.RunLifeCycleStateRunning,
}, RunPageUrl: testRunPageURL}
})

_, err := waitForTestRun(t, ctx, client)

// The run keeps going, so the error links to it and names the interrupt.
Expand Down
Loading