Skip to content

SRE-610 - K6 Workflow Updates #270

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 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions workflow-templates/im-test-k6-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow Code: TroubledJaguar_v6 DO NOT REMOVE
# Workflow Code: TroubledJaguar_v7 DO NOT REMOVE
# Purpose:
# Uses a container to run K6 with the file specified in
# the workflow when commits are pushed to the main branch.
Expand Down Expand Up @@ -26,11 +26,9 @@ env:
K6_VERSION: 'v0.45.0' # TODO: Set version of k6. IE. 0.38.3
TEST_FILE: '' # TODO: Add test file to run.

# InfluxDB addresses -
# DNS: https://influxdb-v1.mktp.io/loadtesting
# Alternatively you can use IPs if the dns doesn't resolve.
# IPS: https://10.206.234.23/loadtesting or https://10.206.234.22/loadtesting or https://10.206.234.21/loadtesting
K6_DEFAULT_PARAMATERS: '--out influxdb=https://influxdb-v1.mktp.io/loadtesting --insecure-skip-tls-verify --tag NAME=K6-CI-Test,product=<your-product-tag>,family=pf,env=dev -e RUN_ENV=dev' # TODO: Set default k6 parameters. Update product and family tag
K6_DEFAULT_PARAMATERS: '--insecure-skip-tls-verify --tag NAME=K6-CI-Test,product=<your-product-tag>,family=pf,env=dev -e RUN_ENV=dev' # TODO: Set default k6 parameters. Update product and family tag
K6_INFLUX_DB_PARAMATERS: "-e K6_INFLUX_DB_PUSH_INTERVAL=10s --out influxdb=https://influxdb-v1.mktp.io/loadtesting"
K6_PROMETHEUS_PARAMATERS: "-e K6_PROMETHEUS_RW_PUSH_INTERVAL=10s -e K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),min,max -e K6_PROMETHEUS_RW_SERVER_URL=${{vars.K6_PROMETHEUS_RW_SERVER_URL_ACTIONS}} --out experimental-prometheus-rw"

# TODO: Uncomment if you are using custom k6 binary with k6 extensions installed
# Update to desired version of releases found in https://github.com/im-practices/performance-testing/releases?q=k6&expanded=true
Expand Down Expand Up @@ -98,23 +96,25 @@ jobs:

- name: Run k6 test
working-directory: ${{ env.WORKING_DIRECTORY }}
env:
# K6_COMBINED_PARAMATERS: ${{ env.K6_DEFAULT_PARAMATERS }} ${{ env.K6_INFLUX_DB_PARAMATERS }} # TODO: Uncomment if using influxdb output
# K6_COMBINED_PARAMATERS: ${{ env.K6_DEFAULT_PARAMATERS }} ${{ env.K6_PROMETHEUS_PARAMATERS }} # TODO: Uncomment if using prometheus output
run: |
k6_args="${{ env.K6_PARAMATERS }}"

k6_test_file_tag="--tag test=${{ env.TEST_FILE }}"
k6_test_file_tag="--tag testid=${{ env.TEST_FILE }}"
# Removing slashes from k6_test_file_tag
k6_test_file_tag=$(echo $k6_test_file_tag | tr '/' '-')

k6_params=""
if [[ -z k6_args ]]; then
k6_params="${{ env.K6_DEFAULT_PARAMATERS }} $k6_test_file_tag"
else
k6_params="${{ env.K6_DEFAULT_PARAMATERS }} $k6_args $k6_test_file_tag"
fi
k6_params="${{ env.K6_COMBINED_PARAMATERS }} $k6_test_file_tag"

echo "K6 Parmaters passing in:"
echo $k6_params
echo "::notice file=k6.params,line=1,col=1,endColumn=1::$k6_params"
echo $'
## K6 Paramaters
| Name | Value |
| --- | --- |
| K6 Combined Paramaters| `${{env.K6_COMBINED_PARAMATERS}}` |
| Test ID | `$k6_test_file_tag` |' >> $GITHUB_STEP_SUMMARY

