-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add more performance tests (#1373)
<!--- Provide a general summary of your changes in the Title above --> ## Description Added more performance tests and some improvements on github workflow for performance tests ## Related Issue(s) - #1326 ## Verification - [x] **Your** code builds clean without any errors or warnings - [x] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [x] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced performance testing scripts for end-user search and GraphQL search functionalities. - Added a tagging system for performance tests with a new required input parameter. - Enhanced dialog creation and removal performance tests with improved data handling. - Implemented a new function for generating default thresholds for performance tests. - Added new performance testing scenarios for creating dialogs and executing searches. - **Bug Fixes** - Updated performance test configurations to ensure correct environment settings. - **Refactor** - Reorganized performance test scripts to utilize newly created utility functions for better maintainability. - Removed outdated performance testing scripts to streamline the testing framework. - **Documentation** - Updated workflow configurations for clarity and improved execution context. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Ole Jørgen Skogstad <skogstad@softis.net> Co-authored-by: Are Almaas <arealmaas@gmail.com>
- Loading branch information
1 parent
493d247
commit 70a63cd
Showing
20 changed files
with
682 additions
and
112 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
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
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,27 @@ | ||
import { enduserSearch } from '../../performancetest_common/simpleSearch.js' | ||
import { getDefaultThresholds } from '../../performancetest_common/getDefaultThresholds.js'; | ||
import { endUsersWithTokens } from '../../performancetest_common/readTestdata.js'; | ||
|
||
export let options = { | ||
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'], | ||
thresholds: getDefaultThresholds(['http_req_duration', 'http_reqs'],['enduser search', | ||
'get dialog', | ||
'get dialog activities', | ||
'get dialog activity', | ||
'get seenlogs', | ||
'get seenlog', | ||
'get transmissions', | ||
'get transmission', | ||
'get labellog' | ||
]) | ||
}; | ||
|
||
export default function() { | ||
if ((options.vus === undefined || options.vus === 1) && (options.iterations === undefined || options.iterations === 1)) { | ||
enduserSearch(endUsersWithTokens[0]); | ||
} | ||
else { | ||
enduserSearch(randomItem(endUsersWithTokens)); | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
/** | ||
* The performance test for GraphQL search. | ||
* Run: k6 run tests/k6/tests/graphql/performance/graphql-search.js --vus 1 --iterations 1 -e env=yt01 | ||
*/ | ||
|
||
import { randomItem } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; | ||
import { getDefaultThresholds } from '../../performancetest_common/getDefaultThresholds.js'; | ||
import { endUsersWithTokens as endUsers } from '../../performancetest_common/readTestdata.js'; | ||
import { graphqlSearch } from "../../performancetest_common/simpleSearch.js"; | ||
|
||
/** | ||
* The options object for configuring the performance test for GraphQL search. | ||
* | ||
* @property {string[]} summaryTrendStats - The summary trend statistics to include in the test results. | ||
* @property {object} thresholds - The thresholds for the test metrics. | ||
*/ | ||
export let options = { | ||
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'], | ||
thresholds: getDefaultThresholds(['http_req_duration', 'http_reqs'],['graphql search']) | ||
}; | ||
|
||
/** | ||
* The default function for the performance test for GraphQL search. | ||
*/ | ||
export default function() { | ||
if (!endUsers || endUsers.length === 0) { | ||
throw new Error('No end users loaded for testing'); | ||
} | ||
if ((options.vus === undefined || options.vus === 1) && (options.iterations === undefined || options.iterations === 1)) { | ||
graphqlSearch(endUsers[0]); | ||
} | ||
else { | ||
graphqlSearch(randomItem(endUsers)); | ||
} | ||
} | ||
|
||
|
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,61 @@ | ||
/** | ||
* Common functions for creating dialogs. | ||
*/ | ||
import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js'; | ||
import { describe } from "../../common/describe.js"; | ||
import { postSO, purgeSO } from "../../common/request.js"; | ||
import { expect } from "../../common/testimports.js"; | ||
import dialogToInsert from "../performancetest_data/01-create-dialog.js"; | ||
|
||
/** | ||
* Creates a dialog. | ||
* | ||
* @param {Object} serviceOwner - The service owner object. | ||
* @param {Object} endUser - The end user object. | ||
*/ | ||
export function createDialog(serviceOwner, endUser) { | ||
var paramsWithToken = { | ||
headers: { | ||
Authorization: "Bearer " + serviceOwner.token, | ||
traceparent: uuidv4() | ||
}, | ||
tags: { name: 'create dialog' } | ||
}; | ||
|
||
describe('create dialog', () => { | ||
let r = postSO('dialogs', dialogToInsert(endUser.ssn, endUser.resource), paramsWithToken); | ||
expect(r.status, 'response status').to.equal(201); | ||
}); | ||
|
||
} | ||
|
||
/** | ||
* Creates a dialog and removes it. | ||
* | ||
* @param {Object} serviceOwner - The service owner object. | ||
* @param {Object} endUser - The end user object. | ||
*/ | ||
export function createAndRemoveDialog(serviceOwner, endUser) { | ||
var paramsWithToken = { | ||
headers: { | ||
Authorization: "Bearer " + serviceOwner.token | ||
}, | ||
tags: { name: 'create dialog' } | ||
} | ||
|
||
let dialogId = 0; | ||
describe('create dialog', () => { | ||
paramsWithToken.tags.name = 'create dialog'; | ||
let r = postSO('dialogs', dialogToInsert(endUser.ssn, endUser.resource), paramsWithToken); | ||
expect(r.status, 'response status').to.equal(201); | ||
dialogId = r.json(); | ||
}); | ||
|
||
describe('remove dialog', () => { | ||
paramsWithToken.tags.name = 'remove dialog'; | ||
if (dialogId) { | ||
let r = purgeSO('dialogs/' + dialogId, paramsWithToken); | ||
expect(r.status, 'response status').to.equal(204); | ||
} | ||
}); | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/k6/tests/performancetest_common/getDefaultThresholds.js
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,21 @@ | ||
/** | ||
* Creates default thresholds configuration for K6 tests. | ||
* @param {string[]} counters - Array of counter names | ||
* @param {string[]} labels - Array of label names | ||
* @returns {Object} Threshold configuration object | ||
* @throws {Error} If inputs are invalid | ||
*/ | ||
export function getDefaultThresholds(counters, labels) { | ||
if (!Array.isArray(counters) || !Array.isArray(labels)) { | ||
throw new Error('Both counters and labels must be arrays'); | ||
} | ||
let thresholds = { | ||
http_req_failed: ['rate<0.01'] | ||
}; | ||
for (const counter of counters) { | ||
for (const label of labels) { | ||
thresholds[`${counter}{name:${label}}`] = []; | ||
} | ||
} | ||
return thresholds; | ||
} |
Oops, something went wrong.