diff --git a/.github/workflows/run-performance.yml b/.github/workflows/run-performance.yml index 791e12bff..67f6f66c0 100644 --- a/.github/workflows/run-performance.yml +++ b/.github/workflows/run-performance.yml @@ -52,17 +52,19 @@ on: default: 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeClientDelegations.js' type: choice options: - - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeClientDelegations.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDagl.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDaglDeny.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRolePriv.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/getClientDelegations.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForSystemUsers.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUser.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUserPartyId.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForOrganization.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/getRightHolders.js' - - 'src/apps/Altinn.Authorization/test/K6/performance/postConsent.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeClientDelegations.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDagl.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDaglDeny.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRolePriv.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/clientDelegations/getClientDelegations.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForSystemUsers.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUser.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUserPartyId.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForOrganization.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/rightHolders/getRightHolders.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/consent/postConsent.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/connections/getConnections.js' + - 'src/apps/Altinn.Authorization/test/K6/performance/connections/getConnectionsAccessPackages.js' workflow_call: inputs: apiVersion: @@ -118,7 +120,7 @@ run-name: ${{ inputs.tag }} ${{ inputs.vus }}/${{ inputs.duration }}/${{ inputs. jobs: k6-performance: runs-on: ubuntu-latest - environment: ${{ inputs.environment }} + environment: test steps: - name: Checkout code uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 diff --git a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForOrganization.js b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForOrganization.js similarity index 90% rename from src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForOrganization.js rename to src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForOrganization.js index 8ae5599c4..38cadaf95 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForOrganization.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForOrganization.js @@ -1,4 +1,4 @@ -import { getParams, buildOptions } from "./commonFunctions.js"; +import { getParams, buildOptions } from "../common/commonFunctions.js"; import { getAuthorizedParties, getParty } from "./getAuthorizedPartiesForParty.js" export { setup } from "./getAuthorizedPartiesForParty.js" diff --git a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForParty.js b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForParty.js similarity index 90% rename from src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForParty.js rename to src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForParty.js index d24879b68..4e30f549a 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForParty.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForParty.js @@ -1,8 +1,8 @@ import http from 'k6/http'; import { SharedArray } from "k6/data"; -import { getAuthorizedPartiesUrl, tokenGeneratorEnv } from "./common/config.js"; -import { expect, describe, randomItem, URL, getEnterpriseToken } from "./common/testimports.js"; -import { buildOptions, getParams, readCsv } from "./commonFunctions.js"; +import { getAuthorizedPartiesUrl, tokenGeneratorEnv } from "../common/config.js"; +import { expect, describe, randomItem, URL, getEnterpriseToken } from "../common/testimports.js"; +import { buildOptions, getParams, readCsv } from "../common/commonFunctions.js"; const randomize = (__ENV.RANDOMIZE ?? 'false') === 'true'; const env = __ENV.API_ENVIRONMENT ?? 'yt01'; @@ -10,7 +10,7 @@ const byOrganization = (__ENV.BY_ORGANIZATION ?? 'true') === 'true'; const byUser = (__ENV.BY_USER ?? 'true') === 'true'; const includeAltinn2 = (__ENV.INCLUDE_ALTINN2 ?? 'false') === 'true'; -const partiesFilename = `./testData/orgsIn-${env}-WithPartyUuid.csv`; +const partiesFilename = import.meta.resolve(`../testData/orgsIn-${env}-WithPartyUuid.csv`); const parties = new SharedArray('parties', function () { return readCsv(partiesFilename); }); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForSystemUsers.js b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForSystemUsers.js similarity index 86% rename from src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForSystemUsers.js rename to src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForSystemUsers.js index 9cc315e9b..771025cbd 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForSystemUsers.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForSystemUsers.js @@ -1,11 +1,11 @@ import http from 'k6/http'; import { SharedArray } from "k6/data"; -import { getAuthorizedPartiesUrl } from "./common/config.js"; -import { expect, describe, randomItem, URL, getEnterpriseToken } from "./common/testimports.js"; -import { buildOptions, getParams, readCsv } from "./commonFunctions.js"; +import { getAuthorizedPartiesUrl } from "../common/config.js"; +import { expect, describe, randomItem, URL, getEnterpriseToken } from "../common/testimports.js"; +import { buildOptions, getParams, readCsv } from "../common/commonFunctions.js"; -const systemusersFilename = `./testData/systemusers.csv`; +const systemusersFilename = import.meta.resolve(`../testData/systemusers.csv`); const systemUsers = new SharedArray('systemusers', function () { return readCsv(systemusersFilename); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUser.js b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUser.js similarity index 90% rename from src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUser.js rename to src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUser.js index 37f96bd0c..cd2326759 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUser.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUser.js @@ -1,4 +1,4 @@ -import { getParams, buildOptions } from "./commonFunctions.js"; +import { getParams, buildOptions } from "../common/commonFunctions.js"; import { getAuthorizedParties, getParty } from "./getAuthorizedPartiesForParty.js" export { setup } from "./getAuthorizedPartiesForParty.js" diff --git a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUserPartyId.js b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUserPartyId.js similarity index 88% rename from src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUserPartyId.js rename to src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUserPartyId.js index 1a2c88b03..5d4fbaa71 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/getAuthorizedPartiesForUserPartyId.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/authorizedParties/getAuthorizedPartiesForUserPartyId.js @@ -1,6 +1,6 @@ import { SharedArray } from "k6/data"; -import { randomItem } from "./common/testimports.js"; -import { getParams, buildOptions, readCsv } from "./commonFunctions.js"; +import { randomItem } from "../common/testimports.js"; +import { getParams, buildOptions, readCsv } from "../common/commonFunctions.js"; import { getAuthorizedParties } from "./getAuthorizedPartiesForParty.js" export { setup } from "./getAuthorizedPartiesForParty.js" diff --git a/src/apps/Altinn.Authorization/test/K6/performance/getClientDelegations.js b/src/apps/Altinn.Authorization/test/K6/performance/clientDelegations/getClientDelegations.js similarity index 94% rename from src/apps/Altinn.Authorization/test/K6/performance/getClientDelegations.js rename to src/apps/Altinn.Authorization/test/K6/performance/clientDelegations/getClientDelegations.js index 92911fa48..f87f17f6f 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/getClientDelegations.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/clientDelegations/getClientDelegations.js @@ -1,12 +1,12 @@ import http from 'k6/http'; import exec from 'k6/execution'; import { SharedArray } from "k6/data"; -import { getAmDelegationUrl } from "./common/config.js"; -import { expect, describe, randomItem, URL, getPersonalToken, randomIntBetween } from "./common/testimports.js"; -import { buildOptions, getParams, breakpoint, stages_target, readCsv } from "./commonFunctions.js"; +import { getAmDelegationUrl } from "../common/config.js"; +import { expect, describe, randomItem, URL, getPersonalToken, randomIntBetween } from "../common/testimports.js"; +import { buildOptions, getParams, breakpoint, stages_target, readCsv } from "../common/commonFunctions.js"; -const orgsWithPartyUuidFilename = `./testData/orgsIn-yt01-WithPartyUuid.csv`; +const orgsWithPartyUuidFilename = import.meta.resolve(`../testData/orgsIn-yt01-WithPartyUuid.csv`); const orgsWithPartyUuid = new SharedArray('orgs2', function () { return readCsv(orgsWithPartyUuidFilename); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/commonFunctions.js b/src/apps/Altinn.Authorization/test/K6/performance/common/commonFunctions.js similarity index 99% rename from src/apps/Altinn.Authorization/test/K6/performance/commonFunctions.js rename to src/apps/Altinn.Authorization/test/K6/performance/common/commonFunctions.js index 6ec07f9ba..19484c990 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/commonFunctions.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/common/commonFunctions.js @@ -1,5 +1,5 @@ import papaparse from 'https://jslib.k6.io/papaparse/5.1.1/index.js'; -import { getEnterpriseToken, getPersonalToken, uuidv4, randomIntBetween } from './common/testimports.js'; +import { getEnterpriseToken, getPersonalToken, uuidv4, randomIntBetween } from './testimports.js'; const subscription_key = __ENV.subscription_key; const traceCalls = __ENV.TRACE_CALLS == "true" || __ENV.TRACE_CALLS == "1" || __ENV.TRACE_CALLS == "yes" || __ENV.TRACE_CALLS == "YES" || __ENV.TRACE_CALLS == "Yes"; diff --git a/src/apps/Altinn.Authorization/test/K6/performance/common/config.js b/src/apps/Altinn.Authorization/test/K6/performance/common/config.js index 580f32de9..318dd4e4a 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/common/config.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/common/config.js @@ -18,7 +18,9 @@ const amAuthorizedPartiesUrl = "api/v1/resourceowner/authorizedparties"; const amConsentUrl = "api/v1/enterprise/consentrequests/" const amRightholders = "api/v1/user/rightholders"; const amConsentApprove = "api/v1/bff/consentrequests/"; +const amConnections = "api/v1/enduser/connections"; +export const apiVersion = __ENV.API_VERSION ?? 'v1'; export const env = __ENV.API_ENVIRONMENT ?? 'yt01'; export const urls = { @@ -62,26 +64,32 @@ export const urls = { test: testAmBaseUrl + amRightholders, staging: stagingAmUiBaseUrl + amRightholders, yt01: yt01AmUiBaseUrl + amRightholders + }, + getConnectionsUrl: { + test: testAmBaseUrl + amConnections, + staging: stagingAmBaseUrl + amConnections, + yt01: yt01AmBaseUrl + amConnections } } }; -if (!urls[__ENV.API_VERSION]) { - throw new Error(`Invalid API version: ${__ENV.API_VERSION}. Please ensure it's set correctly in your environment variables.`); +if (!urls[apiVersion]) { + throw new Error(`Invalid API version: ${apiVersion}. Please ensure it's set correctly in your environment variables.`); } -if (!urls[__ENV.API_VERSION]["authorizeUrl"][__ENV.API_ENVIRONMENT]) { - throw new Error(`Invalid API environment: ${__ENV.API_ENVIRONMENT}. Please ensure it's set correctly in your environment variables.`); +if (!urls[apiVersion]["authorizeUrl"][env]) { + throw new Error(`Invalid API environment: ${_env}. Please ensure it's set correctly in your environment variables.`); } -export const postAuthorizeUrl = urls[__ENV.API_VERSION]["authorizeUrl"][__ENV.API_ENVIRONMENT]; -export const getSystemsUrl = urls[__ENV.API_VERSION]["readSystemsUrl"][__ENV.API_ENVIRONMENT]; -export const getSystemUsersUrl = urls[__ENV.API_VERSION]["systemUsersUrl"][__ENV.API_ENVIRONMENT]; -export const getAmDelegationUrl = urls[__ENV.API_VERSION]["amDelegationUrl"][__ENV.API_ENVIRONMENT]; -export const getAuthorizedPartiesUrl = urls[__ENV.API_VERSION]["authorizedPartiesUrl"][__ENV.API_ENVIRONMENT]; -export const postConsent = urls[__ENV.API_VERSION]["consentUrl"][__ENV.API_ENVIRONMENT]; -export const postConsentApprove = urls[__ENV.API_VERSION]["consentApproveUrl"][__ENV.API_ENVIRONMENT]; -export const getRightHoldersUrl = urls[__ENV.API_VERSION]["rightHoldersUrl"][__ENV.API_ENVIRONMENT]; +export const postAuthorizeUrl = urls[apiVersion]["authorizeUrl"][env]; +export const getSystemsUrl = urls[apiVersion]["readSystemsUrl"][env]; +export const getSystemUsersUrl = urls[apiVersion]["systemUsersUrl"][env]; +export const getAmDelegationUrl = urls[apiVersion]["amDelegationUrl"][env]; +export const getAuthorizedPartiesUrl = urls[apiVersion]["authorizedPartiesUrl"][env]; +export const postConsent = urls[apiVersion]["consentUrl"][env]; +export const postConsentApprove = urls[apiVersion]["consentApproveUrl"][env]; +export const getRightHoldersUrl = urls[apiVersion]["rightHoldersUrl"][env]; +export const getConnectionsUrl = urls[apiVersion]["getConnectionsUrl"][env]; export const tokenGeneratorEnv = (() => { switch (env) { case 'yt01': diff --git a/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnections.js b/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnections.js new file mode 100644 index 000000000..4e75966db --- /dev/null +++ b/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnections.js @@ -0,0 +1,14 @@ +import { buildOptions } from "../common/commonFunctions.js"; +import { getConnections, getUserParty } from "./getConnectionsCommon.js" + +const getConnectionsLabel = "Get connections"; +const labels = [ getConnectionsLabel ]; + +export let options = buildOptions(labels); + +export default function () { + const userParty = getUserParty(); + getConnections(userParty, getConnectionsLabel); +} + + diff --git a/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnectionsAccessPackages.js b/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnectionsAccessPackages.js new file mode 100644 index 000000000..42a455e17 --- /dev/null +++ b/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnectionsAccessPackages.js @@ -0,0 +1,12 @@ +import { buildOptions } from "../common/commonFunctions.js"; +import { getConnections, getUserParty } from "./getConnectionsCommon.js" + +const getConnectionsLabel = "Get connections/accesspackages"; +const labels = [ getConnectionsLabel ]; + +export let options = buildOptions(labels); + +export default function () { + const userParty = getUserParty(); + getConnections(userParty, getConnectionsLabel, '/accesspackages'); +} diff --git a/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnectionsCommon.js b/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnectionsCommon.js new file mode 100644 index 000000000..d7999fdf8 --- /dev/null +++ b/src/apps/Altinn.Authorization/test/K6/performance/connections/getConnectionsCommon.js @@ -0,0 +1,56 @@ +import http from 'k6/http'; +import { SharedArray } from "k6/data"; +import { getConnectionsUrl, tokenGeneratorEnv } from "../common/config.js"; +import { expect, describe, randomItem, URL, getPersonalToken } from "../common/testimports.js"; +import { buildOptions, getParams, readCsv } from "../common/commonFunctions.js"; + +const randomize = (__ENV.RANDOMIZE ?? 'false') === 'true'; +const env = __ENV.API_ENVIRONMENT ?? 'yt01'; +const partiesFilename = import.meta.resolve(`../testData/orgsIn-${env}-WithPartyUuid.csv`); + +const parties = new SharedArray('parties', function () { + return readCsv(partiesFilename); +}); + +const getConnectionsLabel = "Get connections"; +const labels = [ getConnectionsLabel ]; + +export let options = buildOptions(labels); + +function getToken(userId) { + const tokenOpts = { + scopes: "altinn:portal/enduser", + userId: userId, + env: tokenGeneratorEnv + } + const token = getPersonalToken(tokenOpts); + return token; +} + +export function getUserParty () { + if (randomize) { return randomItem(parties) } + else { return parties[__ITER % parties.length] }; +} + +export default function () { + const userParty = getUserParty(); + getConnections(userParty, getConnectionsLabel); +} + +export function getConnections(userParty, label, accessPackagesPath = '') { + const token = getToken(userParty.userId); + const params = getParams(label); + params.headers.Authorization = "Bearer " + token; + const url = new URL(getConnectionsUrl + accessPackagesPath); + url.searchParams.append('party', userParty.orgUuid); + url.searchParams.append('to', userParty.orgUuid); + describe('Get connections', () => { + let r = http.get(url.toString(), params); + if (r.timings.duration > 2000.0) { + console.log(__ITER, userParty.orgNo, r.timings.duration); + } + expect(r.status, "response status").to.equal(200); + expect(r, 'response').to.have.validJsonBody(); + }); +} + diff --git a/src/apps/Altinn.Authorization/test/K6/performance/postConsent.js b/src/apps/Altinn.Authorization/test/K6/performance/consent/postConsent.js similarity index 92% rename from src/apps/Altinn.Authorization/test/K6/performance/postConsent.js rename to src/apps/Altinn.Authorization/test/K6/performance/consent/postConsent.js index 708d93b93..a47a6288e 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/postConsent.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/consent/postConsent.js @@ -1,10 +1,10 @@ import http from 'k6/http'; import { SharedArray } from "k6/data"; -import { postConsent, postConsentApprove, env } from './common/config.js'; -import { expect, describe, randomItem, randomIntBetween, URL, uuidv4 } from "./common/testimports.js"; -import { buildOptions, readCsv, getConsentRequestToken, getConsentApproveToken, getAuthorizeParams } from './commonFunctions.js'; +import { postConsent, postConsentApprove, env } from '../common/config.js'; +import { expect, describe, randomItem, randomIntBetween, URL, uuidv4 } from "../common/testimports.js"; +import { buildOptions, readCsv, getConsentRequestToken, getConsentApproveToken, getAuthorizeParams } from '../common/commonFunctions.js'; -const orgsDaglFilename = `./testData/orgsIn-${env}-WithPartyUuid.csv`; +const orgsDaglFilename = import.meta.resolve(`../testData/orgsIn-${env}-WithPartyUuid.csv`); const orgsDagl = new SharedArray('orgsDagl', function () { return readCsv(orgsDaglFilename); }); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeClientDelegations.js b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeClientDelegations.js similarity index 81% rename from src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeClientDelegations.js rename to src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeClientDelegations.js index 6b210f02c..f2e20cc9c 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeClientDelegations.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeClientDelegations.js @@ -1,15 +1,15 @@ import http from 'k6/http'; import { SharedArray } from "k6/data"; -import { expect, describe, randomItem, URL } from "./common/testimports.js"; -import { postAuthorizeUrl } from './common/config.js'; -import { buildClientDelegationAuthorizeBody } from './testData/buildAuthorizeBody.js'; -import { buildOptions, getAuthorizeParams, getActionLabelAndExpectedResponse, getAuthorizeToken, readCsv } from "./commonFunctions.js"; +import { expect, describe, randomItem, URL } from "../common/testimports.js"; +import { postAuthorizeUrl } from '../common/config.js'; +import { buildClientDelegationAuthorizeBody } from '../testData/buildAuthorizeBody.js'; +import { buildOptions, getAuthorizeParams, getActionLabelAndExpectedResponse, getAuthorizeToken, readCsv } from "../common/commonFunctions.js"; const regnResources = "ttd-performance-clientdelegation"; const fforResource = "ttd-performance-clientdelegation-ffor"; const revResource = "ttd-performance-clientdelegation-revisor"; -const systemUsersFilename = `./testData/customers.csv`; +const systemUsersFilename = import.meta.resolve(`../testData/customers.csv`); const systemUsers = new SharedArray('systemUsers', function () { return readCsv(systemUsersFilename); }); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDagl.js b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDagl.js similarity index 83% rename from src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDagl.js rename to src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDagl.js index 0f558f364..dae54cb15 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDagl.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDagl.js @@ -1,15 +1,15 @@ import http from 'k6/http'; import exec from 'k6/execution'; import { SharedArray } from "k6/data"; -import { expect, randomIntBetween, URL, describe } from "./common/testimports.js"; -import { postAuthorizeUrl } from './common/config.js'; -import { buildDaglAuthorizeBody } from './testData/buildAuthorizeBody.js'; -import { buildOptions, getAuthorizeParams, getActionLabelAndExpectedResponse, getAuthorizeClientToken, readCsv} from "./commonFunctions.js"; +import { expect, randomIntBetween, URL, describe } from "../common/testimports.js"; +import { postAuthorizeUrl } from '../common/config.js'; +import { buildDaglAuthorizeBody } from '../testData/buildAuthorizeBody.js'; +import { buildOptions, getAuthorizeParams, getActionLabelAndExpectedResponse, getAuthorizeClientToken, readCsv} from "../common/commonFunctions.js"; // resource with read/write for PRIV and DAGL const resource = "ttd-dialogporten-performance-test-02"; const noOfClientsPerVu = 50; -const daglFilename = `./testData/OrgsDagl.csv`; +const daglFilename = import.meta.resolve(`../testData/OrgsDagl.csv`);; export const dagl = new SharedArray('dagl', function () { return readCsv(daglFilename); }); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDaglDeny.js b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDaglDeny.js similarity index 81% rename from src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDaglDeny.js rename to src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDaglDeny.js index 4e3ec23bb..c112dee1d 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRoleDaglDeny.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRoleDaglDeny.js @@ -1,13 +1,13 @@ import http from 'k6/http'; import exec from 'k6/execution'; import { SharedArray } from "k6/data"; -import { expect, randomIntBetween, URL, describe } from "./common/testimports.js"; -import { postAuthorizeUrl } from './common/config.js'; -import { buildDaglAuthorizeBody } from './testData/buildAuthorizeBody.js'; -import { buildOptions, getAuthorizeParams, getAuthorizeClientToken, getActionLabelAndExpectedResponseForDaglDeny, readCsv } from "./commonFunctions.js"; +import { expect, randomIntBetween, URL, describe } from "../common/testimports.js"; +import { postAuthorizeUrl } from '../common/config.js'; +import { buildDaglAuthorizeBody } from '../testData/buildAuthorizeBody.js'; +import { buildOptions, getAuthorizeParams, getAuthorizeClientToken, getActionLabelAndExpectedResponseForDaglDeny, readCsv } from "../common/commonFunctions.js"; const resource = "ttd-dialogporten-performance-test-02"; -const daglFilename = `./testData/OrgsDagl.csv`; +const daglFilename = import.meta.resolve(`../testData/OrgsDagl.csv`); export const dagl = new SharedArray('dagl', function () { return readCsv(daglFilename); }); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRolePriv.js b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRolePriv.js similarity index 73% rename from src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRolePriv.js rename to src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRolePriv.js index e9146c81b..07df54681 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorizeRolePriv.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/pdpAuthorize/pdpAuthorizeRolePriv.js @@ -1,16 +1,22 @@ import http from 'k6/http'; import exec from 'k6/execution'; import { SharedArray } from "k6/data"; -import { expect, randomIntBetween, URL, describe } from "./common/testimports.js"; -import { postAuthorizeUrl } from './common/config.js'; -import { buildPrivAuthorizeBody } from './testData/buildAuthorizeBody.js'; -import { buildOptions, getAuthorizeParams, getActionLabelAndExpectedResponse, getAuthorizeClientToken, readCsv } from "./commonFunctions.js"; +import { expect, randomIntBetween, URL, describe } from "../common/testimports.js"; +import { postAuthorizeUrl } from '../common/config.js'; +import { buildPrivAuthorizeBody } from '../testData/buildAuthorizeBody.js'; +import { + buildOptions, + getAuthorizeParams, + getActionLabelAndExpectedResponse, + getAuthorizeClientToken, + readCsv +} from "../common/commonFunctions.js"; // resource with read/write for PRIV and DAGL const resource = "ttd-dialogporten-performance-test-02"; const noOfClientsPerVu = 50; -const daglFilename = `./testData/OrgsDagl.csv`; +const daglFilename = import.meta.resolve(`../testData/OrgsDagl.csv`); export const dagl = new SharedArray('dagl', function () { return readCsv(daglFilename); }); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/getRightHolders.js b/src/apps/Altinn.Authorization/test/K6/performance/rightHolders/getRightHolders.js similarity index 83% rename from src/apps/Altinn.Authorization/test/K6/performance/getRightHolders.js rename to src/apps/Altinn.Authorization/test/K6/performance/rightHolders/getRightHolders.js index e6d02a0af..ac3004558 100644 --- a/src/apps/Altinn.Authorization/test/K6/performance/getRightHolders.js +++ b/src/apps/Altinn.Authorization/test/K6/performance/rightHolders/getRightHolders.js @@ -1,12 +1,12 @@ import http from 'k6/http'; import { SharedArray } from "k6/data"; -import { getRightHoldersUrl, tokenGeneratorEnv } from "./common/config.js"; -import { expect, describe, randomItem, URL, getPersonalToken } from "./common/testimports.js"; -import { buildOptions, getParams, readCsv } from "./commonFunctions.js"; +import { getRightHoldersUrl, tokenGeneratorEnv } from "../common/config.js"; +import { expect, describe, randomItem, URL, getPersonalToken } from "../common/testimports.js"; +import { buildOptions, getParams, readCsv } from "../common/commonFunctions.js"; const randomize = (__ENV.RANDOMIZE ?? 'false') === 'true'; const env = __ENV.API_ENVIRONMENT ?? 'yt01'; -const partiesFilename = `./testData/orgsIn-${env}-WithPartyUuid.csv`; +const partiesFilename = import.meta.resolve(`../testData/orgsIn-${env}-WithPartyUuid.csv`); const parties = new SharedArray('parties', function () { return readCsv(partiesFilename); diff --git a/src/apps/Altinn.Authorization/test/K6/performance/run-test-in-k8s.sh b/src/apps/Altinn.Authorization/test/K6/performance/run-test-in-k8s.sh index bf1f423cf..c569e0447 100755 --- a/src/apps/Altinn.Authorization/test/K6/performance/run-test-in-k8s.sh +++ b/src/apps/Altinn.Authorization/test/K6/performance/run-test-in-k8s.sh @@ -184,9 +184,18 @@ spec: metadata: labels: k6-test: $name + nodeSelector: + kubernetes.azure.com/scalesetpriority: spot + spot8cpu28gbmem: 'true' resources: requests: - memory: "200Mi" + cpu: 250m + memory: 200Mi + tolerations: + - effect: NoSchedule + key: kubernetes.azure.com/scalesetpriority + operator: Equal + value: spot EOF # Apply the config.yml configuration