# Running the test
k6 run ${{ env.TEST_FILE }} $k6_params
25 changes: 16 additions & 9 deletions workflow-templates/im-test-k6-manual.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow Code: ZestyFlamingo_v24 DO NOT REMOVE
# Workflow Code: ZestyFlamingo_v25 DO NOT REMOVE
# Purpose:
# Uses a container to run a K6 stress test against the environment and
# with the test file the user specifies when they kick it off manually.
Expand Down Expand Up @@ -59,10 +59,10 @@ env:
NODE_VERSION: '20.x' # TODO: Set correct node version or delete if not use npm to build tests
# InfluxDB addresses -
# DNS: https://influxdb-v1.mktp.io/loadtesting
GRAFANA_DASHBOARD_URI: 'https://grafana.mktp.io/d/SizO_pC4k/k6-load-testing-results-with-env?orgId=1&from=now-1h&to=now&var-ProductTag=<your-product-tag>&var-env=${{ inputs.env }}' # TODO: Update product tag
GRAFANA_INFLUXDB_DASHBOARD_URI: 'https://grafana.mktp.io/d/SizO_pC4k/k6-load-testing-results-with-env?orgId=1&from=now-1h&to=now&var-ProductTag=<your-product-tag>&var-env=${{ inputs.env }}' # TODO: Update product tag
GRAFANA_PROMETHEUS_DASHBOARD_URI: 'https://grafana.mktp.io/d/a3b2aaa8-bb66-4008-a1d8-16c49afedbf0/k6-prometheus?orgId=1&refresh=10s&var-quantile=0.99'
K6_DEFAULT_PARAMETERS: "${{ inputs.output-to-prometheus && '--out experimental-prometheus-rw' || '--out influxdb=\"https://influxdb-v1.mktp.io/loadtesting\"' }} --insecure-skip-tls-verify --tag NAME=${{ inputs.run-name }},product=<your-product-tag>,family=pf,env=${{ inputs.env }} -e RUN_ENV=${{ inputs.env }}" # TODO: Set default k6 parameters specifically replace product and family tags.
K6_PROMETHEUS_PARAMATERS: "-e K6_PROMETHEUS_RW_PUSH_INTERVAL=10s -e K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),min,max -e K6_PROMETHEUS_RW_SERVER_URL=${{vars.K6_PROMETHEUS_RW_SERVER_URL_AKS}}"
K6_DEFAULT_PARAMETERS: "${{ inputs.output-to-prometheus && '--out experimental-prometheus-rw' || '--out influxdb=\"https://influxdb-v1.mktp.io/loadtesting\" -e K6_INFLUX_DB_PUSH_INTERVAL=10s ' }} --insecure-skip-tls-verify --tag NAME=${{ inputs.run-name }},product=<your-product-tag>,family=pf,env=${{ inputs.env }} -e RUN_ENV=${{ inputs.env }}" # TODO: Set default k6 parameters specifically replace product and family tags.
K6_PROMETHEUS_PARAMATERS: "-e K6_PROMETHEUS_RW_PUSH_INTERVAL=10s -e K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),min,max -e K6_PROMETHEUS_RW_SERVER_URL=${{vars.K6_PROMETHEUS_RW_SERVER_URL_ACTIONS}}" # TODO: Updated push interval to required seconds
K6_VERSION: 'v0.51.0' # TODO: Update to the latest k6 version

# TODO: Uncomment if you are using custom k6 binary with k6 extensions installed
Expand Down Expand Up @@ -190,23 +190,30 @@ jobs:
- name: Run k6 test
id: k6-run
working-directory: ${{env.WORKING_DIRECTORY }}
env:
K6_COMBINED_PARAMATERS: ${{ env.K6_DEFAULT_PARAMATERS }}${{ inputs.output-to-prometheus && format(' {0}',env.K6_PROMETHEUS_PARAMATERS) || '' }}
run: |
k6_args="${{ github.event.inputs.k6-paramaters }}"

k6_test_file_tag="--tag test=${{ github.event.inputs.test-file }}"
k6_test_file_tag="--tag testid=${{ github.event.inputs.test-file }}"
# Removing slashes from k6_test_file_tag
k6_test_file_tag=$(echo $k6_test_file_tag | tr '/' '-')

k6_params=""
if [[ -z k6_args ]]; then
k6_params="${{ env.K6_DEFAULT_PARAMATERS }} $k6_test_file_tag"
k6_params="$${{ env.K6_COMBINED_PARAMATERS }} $k6_test_file_tag"
else
k6_params="${{ env.K6_DEFAULT_PARAMATERS }} $k6_args $k6_test_file_tag"
k6_params="${{ env.K6_COMBINED_PARAMATERS }} $k6_args $k6_test_file_tag"
fi

echo "K6 Parmaters passing in:"
echo $k6_params
echo "::notice file=k6.params,line=1,col=1,endColumn=1::$k6_params"
echo $'
## K6 Paramaters
| Name | Value |
| --- | --- |
| K6 Combined Paramaters| `${{env.K6_COMBINED_PARAMATERS}}` |
| Test ID | `$k6_test_file_tag` |' >> $GITHUB_STEP_SUMMARY

