Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/integration-test/src…
Browse files Browse the repository at this point in the history
…/follow-redirects-1.15.6
  • Loading branch information
pasqualespica authored Mar 27, 2024
2 parents 3e0aed3 + 8012e7f commit c31b1cf
Show file tree
Hide file tree
Showing 20 changed files with 313 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .devops/performance-test-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ parameters:
values:
- calculator_getFees
- calculator_getFeesByPsp
- calculator_getFeesMulti
- calculator_getFeesByPspMulti

variables:
${{ if eq(parameters['ENVIRONMENT'], 'dev') }}:
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-afm-calculator
description: Microservice that handles calculation for pagoPA Advanced Fees Management
type: application
version: 2.25.0
appVersion: 2.10.13
version: 2.26.0
appVersion: 2.10.14
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-afm-calculator
tag: "2.10.13"
tag: "2.10.14"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
8 changes: 4 additions & 4 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-afm-calculator
tag: "2.10.13"
tag: "2.10.14"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -53,10 +53,10 @@ microservice-chart:
resources:
requests:
memory: "512Mi"
cpu: "0.5"
cpu: "0.4"
limits:
memory: "768Mi"
cpu: "0.5"
memory: "1024Mi"
cpu: "1.0"
autoscaling:
enable: true
minReplica: 3
Expand Down
10 changes: 5 additions & 5 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-afm-calculator
tag: "2.10.13"
tag: "2.10.14"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -53,7 +53,7 @@ microservice-chart:
resources:
requests:
memory: "512Mi"
cpu: "0.75"
cpu: "0.5"
limits:
memory: "1024Mi"
cpu: "1.0"
Expand All @@ -68,12 +68,12 @@ microservice-chart:
metadata:
# Required
type: Utilization # Allowed types are 'Utilization' or 'AverageValue'
value: "70"
value: "80"
- type: memory
metadata:
# Required
type: Utilization # Allowed types are 'Utilization' or 'AverageValue'
value: "70"
value: "80"
fileConfig: {}
envConfig:
WEBSITE_SITE_NAME: 'pagopaafmcalculator' # required to show cloud role name in application insights
Expand All @@ -87,7 +87,7 @@ microservice-chart:
AMOUNT_THRESHOLD: '0'
ID_PSP_POSTE: 'BPPIITRRXXX'
AMEX_ABI: 'AMREX'
PSP_WHITELIST: 'PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019'
PSP_WHITELIST: 'PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019,TMIL0101,POSOIT22XXX'
OTEL_SERVICE_NAME: "pagopa-afm-calculator"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=uat"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-node-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.13"
"version": "2.10.14"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-node-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.13"
"version": "2.10.14"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.13"
"version": "2.10.14"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Calculator Logic",
"description": "Calculator Logic microservice for pagoPA AFM",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "2.10.13"
"version": "2.10.14"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion performance-test/src/calculator_getFees.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const paymenttypes = data["paymenttypes"];

// workaround to use shared array (only array should be used)
const vars = varsArray[0];
const rootUrl = `${vars.host}`;
const rootUrl = `${vars.hostV1}`;
const cosmosDBURI = `${vars.cosmosDBURI}`;
const databaseID = `${vars.databaseID}`;
const validBundlesNum = `${vars.validBundlesNum}`;
Expand Down
2 changes: 1 addition & 1 deletion performance-test/src/calculator_getFeesByPsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const paymenttypes = data["paymenttypes"];

// workaround to use shared array (only array should be used)
const vars = varsArray[0];
const rootUrl = `${vars.host}`;
const rootUrl = `${vars.hostV1}`;
const cosmosDBURI = `${vars.cosmosDBURI}`;
const databaseID = `${vars.databaseID}`;
const validBundlesNum = `${vars.validBundlesNum}`;
Expand Down
127 changes: 127 additions & 0 deletions performance-test/src/calculator_getFeesByPspMulti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// 1. init code (once per VU)
// prepares the script: loading files, importing modules, and defining functions

import {check} from 'k6';
import {SharedArray} from 'k6/data';
import {addTouchpoints, deleteTouchpoints, getFeesByPspMulti, mapToValidBundles, getValidBundle} from './helpers/calculator_helper.js';
import { createDocument, deleteDocument } from "./helpers/cosmosdb_client.js";

export let options = JSON.parse(open(__ENV.TEST_TYPE));

