Skip to content

Commit

Permalink
perf test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopocarlini committed Jul 5, 2024
1 parent b7d3013 commit 5e09fe1
Show file tree
Hide file tree
Showing 8 changed files with 603 additions and 598 deletions.
2 changes: 1 addition & 1 deletion .devops/performance-test-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ steps:
- script: |
cd ./performance-test
sh ./run_performance_test.sh ${{ parameters.ENVIRONMENT }} ${{ parameters.TEST_TYPE }} ${{ parameters.SCRIPT }} ${{ parameters.DB_NAME}} $OCP_APIM_SUBSCRIPTION_KEY ${{ parameters.TEMPLATE_ID }}
sh ./run_performance_test.sh ${{ parameters.ENVIRONMENT }} ${{ parameters.TEST_TYPE }} ${{ parameters.SCRIPT }} ${{ parameters.DB_NAME}} $OCP_APIM_SUBSCRIPTION_KEY ${{ parameters.TEMPLATE_ID }} ${{ parameters.PROCESS_TIME }} ${{ parameters.NUMBER_OF_MASSIVE_ELEMENTS }}
displayName: Run k6 ${{ parameters.SCRIPT }} on ${{ parameters.ENVIRONMENT }}
env:
OCP_APIM_SUBSCRIPTION_KEY: ${{ variables.API_SUBSCRIPTION_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy_with_github_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
app_name: ${{ env.APP_NAME }}
helm_upgrade_options: "--debug"
timeout: '10m0s'

cleanup_runner:
name: Cleanup Runner
Expand Down
1,142 changes: 571 additions & 571 deletions integration-test/src/features/massive_generate.feature

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,15 @@ Then(/^the PDF document should be equal to the reference PDF "([^"]*)"$/, async
// we need to remove some metadata (like createDate) to check only the body of the file
const timestampPattern = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/g;
const metaPattern = /<meta name="resourceName" content=".*\.pdf"\/>/g;
const metaLengthPattern = /<meta name="Content-Length" content=".*"\/>/g;

html1 = html1.replace(timestampPattern, '');
html1 = html1.replace(metaPattern, '');
html1 = html1.replace(metaLengthPattern, '');

html2 = html2.replace(timestampPattern, '');
html2 = html2.replace(metaPattern, '');
html2 = html2.replace(metaLengthPattern, '');

assert.equal(html1, html2);
});
Expand Down
4 changes: 2 additions & 2 deletions performance-test/src/dev.environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"blobStorageNoticeContainerID": "notices",
"noticesDb": "noticesMongoDb",
"noticesCollection": "payment_notice_generation_request",
"noticeServiceUri": "https://api.dev.platform.pagopa.it/print-payment-notice-service/external/v1",
"ciTaxCode": "99999000013"
"noticeServiceUri": "https://api.dev.platform.pagopa.it/print-payment-notice-service/internal/v1",
"ciTaxCode": "80034390585"
}
]
}
4 changes: 3 additions & 1 deletion performance-test/src/modules/notice_service_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ export function generateSingleNotice(noticeServiceUri, subKey, inputData, folder
}

export function generateMassiveNotice(noticeServiceUri, subKey, inputData, userId) {
let idempotencyKey = (Math.random() + 1).toString(36).substring(7);

let headers = {
'Ocp-Apim-Subscription-Key': subKey,
'X-User-Id': userId,
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey
};

return http.post(`${noticeServiceUri}/notices/generate-massive`, JSON.stringify(inputData), {
Expand Down
39 changes: 19 additions & 20 deletions performance-test/src/notice_massive_generation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sleep, check } from 'k6';
import { generateMassiveNotice, getNoticeRequest, deleteNoticeRequest } from './modules/notice_service_client.js';
import { SharedArray } from 'k6/data';
import { retrieveNoticeItemData } from './modules/common.js';
import {check, sleep} from 'k6';
import {generateMassiveNotice, getNoticeRequest} from './modules/notice_service_client.js';
import {SharedArray} from 'k6/data';
import {retrieveNoticeItemData} from './modules/common.js';

const varsArray = new SharedArray('vars', function () {
return JSON.parse(open(`./${__ENV.VARS}`)).environment;
Expand All @@ -15,7 +15,6 @@ const noticeServiceUri = `${vars.noticeServiceUri}`;
const subKey = `${__ENV.SUBSCRIPTION_KEY}`;
const templateId = `${__ENV.TEMPLATE_ID}`;
const ciTaxCode = `${vars.ciTaxCode}`;
const numberOfElements = `${vars.numberOfElements}`;
const processTime = `${__ENV.PROCESS_TIME >= 0 ? __ENV.PROCESS_TIME : 3}`;
const numberOfElements = `${__ENV.NUMBER_OF_MASSIVE_ELEMENTS >= 0 ? __ENV.NUMBER_OF_MASSIVE_ELEMENTS : 10}`;

Expand All @@ -27,35 +26,35 @@ function postcondition(folderId) {
console.log("Get Notice Request call, Status " + response.status);

check(response, {
'Get Notice Request status is 200': (response) => response.status === 200,
'Get Notice Request content_type is the expected one':
(response) => response.headers["Content-Type"] === "application/json",
'Get Notice Request not null and with status PROCESSED':
(response) => response.body !== null && JSON.parse(response.body).status === "PROCESSED"
'Get Notice Request status is 200': (response) => response.status === 200,
'Get Notice Request content_type is the expected one':
(response) => response.headers["Content-Type"] === "application/json",
'Get Notice Request not null and with status PROCESSED':
(response) => response.body !== null && JSON.parse(response.body).status === "PROCESSED"
});

}

export default function () {

const notices = [];
const notices = [];

for (let i = 0; i < numberOfElements; i++) {
for (let i = 0; i < numberOfElements; i++) {
notices.push(retrieveNoticeItemData(ciTaxCode, templateId));
}
}

let response = generateMassiveNotice(noticeServiceUri, subKey, {"notices": notices}, ciTaxCode);
let response = generateMassiveNotice(noticeServiceUri, subKey, {"notices": notices}, ciTaxCode);

console.log("Generate Notice call, Status " + response.status);
console.log("Generate Notice call. ", response.status, response.body);

check(response, {
check(response, {
'Generate PDF status is 200': (response) => response.status === 200,
'Generate PDF content_type is the expected one':
(response) => response.headers["Content-Type"] === "application/json",
(response) => response.headers["Content-Type"] === "application/json",
'Generate Massive Request body not null': (response) => response.body !== null
});
});

sleep(processTime*numberOfElements);
postcondition(JSON.parse(response.body).folderId);
sleep(processTime * numberOfElements);
postcondition(JSON.parse(response.body).folderId);

}
6 changes: 3 additions & 3 deletions performance-test/src/uat.environment.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"environment": [
{
"env": "uat",
"env": "dev",
"blobStorageInstContainerID": "institutionsdatablob",
"blobStorageLogoContainerID": "institutionslogoblob",
"blobStorageNoticeContainerID": "notices",
"noticesDb": "noticesMongoDb",
"noticesCollection": "payment_notice_generation_request",
"noticeServiceUri": "https://api.uat.platform.pagopa.it/print-payment-notice-service/external/v1",
"ciTaxCode": "99999000013"
"noticeServiceUri": "https://api.dev.platform.pagopa.it/print-payment-notice-service/internal/v1",
"ciTaxCode": "80034390585"
}
]
}

0 comments on commit 5e09fe1

Please sign in to comment.