-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fix(runner): canceling non-running jobs causes deadlock
Showing
12 changed files
with
140 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package integration | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/leg100/otf/internal/daemon" | ||
"github.com/leg100/otf/internal/pubsub" | ||
"github.com/leg100/otf/internal/run" | ||
"github.com/leg100/otf/internal/runner" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestIntegration_RunJobCancel tests the cancelation of a run and one of its | ||
// jobs, when the job is not yet running. | ||
func TestIntegration_RunJobCancel(t *testing.T) { | ||
integrationTest(t) | ||
|
||
// Disable runner to prevent the run's plan job from running. | ||
daemon, _, ctx := setup(t, &config{ | ||
Config: daemon.Config{ | ||
DisableRunner: true, | ||
}, | ||
}) | ||
// Watch job events | ||
jobs, unsub := daemon.Runners.WatchJobs(ctx) | ||
defer unsub() | ||
|
||
// Create run, and wait til it reaches plan queued state | ||
r := daemon.createRun(t, ctx, nil, nil, nil) | ||
daemon.waitRunStatus(t, r.ID, run.RunPlanQueued) | ||
// Job should be automatically created | ||
wait(t, jobs, func(event pubsub.Event[*runner.Job]) bool { | ||
return event.Payload.RunID == r.ID | ||
}) | ||
|
||
// Cancel run | ||
err := daemon.Runs.Cancel(ctx, r.ID) | ||
require.NoError(t, err) | ||
|
||
// Run and job should now enter canceled state. | ||
daemon.waitRunStatus(t, r.ID, run.RunCanceled) | ||
wait(t, jobs, func(event pubsub.Event[*runner.Job]) bool { | ||
return event.Payload.Status == runner.JobCanceled && | ||
event.Payload.RunID == r.ID | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.