Skip to content
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

Run k6 after staging deployments #4991

Merged
merged 9 commits into from
Oct 21, 2024
Merged

Conversation

sarayourfriend
Copy link
Collaborator

@sarayourfriend sarayourfriend commented Sep 25, 2024

Fixes

Fixes https://github.com/WordPress/openverse-infrastructure/issues/1031 by @obulat

Description

This PR:

  • Adds an intentionally flexible new run-k6 GitHub Workflow for usage both with manual dispatch and programmatic dispatch via the GitHub CLI during other workflows (we could also leverage that to e.g., run some subset of k6 against production on a regular basis irrespective of deployments, managed using Airflow)
  • Changes FRONTEND_URL to use a generic service_url variable so prepare for also having API tests in k6... this allows us not to need to change the variable name based on the other inputs.
  • Adds an ls recipe to the k6 justfile for listing the namespaces and scenarios.
  • Dispatch that workflow after the staging frontend deploys.

Testing Instructions

Review the testing runs here: https://github.com/WordPress/openverse/actions/workflows/k6.yml

Note that the three failures were due to issues with passing the signing token. That was fixed by https://github.com/WordPress/openverse-infrastructure/pull/1060 and by correctly passing the token in the workflow 🙂

If you have access to Openverse's Grafana, you can also see those runs here: https://openverse.grafana.net/a/k6-app/tests/926189

Those runs were triggered in this PR by me setting the workflow to dispatch on pull_request and hard-coding input parameters. I've removed those hard coded parameters and put the workflow back to dispatch.

The only remaining thing to test is the staging deployment bit that triggers this workflow, and of course we can dispatch the workflow manually from the repository to test that further as well (e.g., to test the inputs).

Otherwise, there is not much real testing possible in this PR.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • [N/A] I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added 🟨 priority: medium Not blocking but should be addressed soon 💻 aspect: code Concerns the software code in the repository 🌟 goal: addition Addition of new feature 🧱 stack: mgmt Related to repo management and automations 🧱 stack: infra Related to the Terraform config and other infrastructure labels Sep 25, 2024
Copy link

github-actions bot commented Sep 25, 2024

Latest k6 run output1

     ✓ status was 200

     checks.........................: 100.00% ✓ 8000     ✗ 0   
     data_received..................: 1.9 GB  8.3 MB/s
     data_sent......................: 1.0 MB  4.7 kB/s
     http_req_blocked...............: avg=10.8µs   min=1.92µs  med=3.93µs   max=7.2ms   p(90)=5.4µs    p(95)=5.84µs  
     http_req_connecting............: avg=5.65µs   min=0s      med=0s       max=4.6ms   p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=581.94ms min=36.55ms med=522.77ms max=2.44s   p(90)=1.08s    p(95)=1.19s   
       { expected_response:true }...: avg=581.94ms min=36.55ms med=522.77ms max=2.44s   p(90)=1.08s    p(95)=1.19s   
   ✓ http_req_failed................: 0.00%   ✓ 0        ✗ 8000
     http_req_receiving.............: avg=142.83µs min=41.84µs med=117.49µs max=14.63ms p(90)=182.29µs p(95)=210.67µs
     http_req_sending...............: avg=21.26µs  min=6.42µs  med=19.62µs  max=3.44ms  p(90)=25.43µs  p(95)=27.49µs 
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s       max=0s      p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=581.77ms min=36.38ms med=522.62ms max=2.44s   p(90)=1.08s    p(95)=1.19s   
     http_reqs......................: 8000    35.64322/s
     iteration_duration.............: avg=3.88s    min=1.16s   med=3.41s    max=11.77s  p(90)=8.4s     p(95)=8.95s   
     iterations.....................: 1200    5.346483/s
     vus............................: 7       min=7      max=30
     vus_max........................: 30      min=30     max=30

Footnotes

  1. This comment will automatically update with new output each time k6 runs for this PR

