Skip to content

feat: add load testing harness, coder loadtest command #4853

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 2, 2022

Conversation

deansheather
Copy link
Member

@deansheather deansheather commented Nov 2, 2022

  • Adds httpapi.Duration which wraps time.Duration with sensible JSON marshaling and unmarshaling
  • Adds loadtest/harness package with tests which is the overall runner of a collection of tests
    • Concurrency can be controlled by using a different execution strategy
  • Adds loadtest/placebo which has an implementation of harness.Runnable that sleeps for a given duration with jitter and failure chance
  • Adds loadtest/workspacebuild which has an implementation of harness.Runnable that builds a workspace, waits for it to become available
    • Also implements harness.Cleanable to delete the workspace on test completion
  • Adds hidden coder loadtest subcommand which is only available to the site owner
    • Configured by a JSON file (accepts STDIN as well)
    • Runs any variety of tests with any given concurrency settings
    • Prints error message and logs for all failed test runs
    • Cleans up afterwards

TODO (in future PRs):

  • Add a loadtest for workspace connections via STUN or DERP
  • Better output formatting, including HTML and JSON output
  • Live progress/failure output instead of only outputting information at the end
  • Github actions workflows for periodic load testing in different configurations
  • Documentation, json schema and unhidden loadtest command

Example

{
  "strategy": {
    "type": "concurrent"
  },
  "tests": [
    {
      "type": "placebo",
      "count": 500,
      "placebo": {
        "sleep": "1s",
        "failure_chance": 0.005
      }
    }
  ],
  "timeout": "1m"
}
$ coder loadtest --config ./loadtest.config.json
Running load test...

== FAIL: placebo-0/322

        Error: test failed due to configured failure chance

        Log:
                sleeping for 1s
                failure chance is 0.005000
                rolling the dice of fate...
                rolled: 0.001123
                :(


Test results:
        Pass:  499
        Fail:  1
        Total: 500

        Total duration: 5.003371453s
        Avg. duration:  1.000593179s

Cleaning up...

@deansheather deansheather requested a review from coadler November 2, 2022 13:45
id := strconv.Itoa(i)
runner, err := t.NewRunner(client)
if err != nil {
return xerrors.Errorf("create %q runner for %s/%s: %w", t.Type, name, id, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

The name string already has the id in it right? Seems redundant to include it again

Copy link
Member Author

Choose a reason for hiding this comment

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

The name is the name of the test e.g. workspacebuild-0 and the id is the iteration of the test e.g. 0, 1, 2, 3, etc.

I reused the i variable in the two loops which makes this hard to read, so I've changed the inner loop to j to make it easier to read

Copy link
Contributor

Choose a reason for hiding this comment

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

ah

@@ -70,33 +70,35 @@ func init() {
}

func Core() []*cobra.Command {
// Please re-sort this list alphabetically if you change it!
Copy link
Contributor

Choose a reason for hiding this comment

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

true

@deansheather deansheather enabled auto-merge (squash) November 2, 2022 18:22
@deansheather deansheather merged commit e7dd3f9 into main Nov 2, 2022
@deansheather deansheather deleted the dean/loadtest branch November 2, 2022 18:30
@github-actions github-actions bot locked and limited conversation to collaborators Nov 2, 2022
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.

2 participants