Skip to content

Commit f1096a4

Browse files
authored
feat(performance): Performance/create serviceowner search (#1413)
Add a simple serviceowner search on enduser(ssn) and service resource ## Description <!--- Describe your changes in detail --> ## Related Issue(s) - #1326 ## Verification - [ ] **Your** code builds clean without any errors or warnings - [ ] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] 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 a new performance testing script for service owner searches. - Added functionality to perform searches specifically for service owners. - **Improvements** - Enhanced existing search functionality for end users. - Updated performance metrics tracking to reflect the new focus on end user searches. - **Bug Fixes** - Improved URL construction in the token generation script for better handling of special characters. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ca18a99 commit f1096a4

File tree

6 files changed

+65
-6
lines changed

6 files changed

+65
-6
lines changed

.github/workflows/dispatch-k6-performance.yml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ on:
4949
options:
5050
- 'tests/k6/tests/serviceowner/performance/create-dialog.js'
5151
- 'tests/k6/tests/serviceowner/performance/create-remove-dialog.js'
52+
- 'tests/k6/tests/serviceowner/performance/serviceowner-search.js'
5253
- 'tests/k6/tests/enduser/performance/enduser-search.js'
5354
- 'tests/k6/tests/graphql/performance/graphql-search.js'
5455

tests/k6/tests/performancetest_common/simpleSearch.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { randomItem, uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js';
66
import { expect, expectStatusFor } from "../../common/testimports.js";
77
import { describe } from '../../common/describe.js';
8-
import { getEU, postGQ } from '../../common/request.js';
8+
import { getEU, postGQ, getSO } from '../../common/request.js';
99
import { getGraphqlParty } from '../performancetest_data/graphql-search.js';
1010

1111

@@ -31,7 +31,7 @@ function retrieveDialogContent(response, paramsWithToken) {
3131
}
3232

3333
/**
34-
* Performs a simple search.
34+
* Performs a enduser search.
3535
* @param {Object} enduser - The end user.
3636
* @returns {void}
3737
*/
@@ -127,3 +127,27 @@ export function graphqlSearch(enduser) {
127127
expect(r, 'response').to.have.validJsonBody();
128128
});
129129
}
130+
131+
/**
132+
* Performs a serviceowner search.
133+
* @param {P} serviceowner
134+
* @param {*} enduser
135+
*/
136+
export function serviceownerSearch(serviceowner, enduser, tag_name) {
137+
let paramsWithToken = {
138+
headers: {
139+
Authorization: "Bearer " + serviceowner.token,
140+
traceparent: uuidv4()
141+
},
142+
tags: { name: tag_name }
143+
}
144+
145+
let enduserid = encodeURIComponent(`urn:altinn:person:identifier-no:${enduser.ssn}`);
146+
let serviceResource = encodeURIComponent(`urn:altinn:resource:${serviceowner.resource}`);
147+
let defaultFilter = `?enduserid=${enduserid}&serviceResource=${serviceResource}`;
148+
describe('Perform serviceowner dialog list', () => {
149+
let r = getSO('dialogs' + defaultFilter, paramsWithToken);
150+
expectStatusFor(r).to.equal(200);
151+
expect(r, 'response').to.have.validJsonBody();
152+
});
153+
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
org,orgno,scopes,resource
2-
digdir,991825827,digdir:dialogporten.serviceprovider,super-simple-service
2+
digdir,991825827,digdir:dialogporten.serviceprovider digdir:dialogporten.serviceprovider.search,ttd-dialogporten-performance-test-01

tests/k6/tests/scenarios/performance/create-dialog-and-search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const options = {
4242
},
4343
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'],
4444
thresholds: getDefaultThresholds(['http_req_duration', 'http_reqs'],[
45-
'simple search',
45+
'enduser search',
4646
'create dialog',
4747
'get dialog',
4848
'get dialog activities',

tests/k6/tests/scripts/generate_tokens.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ if [ "$tokens" = "both" ] || [ "$tokens" = "enterprise" ]; then
5757
echo "org,orgno,scopes,resource,token" > $serviceowner_tokenfile
5858
while IFS=, read -r org orgno scopes resource
5959
do
60-
url="https://altinn-testtools-token-generator.azurewebsites.net/api/GetEnterpriseToken?org=$org&env=$env&scopes=$scopes&orgno=$orgno&ttl=3600"
61-
token=$(curl -s -f $url -u "$tokengenuser:$tokengenpasswd" )
60+
url="https://altinn-testtools-token-generator.azurewebsites.net/api/GetEnterpriseToken?org=$org&env=$env&orgno=$orgno&ttl=3600"
61+
token=$(curl -s -f --get --data-urlencode "scopes=$scopes" $url -u "$tokengenuser:$tokengenpasswd" )
6262
if [ $? -ne 0 ]; then
6363
echo "Error: Failed to generate enterprise token for: $env, $org, $orgno, $scopes "
6464
continue
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { randomItem } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
2+
import { serviceownerSearch } from '../../performancetest_common/simpleSearch.js'
3+
import { getDefaultThresholds } from '../../performancetest_common/getDefaultThresholds.js';
4+
import { serviceOwners ,endUsersWithTokens } from '../../performancetest_common/readTestdata.js';
5+
6+
const tag_name = 'serviceowner search';
7+
8+
export let options = {
9+
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'p(99.5)', 'p(99.9)', 'count'],
10+
thresholds: getDefaultThresholds(['http_req_duration', 'http_reqs'],[tag_name])
11+
};
12+
13+
/**
14+
* Perform a service owner search.
15+
* In single user mode, the first service owner and end user with token is used. Only one iteration is performed.
16+
* In multi user mode, a random service owner and end user with token is used.
17+
*/
18+
export default function() {
19+
if (!endUsersWithTokens || endUsersWithTokens.length === 0) {
20+
throw new Error('No end users loaded for testing');
21+
}
22+
if (!serviceOwners || serviceOwners.length === 0) {
23+
throw new Error('No service owners loaded for testing');
24+
}
25+
26+
const isSingleUserMode = (options.vus ?? 1) === 1 && (options.iterations ?? 1) === 1 && (options.duration ?? 0) === 0;
27+
if (isSingleUserMode) {
28+
serviceownerSearch(serviceOwners[0], endUsersWithTokens[0], tag_name);
29+
}
30+
else {
31+
serviceownerSearch(randomItem(serviceOwners), randomItem(endUsersWithTokens), tag_name);
32+
}
33+
}
34+

0 commit comments

Comments
 (0)