# Running the test
k6 run ${{ github.event.inputs.test-file }} $k6_params
Expand Down Expand Up @@ -234,6 +241,6 @@ jobs:
[
{
"name": "View Grafana Dashboard",
"uri": "${{ inputs.output-to-prometheus && env.GRAFANA_PROMETHEUS_DASHBOARD_URI || env.GRAFANA_DASHBOARD_URI }}"
"uri": "${{ inputs.output-to-prometheus && env.GRAFANA_PROMETHEUS_DASHBOARD_URI || env.GRAFANA_INFLUXDB_DASHBOARD_URI }}"
}
]
4 changes: 2 additions & 2 deletions workflow-templates/im-test-k6-operator-approval.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow Code: ZestyCrocodile_v11 DO NOT REMOVE
# Workflow Code: ZestyCrocodile_v12 DO NOT REMOVE
# Purpose:
# Runs K6 tests at scale in Azure Kubernetes.
# With the workflow the user specifies when they kick it off manually.
Expand Down Expand Up @@ -80,7 +80,7 @@ env:

K6_DEFAULT_PARAMETERS: "${{ inputs.output-to-prometheus && '--out experimental-prometheus-rw' || '--out influxdb=https://influxdb-v1.mktp.io/loadtesting' }} --insecure-skip-tls-verify --tag product=SHOP,family=EN,env=${{ inputs.env }} -e RUN_ENV=${{ inputs.env }}" # TODO: Set default k6 parameters specifically replace product and family tags.
# TODO: Optional add K6_PROMETHEUS_RW_STALE_MARKERS=true when running long load tests. This variable will make short tests not show up in grafana
K6_DEFAULT_ENVIRONMNET_VARIABLES: "K6_PROMETHEUS_RW_PUSH_INTERVAL=10s;K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),min,max;K6_PROMETHEUS_RW_SERVER_URL=${{vars.K6_PROMETHEUS_RW_SERVER_URL_AKS}}"
K6_DEFAULT_ENVIRONMNET_VARIABLES: "K6_INFLUX_DB_PUSH_INTERVAL=10s;K6_PROMETHEUS_RW_PUSH_INTERVAL=10s;K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),min,max;K6_PROMETHEUS_RW_SERVER_URL=${{vars.K6_PROMETHEUS_RW_SERVER_URL_AKS}}" # TODO: Set the push interval for output of k6 logs
RETENTION_IN_DAYS: 1
K6_CONTAINER_IMAGE: 'perftest/k6:latest' # TODO: Update to k6 image version if using custom binary. Uncomment reference in Run K6-Operator Test step to use.

Expand Down
4 changes: 2 additions & 2 deletions workflow-templates/im-test-k6-operator.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow Code: ZestyAligator_v32 DO NOT REMOVE
# Workflow Code: ZestyAligator_v33 DO NOT REMOVE
# Purpose:
# Runs K6 tests at scale in Azure Kubernetes.
# With the workflow the user specifies when they kick it off manually.
Expand Down Expand Up @@ -83,7 +83,7 @@ env:

K6_DEFAULT_PARAMETERS: "${{ inputs.output-to-prometheus && '--out experimental-prometheus-rw' || '--out influxdb=https://influxdb-v1.mktp.io/loadtesting' }} --insecure-skip-tls-verify --tag product=SHOP,family=EN,env=${{ inputs.env }} -e RUN_ENV=${{ inputs.env }}"
# TODO: Optional add K6_PROMETHEUS_RW_STALE_MARKERS=true when running long load tests. This variable will make short tests not show up in grafana
K6_DEFAULT_ENVIRONMNET_VARIABLES: "K6_PROMETHEUS_RW_PUSH_INTERVAL=10s;K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),min,max;K6_PROMETHEUS_RW_SERVER_URL=${{vars.K6_PROMETHEUS_RW_SERVER_URL_AKS}}"
K6_DEFAULT_ENVIRONMNET_VARIABLES: "K6_INFLUX_DB_PUSH_INTERVAL=10s;K6_PROMETHEUS_RW_PUSH_INTERVAL=10s;K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),min,max;K6_PROMETHEUS_RW_SERVER_URL=${{vars.K6_PROMETHEUS_RW_SERVER_URL_AKS}}" # TODO: Set the push interval for output of k6 logs
LOOP_DURATION: '1m' # TODO: Update duration of loop to your specification. The action im-practices/run-k6-operator-test documenation has more details on setting this parameter.
RETENTION_IN_DAYS: 1 # TODO: Set retention in days for uploaded artifacts
K6_CONTAINER_IMAGE: 'perftest/k6:latest' # TODO: Update to k6 image version if using custom binary. Uncomment reference in Run K6-Operator Test step to use.
Expand Down