feat: add codersdk constructor that uses an independent transport (#22282)
This is useful at least in the case of scaletests but potentially in other places as well. I noticed that scaletest workspace creation hammers a single coderd replica. --------- Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
@@ -76,7 +76,13 @@ func (r *Runner) RunReturningUser(ctx context.Context, id string, logs io.Writer
|
||||
r.user = user
|
||||
|
||||
_, _ = fmt.Fprintln(logs, "\nLogging in as new user...")
|
||||
client := codersdk.New(r.client.URL)
|
||||
// Duplicate the client with an independent transport to ensure each user
|
||||
// login gets its own HTTP connection pool, preventing connection sharing
|
||||
// during load testing.
|
||||
client, err := loadtestutil.DupClientCopyingHeaders(r.client, nil)
|
||||
if err != nil {
|
||||
return User{}, xerrors.Errorf("duplicate client: %w", err)
|
||||
}
|
||||
loginRes, err := client.LoginWithPassword(ctx, codersdk.LoginWithPasswordRequest{
|
||||
Email: r.cfg.Email,
|
||||
Password: password,
|
||||
|
||||
@@ -77,7 +77,14 @@ func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error {
|
||||
return xerrors.Errorf("create user: %w", err)
|
||||
}
|
||||
user = newUser.User
|
||||
client = codersdk.New(r.client.URL)
|
||||
// Duplicate the client with an independent transport to ensure each
|
||||
// workspace creation gets its own HTTP connection pool. This prevents
|
||||
// HTTP/2 connection multiplexing from causing all workspace GET requests
|
||||
// to route to a single backend pod during load testing.
|
||||
client, err = loadtestutil.DupClientCopyingHeaders(r.client, nil)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("duplicate client: %w", err)
|
||||
}
|
||||
client.SetSessionToken(newUser.SessionToken)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user