Skip to content

Commit

Permalink
Output 50 slowest request to github console. Add more traceparents an…
Browse files Browse the repository at this point in the history
…d function-headers
  • Loading branch information
dagfinno committed Nov 15, 2024
1 parent d289e10 commit b818bd1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/workflow-run-k6-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
- name: Run K6 tests (${{ inputs.testSuitePath }})
run: |
./tests/k6/tests/scripts/generate_tokens.sh ./tests/k6/tests/performancetest_data ${{ inputs.tokens }}
k6 run ${{ inputs.testSuitePath }} --quiet --log-output=stdout --include-system-env-vars --vus=${{ inputs.vus }} --duration=${{ inputs.duration }} --out=cloud
k6 run ${{ inputs.testSuitePath }} --quiet --log-output=stdout --include-system-env-vars --vus=${{ inputs.vus }} --duration=${{ inputs.duration }} --out=cloud --out csv=./results.csv
grep http_req_duration test_results.csv | sort --field-separator=',' --key=3 -nr | head -50
env:
API_ENVIRONMENT: ${{ inputs.environment }}
API_VERSION: ${{ inputs.apiVersion }}
Expand Down
23 changes: 15 additions & 8 deletions tests/k6/tests/performancetest_common/simpleSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { describe } from '../../common/describe.js';
import { getEU, postGQ, getSO } from '../../common/request.js';
import { getGraphqlParty } from '../performancetest_data/graphql-search.js';


/**
* Retrieves the content for a dialog.
* Get dialog, dialog activities, seenlogs, labellog, and transmissions.
Expand Down Expand Up @@ -38,12 +37,13 @@ function retrieveDialogContent(response, paramsWithToken, getFunction = getEU) {
* @returns {void}
*/
export function enduserSearch(enduser) {
var traceparent = uuidv4();
let paramsWithToken = {
headers: {
Authorization: "Bearer " + enduser.token,
traceparent: uuidv4()
traceparent: traceparent
},
tags: { name: 'enduser search' }
tags: { name: 'enduser search', traceparent: traceparent }
}
let defaultParty = "urn:altinn:person:identifier-no:" + enduser.ssn;
let defaultFilter = "?Party=" + defaultParty;
Expand All @@ -60,7 +60,8 @@ export function enduserSearch(enduser) {
* @param {string} dialogId - The dialog id.
* @param {Object} paramsWithToken - The parameters with token.
* @param {string} tag - Tagging the request.
* @param {string} path - The path to append to the URL. Can be empty or /labellog.
* @param {string} path - The path to append to the URL. Can be empty or /labellog.
* @param {function} getFunction - The get function to use.
* @returns {void}
*/
export function getContent(dialogId, paramsWithToken, tag, path = '', getFunction = getEU) {
Expand All @@ -77,7 +78,8 @@ export function getContent(dialogId, paramsWithToken, tag, path = '', getFunctio
* @param {Object} paramsWithToken - The parameters with token.
* @param {string} tag - Tagging the request.
* @param {string} subtag - Tagging the sub request.
* @param {string} endpoint - The endpoint to append to the URL.
* @param {string} endpoint - The endpoint to append to the URL.
* @param {function} getFunction - The get function to use.
* @returns {void}
*/
export function getContentChain(dialogId, paramsWithToken, tag, subtag, endpoint, getFunction = getEU) {
Expand All @@ -100,6 +102,7 @@ export function getContentChain(dialogId, paramsWithToken, tag, subtag, endpoint
* Performs a GET request to the specified URL with the provided parameters.
* @param {string} url - The URL to send the GET request to.
* @param {Object} paramsWithToken - The parameters with token.
* @param {function} getFunction - The get function to use.
* @returns {Object} The response object.
*/
export function getUrl(url, paramsWithToken, getFunction = getEU) {
Expand Down Expand Up @@ -135,9 +138,10 @@ export function graphqlSearch(enduser) {
/**
* Performs a serviceowner search.
* @param {P} serviceowner
* @param {*} enduser
* @param {*} enduser
* @param {*} tag_name
*/
export function serviceownerSearch(serviceowner, enduser, tag_name) {
export function serviceownerSearch(serviceowner, enduser, tag_name, doSubqueries = true) {
let traceparent = uuidv4();
let paramsWithToken = {
headers: {
Expand All @@ -154,6 +158,9 @@ export function serviceownerSearch(serviceowner, enduser, tag_name) {
let r = getSO('dialogs' + defaultFilter, paramsWithToken);
expectStatusFor(r).to.equal(200);
expect(r, 'response').to.have.validJsonBody();
retrieveDialogContent(r, paramsWithToken, getSO);
if (doSubqueries) {
retrieveDialogContent(r, paramsWithToken, getSO);
}
return r
});
}
18 changes: 7 additions & 11 deletions tests/k6/tests/serviceowner/performance/purge-dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { sentinelPerformanceValue as sentinelValue } from '../../../common/confi
*/
function getDialogs(serviceOwner) {
var traceparent = uuidv4();
console.log("Searching for dialogs to purge, tracevalue: " + traceparent);
var paramsWithToken = {
headers: {
Authorization: "Bearer " + serviceOwner.token,
Expand All @@ -34,7 +33,7 @@ function getDialogs(serviceOwner) {
let continuationToken = "";
let dialogIdsToPurge = [];
do {
let r = getSO('dialogs/?Search=' + sentinelValue + continuationToken, paramsWithToken);
let r = getSO('dialogs/?Search=' + encodeURIComponent(sentinelValue) + continuationToken, paramsWithToken);
expectStatusFor(r).to.equal(200);
expect(r, 'response').to.have.validJsonBody();
let response = r.json();
Expand All @@ -49,12 +48,7 @@ function getDialogs(serviceOwner) {
}
}
console.log("Found " + dialogIdsToPurge.length + " unpurged dialogs");
if (dialogIdsToPurge.length < 200) {
hasNextPage = response.hasNextPage;
}
else {
hasNextPage = false;
}
hasNextPage = response.hasNextPage;
} while (hasNextPage);
return dialogIdsToPurge;
}
Expand Down Expand Up @@ -107,11 +101,13 @@ export default function(serviceOwners) {
* @param {Object} serviceOwner - The service owner object.
*/
export function purgeDialogs(serviceOwner) {
var traceparent = uuidv4();
var paramsWithToken = {
headers: {
Authorization: "Bearer " + serviceOwner.token
},
tags: { name: 'purge dialog' }
Authorization: "Bearer " + serviceOwner.token,
traceparent: traceparent
},
tags: { name: 'purge dialog', traceparent: traceparent }
}
describe('Post run: checking for unpurged dialogs', () => {
let dialogIdsToPurge = serviceOwner.dialogIdsToPurge;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { randomItem } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js';
import { serviceownerSearch } from '../../performancetest_common/simpleSearch.js'
import { getDefaultThresholds } from '../../performancetest_common/getDefaultThresholds.js';
import { serviceOwners ,endUsersWithTokens } from '../../performancetest_common/readTestdata.js';
import { serviceOwners, endUsersWithTokens } from '../../performancetest_common/readTestdata.js';

const tag_name = 'serviceowner search';

Expand Down

0 comments on commit b818bd1

Please sign in to comment.