Comment on lines 1265 to 1329
- name: Trigger staging k6 load test
uses: convictional/[email protected]
with:
owner: WordPress
repo: openverse
token: ${{ secrets.ACCESS_TOKEN }}
workflow_file_name: k6.yml
wait_interval: 60
client_payload: |
{
"namespace": "frontend",
"scenario": "all",
"service_url": "https://staging.openverse.org/",
"report": true
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This "propagates failures" so if the load testing workflow fails, it will mark the staging deployment as failed (which will send a note in our alerts channel about a failed CI/CD run).

This might prove to be a mistake, if these tests are flaky in any way. But, we can try it for now, and easily add the propagate_failure: false option to the action.

We can also choose not to propagate the failure and instead use Grafana's alerting system to send a message when a load test run is uploaded with bad stats (failures).

@sarayourfriend sarayourfriend marked this pull request as ready for review September 25, 2024 21:00
@sarayourfriend sarayourfriend requested review from a team as code owners September 25, 2024 21:00
@sarayourfriend sarayourfriend requested review from obulat and dhruvkb and removed request for a team September 25, 2024 21:00
@obulat obulat force-pushed the run/post-k6-staging-deployment branch 3 times, most recently from c2000c2 to 8b6333d Compare October 11, 2024 15:27
@obulat obulat force-pushed the run/post-k6-staging-deployment branch 2 times, most recently from 5cdd576 to 83d0fea Compare October 19, 2024 15:16
@openverse-bot
Copy link
Collaborator

Based on the contributor urgency of this PR, the following reviewers are being gently reminded to review this PR:

@obulat
@dhruvkb
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 17 day(s) ago. PRs labelled with contributor urgency are expected to be reviewed within 3 weekday(s)2.

@sarayourfriend, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

@obulat obulat force-pushed the run/post-k6-staging-deployment branch from 83d0fea to 91ad5ed Compare October 21, 2024 10:39
obulat and others added 2 commits October 21, 2024 17:43
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

:shipit:

@obulat obulat merged commit 1cd866d into main Oct 21, 2024
55 checks passed
@obulat obulat deleted the run/post-k6-staging-deployment branch October 21, 2024 15:22
@obulat obulat mentioned this pull request Oct 21, 2024
8 tasks
@sarayourfriend
Copy link
Collaborator Author

@obulat the workflow runs are failing, turns out ar locale is not available, presumably due to low-translation percentage? Switching to skr might be a good option!

@obulat
Copy link
Contributor

obulat commented Oct 23, 2024

@obulat the workflow runs are failing, turns out ar locale is not available, presumably due to low-translation percentage? Switching to skr might be a good option!

Yes, turns out that was the reason for not including ar locale in the load testing, there are 0 translations for it, so we filter it out and not show it in the language switcher. I thought about adding fa for RTL, but I don't think we really need RTL for load testing, so decided to remove ar entirely for now: Exclude ar from k6 load testing

@obulat
Copy link
Contributor

obulat commented Oct 24, 2024

@sarayourfriend, the tests are running and passing now 🎉 We also had to increase the CPU resources for staging to prevent the task from restarting during the load tests. We might want to reduce the number of VUs in the tests or the number of requests to prevent the CPU load from going too high (the memory stays below 50%).

I also thought that we might add a process whereby the task with higher resources is deployed when a PR is merged, and after the staging k6 passes, another task with lower values is deployed. But this seems quite complicated to get it right

@sarayourfriend
Copy link
Collaborator Author

For the sake of long-term cost control and simplicity, I'd recommend scaling the staging load tests down until they reliably pass, rather than staging tasks up. Reducing the VUs or the number of iterations both sound like good options. You could also try using the constant-arrival-rate executor to simplify finding the right balance. You could try something like timeUnit: 1s, rate: 2, duration: 5m and then manually ramp rate up by +1 until staging starts to fall over. The goal would be to find the highest rate where it consistently passes so you don't end up with flaky tests, but still have an aggressive enough load test that something like a memory leak would show up.

On that note: I'd also recommend intentionally merging a memory leak and seeing whether this new testing mode catches that 🙂. Trying the same with something CPU bound would also be good.

Danil49 pushed a commit to Danil49/openverse that referenced this pull request Oct 29, 2024
* Add workflow for running k6 on live urls

* Use generic service_url variable for frontend scenarios

* Set testing variables in workflow

* Remove JS template string syntax from Python template string

* Fix missing k6 envvar option for signing secret

* Add step to trigger load test with staging deploy

* Remove testing input overrides

* Update .github/workflows/ci_cd.yml

Co-authored-by: Sara <[email protected]>

* Add comment

Signed-off-by: Olga Bulat <[email protected]>

---------

Signed-off-by: Olga Bulat <[email protected]>
Co-authored-by: Olga Bulat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🌟 goal: addition Addition of new feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: infra Related to the Terraform config and other infrastructure 🧱 stack: mgmt Related to repo management and automations
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants