Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion coderd/coderdtest/coderdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func NewProvisionerDaemon(t *testing.T, coderAPI *coderd.API) io.Closer {
Logger: slogtest.Make(t, nil).Named("provisionerd").Leveled(slog.LevelDebug),
PollInterval: 10 * time.Millisecond,
UpdateInterval: 25 * time.Millisecond,
ForceCancelInterval: 25 * time.Millisecond,
ForceCancelInterval: time.Second,
Provisioners: provisionerd.Provisioners{
string(database.ProvisionerTypeEcho): proto.NewDRPCProvisionerClient(provisionersdk.Conn(echoClient)),
},
Expand Down
7 changes: 5 additions & 2 deletions coderd/templateversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

// 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.

}, 5*time.Second, 25*time.Millisecond)
})
}
Expand Down
8 changes: 6 additions & 2 deletions coderd/workspacebuilds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/coder/coder/coderd/coderdtest"
Expand Down Expand Up @@ -228,8 +229,11 @@ func TestPatchCancelWorkspaceBuild(t *testing.T) {
require.Eventually(t, func() bool {
var err error
build, err = client.WorkspaceBuild(context.Background(), build.ID)
require.NoError(t, err)
return build.Job.Status == codersdk.ProvisionerJobCanceled
return assert.NoError(t, err) &&
// The job will never actually cancel successfully because it will never send a
// provision complete response.
assert.Empty(t, build.Job.Error) &&
build.Job.Status == codersdk.ProvisionerJobCanceling
}, 5*time.Second, 25*time.Millisecond)
}

Expand Down