Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb90c74a

Browse files
chore(scaletest): avoid polling workspace builds during workspace-updates tests (#20534)
This PR is just committing the changes I made while running the`workspace-updates` load generator.It ensures we're not polling the workspace build progress in thebackground (while we also watch for workspace updates via the tailnet),and also removes an unnecessary query to `/api/v2/workspace/{id}` aftereach workspace is built.
1 parentff532d9 commitb90c74a

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

‎scaletest/createworkspaces/run.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,14 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
8787
workspaceBuildConfig.OrganizationID=r.cfg.User.OrganizationID
8888
workspaceBuildConfig.UserID=user.ID.String()
8989
r.workspacebuildRunner=workspacebuild.NewRunner(client,workspaceBuildConfig)
90-
workspace,err:=r.workspacebuildRunner.RunReturningWorkspace(ctx,id,logs)
90+
slimWorkspace,err:=r.workspacebuildRunner.RunReturningWorkspace(ctx,id,logs)
9191
iferr!=nil {
9292
returnxerrors.Errorf("create workspace: %w",err)
9393
}
94+
workspace,err:=client.Workspace(ctx,slimWorkspace.ID)
95+
iferr!=nil {
96+
returnxerrors.Errorf("get full workspace info: %w",err)
97+
}
9498

9599
ifr.cfg.Workspace.NoWaitForAgents {
96100
returnnil

‎scaletest/workspacebuild/run.go‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ func NewRunner(client *codersdk.Client, cfg Config) *Runner {
3333
}
3434
}
3535

36+
typeSlimWorkspacestruct {
37+
ID uuid.UUID
38+
Namestring
39+
}
40+
3641
// Run implements Runnable.
37-
func (r*Runner)RunReturningWorkspace(ctx context.Context,idstring,logs io.Writer) (codersdk.Workspace,error) {
42+
func (r*Runner)RunReturningWorkspace(ctx context.Context,idstring,logs io.Writer) (SlimWorkspace,error) {
3843
ctx,span:=tracing.StartSpan(ctx)
3944
deferspan.End()
4045

@@ -47,14 +52,14 @@ func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.W
4752
ifreq.Name=="" {
4853
randName,err:=loadtestutil.GenerateWorkspaceName(id)
4954
iferr!=nil {
50-
returncodersdk.Workspace{},xerrors.Errorf("generate random name for workspace: %w",err)
55+
returnSlimWorkspace{},xerrors.Errorf("generate random name for workspace: %w",err)
5156
}
5257
req.Name=randName
5358
}
5459

5560
workspace,err:=r.client.CreateWorkspace(ctx,r.cfg.OrganizationID,r.cfg.UserID,req)
5661
iferr!=nil {
57-
returncodersdk.Workspace{},xerrors.Errorf("create workspace: %w",err)
62+
returnSlimWorkspace{},xerrors.Errorf("create workspace: %w",err)
5863
}
5964
r.workspaceID=workspace.ID
6065

@@ -72,15 +77,15 @@ func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.W
7277
TemplateVersionID:req.TemplateVersionID,
7378
})
7479
iferr!=nil {
75-
returncodersdk.Workspace{},xerrors.Errorf("create workspace build: %w",err)
80+
returnSlimWorkspace{},xerrors.Errorf("create workspace build: %w",err)
7681
}
7782
err=waitForBuild(ctx,logs,r.client,workspace.LatestBuild.ID)
7883
iferr==nil {
7984
break
8085
}
8186
}
8287
iferr!=nil {
83-
returncodersdk.Workspace{},xerrors.Errorf("wait for build: %w",err)
88+
returnSlimWorkspace{},xerrors.Errorf("wait for build: %w",err)
8489
}
8590
}
8691
}
@@ -91,16 +96,13 @@ func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.W
9196
_,_=fmt.Fprintln(logs,"")
9297
err=waitForAgents(ctx,logs,r.client,workspace.ID)
9398
iferr!=nil {
94-
returncodersdk.Workspace{},xerrors.Errorf("wait for agent: %w",err)
99+
returnSlimWorkspace{},xerrors.Errorf("wait for agent: %w",err)
95100
}
96101
}
97102

98-
workspace,err=r.client.Workspace(ctx,workspace.ID)
99-
iferr!=nil {
100-
return codersdk.Workspace{},xerrors.Errorf("get workspace %q: %w",workspace.ID.String(),err)
101-
}
102-
103-
returnworkspace,nil
103+
// Some users of this runner might not need the full workspace, and
104+
// want to avoid querying the workspace.
105+
returnSlimWorkspace{ID:workspace.ID,Name:workspace.Name},nil
104106
}
105107

106108
// CleanupRunner is a runner that deletes a workspace in the Run phase.

‎scaletest/workspaceupdates/run.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
116116
workspaceBuildConfig.OrganizationID=r.cfg.User.OrganizationID
117117
workspaceBuildConfig.UserID=newUser.ID.String()
118118
workspaceBuildConfig.Request.Name=workspaceName
119+
// We'll watch for completion ourselves via the tailnet workspace
120+
// updates stream.
121+
workspaceBuildConfig.NoWaitForAgents=true
122+
workspaceBuildConfig.NoWaitForBuild=true
119123

120124
runner:=workspacebuild.NewRunner(newUserClient,workspaceBuildConfig)
121125
r.workspacebuildRunners=append(r.workspacebuildRunners,runner)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp