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

chore(scaletest): avoid polling workspace builds during workspace-updates tests#20534

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
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
6 changes: 5 additions & 1 deletionscaletest/createworkspaces/run.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,10 +87,14 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
workspaceBuildConfig.OrganizationID = r.cfg.User.OrganizationID
workspaceBuildConfig.UserID = user.ID.String()
r.workspacebuildRunner = workspacebuild.NewRunner(client, workspaceBuildConfig)
workspace, err := r.workspacebuildRunner.RunReturningWorkspace(ctx, id, logs)
slimWorkspace, err := r.workspacebuildRunner.RunReturningWorkspace(ctx, id, logs)
if err != nil {
return xerrors.Errorf("create workspace: %w", err)
}
workspace, err := client.Workspace(ctx, slimWorkspace.ID)
if err != nil {
return xerrors.Errorf("get full workspace info: %w", err)
}

if r.cfg.Workspace.NoWaitForAgents {
return nil
Expand Down
26 changes: 14 additions & 12 deletionsscaletest/workspacebuild/run.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,8 +33,13 @@ func NewRunner(client *codersdk.Client, cfg Config) *Runner {
}
}

type SlimWorkspace struct {
ID uuid.UUID
Name string
}
Comment on lines +36 to +39
Copy link
MemberAuthor

@ethanndicksonethanndicksonOct 29, 2025
edited
Loading

Choose a reason for hiding this comment

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

I'm opting to return this new type here instead of thecodersdk.Workspace returned byCreateWorkspace, as I don't want callers ofRunReturningWorkspace to assume that thecodersdk.Workspace being returned contains the latest info about the build.


// Run implements Runnable.
func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.Writer) (codersdk.Workspace, error) {
func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.Writer) (SlimWorkspace, error) {
ctx, span := tracing.StartSpan(ctx)
defer span.End()

Expand All@@ -47,14 +52,14 @@ func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.W
if req.Name == "" {
randName, err := loadtestutil.GenerateWorkspaceName(id)
if err != nil {
returncodersdk.Workspace{}, xerrors.Errorf("generate random name for workspace: %w", err)
returnSlimWorkspace{}, xerrors.Errorf("generate random name for workspace: %w", err)
}
req.Name = randName
}

workspace, err := r.client.CreateWorkspace(ctx, r.cfg.OrganizationID, r.cfg.UserID, req)
if err != nil {
returncodersdk.Workspace{}, xerrors.Errorf("create workspace: %w", err)
returnSlimWorkspace{}, xerrors.Errorf("create workspace: %w", err)
}
r.workspaceID = workspace.ID

Expand All@@ -72,15 +77,15 @@ func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.W
TemplateVersionID: req.TemplateVersionID,
})
if err != nil {
returncodersdk.Workspace{}, xerrors.Errorf("create workspace build: %w", err)
returnSlimWorkspace{}, xerrors.Errorf("create workspace build: %w", err)
}
err = waitForBuild(ctx, logs, r.client, workspace.LatestBuild.ID)
if err == nil {
break
}
}
if err != nil {
returncodersdk.Workspace{}, xerrors.Errorf("wait for build: %w", err)
returnSlimWorkspace{}, xerrors.Errorf("wait for build: %w", err)
}
}
}
Expand All@@ -91,16 +96,13 @@ func (r *Runner) RunReturningWorkspace(ctx context.Context, id string, logs io.W
_, _ = fmt.Fprintln(logs, "")
err = waitForAgents(ctx, logs, r.client, workspace.ID)
if err != nil {
returncodersdk.Workspace{}, xerrors.Errorf("wait for agent: %w", err)
returnSlimWorkspace{}, xerrors.Errorf("wait for agent: %w", err)
}
}

workspace, err = r.client.Workspace(ctx, workspace.ID)
if err != nil {
return codersdk.Workspace{}, xerrors.Errorf("get workspace %q: %w", workspace.ID.String(), err)
}

return workspace, nil
// Some users of this runner might not need the full workspace, and
// want to avoid querying the workspace.
return SlimWorkspace{ID: workspace.ID, Name: workspace.Name}, nil
}

// CleanupRunner is a runner that deletes a workspace in the Run phase.
Expand Down
4 changes: 4 additions & 0 deletionsscaletest/workspaceupdates/run.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,6 +116,10 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
workspaceBuildConfig.OrganizationID = r.cfg.User.OrganizationID
workspaceBuildConfig.UserID = newUser.ID.String()
workspaceBuildConfig.Request.Name = workspaceName
// We'll watch for completion ourselves via the tailnet workspace
// updates stream.
workspaceBuildConfig.NoWaitForAgents = true
workspaceBuildConfig.NoWaitForBuild = true

runner := workspacebuild.NewRunner(newUserClient, workspaceBuildConfig)
r.workspacebuildRunners = append(r.workspacebuildRunners, runner)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp