-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run k6 after staging deployments (#4991)
* 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]>
- Loading branch information
1 parent
6f95b57
commit 1cd866d
Showing
5 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -708,7 +708,7 @@ jobs: | |
- name: Run k6 frontend all against local Nuxt | ||
run: | | ||
just k6 frontend all \ | ||
-e FRONTEND_URL=http://127.0.0.1:8443/ \ | ||
-e service_url=http://127.0.0.1:8443/ \ | ||
-e text_summary=/tmp/k6-summary.txt | ||
- name: Upload artifacts | ||
|
@@ -739,7 +739,7 @@ jobs: | |
## Latest k6 run output[^update] | ||
``` | ||
${summary} | ||
{summary} | ||
``` | ||
[^update]: This comment will automatically update with new output each time k6 runs for this PR | ||
|
@@ -1312,6 +1312,25 @@ jobs: | |
wait_time: 60 # check every minute | ||
max_time: 1800 # allow up to 30 minutes for a deployment | ||
|
||
- 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 | ||
# TODO: Set to true once we see that this test is stable, and we can fail the deployment if it fails. | ||
# @see https://github.com/WordPress/openverse/pull/4991 | ||
propagate_failure: false | ||
client_payload: | | ||
{ | ||
"namespace": "frontend", | ||
"scenario": "all", | ||
"service_url": "https://staging.openverse.org/", | ||
"report": true | ||
} | ||
deploy-api: | ||
name: Deploy staging API | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Run k6 scenario | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
namespace: | ||
description: '"namespace" of the k6 test scenario to run.' | ||
required: true | ||
type: choice | ||
# frontend is the only one so far, but we will add API back to the k6 tests at some point | ||
options: | ||
- frontend | ||
scenario: | ||
description: "The k6 scenario to run; availability differs per namespace. Run `ov j packages/js/k6/ls` for a list of all k6 scenarios for each namespace." | ||
required: true | ||
type: string | ||
service_url: | ||
description: "The service against which to run the k6 scenario." | ||
required: true | ||
type: string | ||
report: | ||
description: "Whether to report the run results to Grafana Cloud k6" | ||
required: false | ||
type: boolean | ||
default: false | ||
|
||
run-name: k6 run ${{ inputs.namespace }} ${{ inputs.scenario }} ${{ inputs.service_url }} report=${{ inputs.report }} | ||
|
||
# Disallow running multiple load tests at once against the same service | ||
concurrency: ${{ github.workflow }}-${{ inputs.service_url }} | ||
|
||
jobs: | ||
run-k6: | ||
name: "Run k6 ${{ inputs.namespace }} ${{ inputs.scenario }} ${{ inputs.service_url }} report=${{ inputs.report }}" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup CI env | ||
uses: ./.github/actions/setup-env | ||
with: | ||
setup_python: false | ||
install_recipe: node-install | ||
|
||
- name: Setup k6 | ||
uses: grafana/setup-k6-action@v1 | ||
|
||
- name: k6 run ${{ inputs.namespace }} ${{ inputs.scenario }} ${{ inputs.service_url }} | ||
env: | ||
K6_CLOUD_TOKEN: ${{ secrets.GC_K6_TOKEN }} | ||
K6_SIGNING_SECRET: ${{ secrets.K6_SIGNING_SECRET }} | ||
run: | | ||
just k6 ${{ inputs.namespace }} ${{ inputs.scenario }} \ | ||
${{ inputs.report && '-o cloud' || ''}} \ | ||
-e signing_secret="$K6_SIGNING_SECRET" \ | ||
-e service_url=${{ inputs.service_url }} \ | ||
-e text_summary=/tmp/k6-summary.txt | ||
- name: Upload artifacts | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: k6-output | ||
path: /tmp/k6-summary.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const PROJECT_ID = 3713375 | ||
// Default to location of `ov j p frontend prod` | ||
export const FRONTEND_URL = __ENV.FRONTEND_URL || "http://127.0.0.1:8443/" | ||
export const FRONTEND_URL = __ENV.service_url || "http://127.0.0.1:8443/" |