Skip to content

feat: add scaletest Runner for dynamicparameters load gen#19890

Merged
spikecurtis merged 4 commits into
mainfrom
spike/internal-912-dynamic-parameters-runner
Sep 25, 2025
Merged

feat: add scaletest Runner for dynamicparameters load gen#19890
spikecurtis merged 4 commits into
mainfrom
spike/internal-912-dynamic-parameters-runner

Conversation

@spikecurtis
Copy link
Copy Markdown
Contributor

@spikecurtis spikecurtis commented Sep 19, 2025

relates to coder/internal#912

Adds a new scaletest Runner to generate dynamic parameters load.

A later PR will add the CLI command, including creating the template & version.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@spikecurtis spikecurtis marked this pull request as ready for review September 19, 2025 12:07
@spikecurtis spikecurtis force-pushed the spike/internal-912-dynamic-parameters-runner branch 2 times, most recently from a368b05 to 0b6d03c Compare September 19, 2025 12:11
Copy link
Copy Markdown
Member

@ethanndickson ethanndickson left a comment

Choose a reason for hiding this comment

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

LGTM after a lint

Comment thread scaletest/dynamicparameters/workspace-template.tf Outdated
Comment thread scaletest/dynamicparameters/run.go Outdated
Comment thread scaletest/dynamicparameters/workspace-template.tf Outdated
Comment thread scaletest/dynamicparameters/workspace-template.tf Outdated
Comment thread scaletest/dynamicparameters/template.go Outdated
Comment on lines +5 to +10
type Config struct {
TemplateVersion uuid.UUID `json:"template_version"`
SessionToken string `json:"session_token"`
Metrics *Metrics `json:"-"`
MetricLabelValues []string `json:"metric_label_values"`
}
Copy link
Copy Markdown
Member

@ethanndickson ethanndickson Sep 22, 2025

Choose a reason for hiding this comment

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

Optional: could use a Validate function here, I've found the one on my load generator somewhat useful, such as for checking that my time.Duration timeouts aren't zero.

Copy link
Copy Markdown
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

Overall this is a good start. It is missing tests/assertions for some more dynamic elements, modules, some terraform functions, user context.

In my experience, the verbosity required to run an exchange and test is just too cumbersome. So we should come up with some patterns like the unit tests have:

preview, pop := coderdtest.SynchronousStream(stream)
init := pop()
require.Len(t, init.Diagnostics, 0, "no top level diags")
coderdtest.AssertParameter(t, "isAdmin", init.Parameters).
Exists().Value("false")
coderdtest.AssertParameter(t, "adminonly", init.Parameters).
NotExists()
coderdtest.AssertParameter(t, "groups", init.Parameters).
Exists().Options(database.EveryoneGroup, "developer")
// Switch to an admin
resp, err := preview(codersdk.DynamicParametersRequest{
ID: 1,
Inputs: map[string]string{
"colors": `["red"]`,
"thing": "apple",
},
OwnerID: userAdminData.ID,
})

Then it could be easier to add more query/response round trips and assert more properties of the response.

Comment on lines +86 to +100
case resp, ok := <-respCh:
if !ok {
return xerrors.Errorf("dynamic parameters stream closed before change response")
}
_, _ = fmt.Fprintf(logs, "change response: %+v\n", resp)
r.cfg.Metrics.LatencyChangeResponseSeconds.
WithLabelValues(r.cfg.MetricLabelValues...).
Observe(time.Since(initTime).Seconds())
if resp.ID != 1 {
return xerrors.Errorf("unexpected response ID: %d", resp.ID)
}
if err := checkNoDiagnostics(resp); err != nil {
return xerrors.Errorf("unexpected change response diagnostics: %w", err)
}
return nil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not assert any param condition on the response. I wonder if we can refactor the ParameterAsserter structure to be useful here:

func AssertParameter(t *testing.T, name string, params []codersdk.PreviewParameter) *ParameterAsserter {

It really streamlines the assertion code to something like:

	coderdtest.AssertParameter(t, "groups", resp.Parameters).
		Exists().
		Options(database.EveryoneGroup, "admin", "auditor").
		Value("admin")

It just currently only works in unit tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I feel like this is missing the point --- we are scale testing, not functional testing. I'm not looking to check that the response we get is "correct" in any detailed sense of the term, just that the response has not thrown errors and is doing the computation we want it to.

Comment thread scaletest/dynamicparameters/tf/main.tf
Comment thread scaletest/dynamicparameters/run_test.go
Copy link
Copy Markdown
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

Is this using the echo provisioner? And is that intentional?

@spikecurtis
Copy link
Copy Markdown
Contributor Author

Is this using the echo provisioner? And is that intentional?

That's the test of the scaletest runner/load generator. The actual scale test won't use the echo provisioner.

@spikecurtis
Copy link
Copy Markdown
Contributor Author

Overall this is a good start. It is missing tests/assertions for some more dynamic elements, modules, some terraform functions, user context.

I'm not sure what you mean by "more dynamic elements."

Modules is a good call out.

Are there particular terraform functions that are relevant for a scale test? The point here is not to verify the functionality of dynamic parameters, but how it behaves under load.

The test template does make use of the user roles and username. Are there other elements of the user context that need special attention in terms of scale?

@spikecurtis spikecurtis force-pushed the spike/internal-912-dynamic-parameters-runner branch from 0b6d03c to cefa48c Compare September 23, 2025 08:33
@spikecurtis spikecurtis requested a review from Emyrk September 23, 2025 11:57
@spikecurtis spikecurtis merged commit 289f021 into main Sep 25, 2025
27 checks passed
@spikecurtis spikecurtis deleted the spike/internal-912-dynamic-parameters-runner branch September 25, 2025 12:18
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants