-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added test for search and refactored a bit * fixed smoketest for search * added action to run search loadterst ondemand * Fixed typo in yml-file * updated readmes
- Loading branch information
Showing
12 changed files
with
275 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: t3search loadtest ondemand | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
vus: | ||
description: 'Number of VUS' | ||
required: true | ||
default: 10 | ||
type: number | ||
duration: | ||
description: 'Duration of test, ie 30s, 1m, 10m' | ||
required: true | ||
default: 1m | ||
type: string | ||
limit: | ||
description: 'Limit the number of tokens to generate, 0 or less means create for every partyId/userId' | ||
required: true | ||
default: 10 | ||
type: number | ||
select-runner: | ||
description: 'Select runner to run the test' | ||
required: true | ||
type: choice | ||
default: "'ubuntu-latest'" | ||
options: | ||
- "'ubuntu-latest'" | ||
- "['self-hosted', 'macOS', 'X64']" | ||
|
||
jobs: | ||
run-test: | ||
runs-on: ${{ fromJSON(inputs.select-runner) }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 'stable' | ||
|
||
- name: Install xk6 | ||
run: go install go.k6.io/xk6/cmd/xk6@latest | ||
|
||
- name: Build xk6-counter binary | ||
working-directory: ./performance-tests/t3search/src | ||
run: xk6 build --with github.com/avitalique/xk6-file@latest | ||
|
||
- name: Run k6 to generate tokens | ||
working-directory: ./performance-tests/t3search/src | ||
run: ./k6 run ../../generate-tokens/src/generate-tokens.js | ||
env: | ||
env: ${{ secrets.YTENVIRONMENT }} | ||
tokengenuser: ${{ secrets.TOKENGENUSER }} | ||
tokengenuserpwd: ${{ secrets.TOKENGENPWD }} | ||
limit: ${{ inputs.limit }} | ||
|
||
- name: Setup K6 | ||
uses: grafana/setup-k6-action@v1 | ||
|
||
- name: Run local k6 test | ||
uses: grafana/run-k6-action@v1 | ||
with: | ||
path: performance-tests/t3search/src/t3search.js | ||
flags: --vus=${{ inputs.vus }} --duration=${{ inputs.duration }} | ||
env: | ||
K6_WEB_DASHBOARD: true | ||
K6_WEB_DASHBOARD_EXPORT: html-report.html | ||
subscription_key: ${{ secrets.SUBSCRIPTION_KEY }} | ||
|
||
- name: Upload summary html report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: summary-html | ||
path: summary.html | ||
- name: Upload extended html report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: extended-html | ||
path: html-report.html | ||
|
||
- name: Upload summary text report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: summary-txt | ||
path: stdout.txt | ||
|
||
- name: Upload HTML report to Azure | ||
if: always() | ||
shell: bash | ||
run: | | ||
REPORT_DIR='t3search_ondemand-${{ github.run_number }}-${{ github.run_attempt }}' | ||
azcopy cp --recursive "*.html" "https://altinnloadtests.blob.core.windows.net/\$web/$REPORT_DIR" | ||
echo "::Link to test results summary: title=HTML report url::https://altinnloadtests.z1.web.core.windows.net/$REPORT_DIR/summary.html" | ||
echo "::Link to test results extended: title=HTML report url::https://altinnloadtests.z1.web.core.windows.net/$REPORT_DIR/html-report.html" | ||
env: | ||
AZCOPY_AUTO_LOGIN_TYPE: SPN | ||
AZCOPY_SPA_APPLICATION_ID: ${{ secrets.AZCOPY_SPA_APPLICATION_ID }} | ||
AZCOPY_SPA_CLIENT_SECRET: ${{ secrets.AZCOPY_SPA_CLIENT_SECRET }} | ||
AZCOPY_TENANT_ID: ${{ secrets.AZCOPY_TENANT_ID }} | ||
|
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,50 @@ | ||
name: t3search loadtest smoketest | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
paths: | ||
- performance-tests/t3search/** | ||
- .github/workflows/t3search-loadtest-push.yml | ||
|
||
jobs: | ||
run-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 'stable' | ||
|
||
- name: Install xk6 | ||
run: go install go.k6.io/xk6/cmd/xk6@latest | ||
|
||
- name: Build xk6-counter binary | ||
working-directory: ./performance-tests/t3search/src | ||
run: xk6 build --with github.com/avitalique/xk6-file@latest | ||
|
||
- name: Run k6 to generate tokens | ||
working-directory: ./performance-tests/t3search/src | ||
run: ./k6 run ../../generate-tokens/src/generate-tokens.js | ||
env: | ||
env: ${{ secrets.YTENVIRONMENT }} | ||
tokengenuser: ${{ secrets.TOKENGENUSER }} | ||
tokengenuserpwd: ${{ secrets.TOKENGENPWD }} | ||
limit: 1 | ||
|
||
- name: Setup K6 | ||
uses: grafana/setup-k6-action@v1 | ||
|
||
- name: Run local k6 test | ||
uses: grafana/run-k6-action@v1 | ||
with: | ||
path: performance-tests/t3search/src/t3search.js | ||
flags: --vus=1 --iterations=1 | ||
env: | ||
subscription_key: ${{ secrets.SUBSCRIPTION_KEY }} | ||
|
||
|
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
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
File renamed without changes.
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
File renamed without changes.
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,31 @@ | ||
# Load test for t3search | ||
Load test for t3search, does the following, divided in two separate steps | ||
|
||
## Steps | ||
1. create tokens | ||
2. Do a simple search: | ||
|
||
## Run locally | ||
1. Clone this repo | ||
2. Go to src directory | ||
3. build k6 with fileextention | ||
4. run k6 extention to create tokens | ||
4. run test | ||
``` | ||
git clone <this repo> | ||
cd altinn-test/performance-tests/t3search/src | ||
xk6 build v0.46.0 --with github.com/avitalique/xk6-file@latest | ||
./k6 run -e env=<> -e tokengenuser=<> -e tokengenuserpwd=<> ../../generate-tokens/src/generate-tokens.js | ||
k6 run -e subscription_key=<Ocp-Apim-Subscription-Key> t3search.js | ||
``` | ||
## Github actions | ||
### On push | ||
Runs a test for every push to the performance-loadtest/t3search directory | ||
- one vu | ||
- one minute | ||
### Ondemand | ||
Runs when requested | ||
- selectable number of vus | ||
- selectable duration | ||
- selectable runner | ||
|
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,81 @@ | ||
import http from 'k6/http'; | ||
import papaparse from 'https://jslib.k6.io/papaparse/5.1.1/index.js'; | ||
import { randomItem } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; | ||
import { SharedArray } from 'k6/data'; | ||
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; | ||
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js"; | ||
|
||
const idKeys = new SharedArray('idKeys', function () { | ||
return papaparse.parse(open('data-with-tokens.csv'), { header: true }).data; | ||
}); | ||
|
||
const subscription_key = __ENV.subscription_key; | ||
|
||
export const options = { | ||
discardResponseBodies: true, | ||
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'], | ||
thresholds: { | ||
http_req_failed: ['rate<0.01'], | ||
}, | ||
|
||
}; | ||
|
||
export function setup() { | ||
var data = { | ||
searchUrlYt: `https://platform.yt01.altinn.cloud/storage/api/v1/sbl/instances/search`, | ||
idKeys: [] | ||
}; | ||
|
||
for (const idKey of idKeys) { | ||
data.idKeys.push({ | ||
partyId: idKey.partyId, | ||
userId: idKey.userId, | ||
ssn: idKey.ssn, | ||
token: idKey.token | ||
}); | ||
if ((options.vus === undefined || options.vus === 1) && (options.iterations === undefined || options.iterations === 1)) { | ||
break; | ||
} | ||
}; | ||
return data; | ||
} | ||
|
||
export default function(data) { | ||
if ((options.vus === undefined || options.vus === 1) && (options.iterations === undefined || options.iterations === 1)) { | ||
search(data, data.idKeys[0]); | ||
} | ||
else { | ||
while (true) { search(data, randomItem(data.idKeys)); } | ||
} | ||
} | ||
|
||
export function search(data, id) { | ||
var query = | ||
{ | ||
Language: 'nb', | ||
InstanceOwnerPartyIdList: [ id.partyId ], | ||
FromCreated: new Date(2018, 12, 12), | ||
ToCreated: new Date(2099, 1, 1), | ||
IncludeActive: false, | ||
IncludeArchived: true | ||
}; | ||
|
||
var params = { | ||
headers: { | ||
Authorization: 'Bearer ' + id.token, | ||
'Content-Type': 'application/json', | ||
'Ocp-Apim-Subscription-Key': subscription_key | ||
}, | ||
} | ||
|
||
var request_body = JSON.stringify(query) | ||
http.post(data.searchUrlYt, request_body, params); | ||
} | ||
|
||
export function handleSummary(data) { | ||
return { | ||
'stdout': textSummary(data, { indent: ' ', enableColors: true }), | ||
'stdout.txt': textSummary(data, { indent: ' ', enableColors: true }), | ||
"summary.html": htmlReport(data), | ||
}; | ||
} |
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