Skip to content

Commit f9dadf9

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 f9dadf9

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

enterprise/coderd/workspacequota_test.go

Lines changed: 16 additions & 7 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,19 @@ 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++ {
111+
i := i
108112
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)
113+
wg.Add(1)
114+
go func() {
115+
defer wg.Done()
116+
build := coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
117+
verifyQuota(ctx, t, client, i+1, 3)
118+
assert.Equal(t, codersdk.WorkspaceStatusRunning, build.Status)
119+
}()
112120
}
121+
wg.Wait()
113122

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

0 commit comments

Comments
 (0)