Skip to content

Commit 2636de9

Browse files
committed
chore: increase parallelism of TestWorkspaceQuota
This does a lot of build operations, so having multiple provisioner daemons is great. We were actually approaching the ceiling here for test duration!
1 parent 5cbe360 commit 2636de9

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

enterprise/coderd/workspacequota_test.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package coderd_test
22

33
import (
44
"context"
5+
"sync"
56
"testing"
67

78
"github.com/google/uuid"
9+
"github.com/stretchr/testify/assert"
810
"github.com/stretchr/testify/require"
911

1012
"github.com/coder/coder/coderd/coderdtest"
@@ -37,12 +39,12 @@ func TestWorkspaceQuota(t *testing.T) {
3739
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
3840
defer cancel()
3941
max := 1
40-
client := coderdenttest.New(t, &coderdenttest.Options{
42+
client, _, api := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
4143
UserWorkspaceQuota: max,
42-
Options: &coderdtest.Options{
43-
IncludeProvisionerDaemon: true,
44-
},
4544
})
45+
coderdtest.NewProvisionerDaemon(t, api.AGPL)
46+
coderdtest.NewProvisionerDaemon(t, api.AGPL)
47+
coderdtest.NewProvisionerDaemon(t, api.AGPL)
4648

4749
user := coderdtest.CreateFirstUser(t, client)
4850
coderdenttest.AddLicense(t, client, coderdenttest.LicenseOptions{
@@ -104,12 +106,18 @@ func TestWorkspaceQuota(t *testing.T) {
104106
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
105107

106108
// Spin up three workspaces fine
109+
var wg sync.WaitGroup
107110
for i := 0; i < 3; i++ {
108-
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
109-
build := coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
110-
verifyQuota(ctx, t, client, i+1, 3)
111-
require.Equal(t, codersdk.WorkspaceStatusRunning, build.Status)
111+
wg.Add(1)
112+
go func() {
113+
defer wg.Done()
114+
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
115+
build := coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
116+
assert.Equal(t, codersdk.WorkspaceStatusRunning, build.Status)
117+
}()
112118
}
119+
wg.Wait()
120+
verifyQuota(ctx, t, client, 3, 3)
113121

114122
// Next one must fail
115123
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)

0 commit comments

Comments
 (0)