Skip to content

fix: coderdtest: increase ForceCancelInterval #3085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2022

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Jul 21, 2022

Two coderd unit tests (TestPatchCancelTemplateVersion/Success and TestPatchCancelWorkspaceBuild) implied erroneously that the job was canceled successfully.

This is not the case, as these unit tests do not include a Provision_Complete response in the input to the
echo provisioner. Now explicitly checking the job error and bumping the force cancel interval to be longer.

I'm not sure if this is the "correct" fix here; I'm mainly unblocking #3061.
It seems that the "right" way would be to allow some way of modifying the contents of the test provisioner's job in-flight.
For example in this use-case, we want to have the job initially returning only logs (implying in progress), and then also returning a complete after we cancel.
There's another use case where we want the status quo, e.g. to test the force cancelation logic.

Fixes #3083.

Two unit tests (TestPatchCancelTemplateVersion/Success and Test-
PatchCancelWorkspaceBuild) implied errneously that the job was
canceled successfully. This is not the case, as these unit tests
do not include a Provision_Complete response in the input to the
echo provisioner. Now explicitly checking the job error.
@johnstcn johnstcn self-assigned this Jul 21, 2022
@johnstcn johnstcn changed the title fix: coderd: TestPatchCancelTemplateVersion: check job error fix: coderdtest: increase ForceCancelInterval Jul 21, 2022
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as workarounds go, this looks OK to me. I'd like to defer to @spikecurtis for a correctness check though.

@@ -150,8 +150,11 @@ func TestPatchCancelTemplateVersion(t *testing.T) {
require.Eventually(t, func() bool {
var err error
version, err = client.TemplateVersion(context.Background(), version.ID)
require.NoError(t, err)
return version.Job.Status == codersdk.ProvisionerJobCanceled
return assert.NoError(t, err) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, TIL these could be used as booleans.

Copy link
Member

@Kira-Pilot Kira-Pilot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this!

// The job will never actually cancel successfully because it will never send a
// provision complete response.
assert.Empty(t, version.Job.Error) &&
version.Job.Status == codersdk.ProvisionerJobCanceling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine with me as a workaround for now, but it exposes that we don't have any tests that actually reach JobCanceled. For that we need to either enhance the echo provisioner, or make a new provisioner that just waits until it is canceled and returns a successful cancel.

One thing that's probably worth doing is renaming this testcase Success -> Canceling to reflect the fact that we don't have a Success testcase yet.

@johnstcn johnstcn enabled auto-merge (squash) July 21, 2022 19:19
@johnstcn johnstcn merged commit 59b04c1 into main Jul 21, 2022
@johnstcn johnstcn deleted the cj/gh-3083/test-cancel-provisionerjob-timeout branch July 21, 2022 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test bug: coderd/TestPatchCancelTemplateVersion/Success
4 participants