// read configuration
// note: SharedArray can currently only be constructed inside init code
// according to https://k6.io/docs/javascript-api/k6-data/sharedarray
const varsArray = new SharedArray('vars', function () {
return JSON.parse(open(`${__ENV.VARS}`)).environment;
});

const data = JSON.parse(open('./helpers/data.json'));
const touchpoints = data["touchpoints"];
const paymenttypes = data["paymenttypes"];

// workaround to use shared array (only array should be used)
const vars = varsArray[0];
const rootUrl = `${vars.hostV2}`;
const cartPathApi = `${vars.cartPathApi}`;
const cosmosDBURI = `${vars.cosmosDBURI}`;
const databaseID = `${vars.databaseID}`;
const validBundlesNum = `${vars.validBundlesNum}`;

const cosmosPrimaryKey = `${__ENV.COSMOS_SUBSCRIPTION_KEY}`;


export function setup() {
// 2. setup code (once)
// The setup code runs, setting up the test environment (optional) and generating data
// used to reuse code for the same VU

for (let i = 0; i < touchpoints.length; i++) {
let response = createDocument(cosmosDBURI, databaseID, "touchpoints", cosmosPrimaryKey, touchpoints[i], touchpoints[i]['name']);
check(response, { "status is 201": (res) => (res.status === 201) });
}

for (let i = 0; i < paymenttypes.length; i++) {
let response = createDocument(cosmosDBURI, databaseID, "paymenttypes", cosmosPrimaryKey, paymenttypes[i], paymenttypes[i]['name']);
check(response, { "status is 201": (res) => (res.status === 201) });
}

for (let i = 0; i < validBundlesNum; i++) {
let validBundle = getValidBundle("int-test-"+i);
let response = createDocument(cosmosDBURI, databaseID, "validbundles", cosmosPrimaryKey, validBundle, validBundle['idPsp']);
check(response, { "status is 201": (res) => (res.status === 201) });
}

// precondition is moved to default fn because in this stage
// __VU is always 0 and cannot be used to create env properly
}

export default function calculator() {

const params = {
headers: {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': __ENV.API_SUBSCRIPTION_KEY
},
};

// to give randomness to request in order to avoid caching
const paymentAmount = Math.floor(Math.random() * (100 + __VU) % 100);
//const primaryCreditorInstitution1 = '7777777777' + Math.floor(Math.random() * 10);
//const primaryCreditorInstitution2 = '7777777777' + Math.floor(Math.random() * 10);
const primaryCreditorInstitution = 'fiscalCode-' + Math.floor(Math.random() * 2) + 1;

let payload = {
"bin": "1005066",
"paymentMethod": "CP",
"touchpoint": "CHECKOUT",
"paymentNotice": [
{
"primaryCreditorInstitution": primaryCreditorInstitution,
"paymentAmount": paymentAmount/2,
"transferList": [
{
"creditorInstitution": "fiscalCode-1",
"transferCategory": "TAX1"
}
]
},
{
"primaryCreditorInstitution": primaryCreditorInstitution,
"paymentAmount": paymentAmount/2,
"transferList": [
{
"creditorInstitution": "fiscalCode-1",
"transferCategory": "TAX1"
}
]
}
]
}
const idPsp = String(Math.floor(Math.random() * 10) + 1).padStart(11, '0');

let response = getFeesByPspMulti(rootUrl, cartPathApi, idPsp, payload, params);

check(response, {
'getFeesMulti': (r) => r.status === 200,
});

}

export function teardown() {
// After All
for (let i = 0; i < touchpoints.length; i++) {
let response = deleteDocument(cosmosDBURI, databaseID, "touchpoints", cosmosPrimaryKey, touchpoints[i]['id'], touchpoints[i]["name"]);
check(response, { "status is 204": (res) => (res.status === 204) });
}

for (let i = 0; i < paymenttypes.length; i++) {
let response = deleteDocument(cosmosDBURI, databaseID, "paymenttypes", cosmosPrimaryKey, paymenttypes[i]['id'], paymenttypes[i]["name"]);
check(response, { "status is 204": (res) => (res.status === 204) });
}

for (let i = 0; i < validBundlesNum; i++) {
let validBundle = getValidBundle("int-test-"+i);
let response = deleteDocument(cosmosDBURI, databaseID, "validbundles", cosmosPrimaryKey, validBundle['id'], validBundle['idPsp']);
check(response, { "status is 204": (res) => (res.status === 204) });
}
}
Loading

0 comments on commit c31b1cf

Please sign in to comment.