Skip to content

Commit

Permalink
Merge branch 'main' into PRDP-283-sviluppo-script-rigenerazione-ricev…
Browse files Browse the repository at this point in the history
…ute-utenti-b-simul
  • Loading branch information
pasqualespica authored Dec 15, 2023
2 parents d9b589a + bb48e97 commit 859c551
Show file tree
Hide file tree
Showing 44 changed files with 2,336 additions and 601 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,25 @@ jobs:
export CUCUMBER_PUBLISH_TOKEN=${{ secrets.CUCUMBER_PUBLISH_TOKEN }}
export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}'
export BIZEVENTS_COSMOS_CONN_STRING='${{ secrets.BIZEVENTS_COSMOS_CONN_STRING }}'
export RECEIPTS_STORAGE_CONN_STRING='${{ secrets.RECEIPTS_STORAGE_CONN_STRING }}'
export SUBKEY='${{ secrets.SUBKEY }}'
cd ./integration-test
chmod +x ./run_integration_test.sh
./run_integration_test.sh local
- name: Teardown integration tests
shell: bash
id: run_teardown
if: ${{ always() }}
run: |
export CUCUMBER_PUBLISH_TOKEN=${{ secrets.CUCUMBER_PUBLISH_TOKEN }}
export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}'
export BIZEVENTS_COSMOS_CONN_STRING='${{ secrets.BIZEVENTS_COSMOS_CONN_STRING }}'
export RECEIPTS_STORAGE_CONN_STRING='${{ secrets.RECEIPTS_STORAGE_CONN_STRING }}'
cd ./integration-test
chmod +x ./run_teardown.sh
./run_teardown.sh local
delete_github_deployments:
runs-on: ubuntu-latest
needs: smoke-test
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,24 @@ jobs:
export CUCUMBER_PUBLISH_TOKEN=${{ secrets.CUCUMBER_PUBLISH_TOKEN }}
export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}'
export BIZEVENTS_COSMOS_CONN_STRING='${{ secrets.BIZEVENTS_COSMOS_CONN_STRING }}'
export RECEIPTS_STORAGE_CONN_STRING='${{ secrets.RECEIPTS_STORAGE_CONN_STRING }}'
export SUBKEY='${{ secrets.SUBKEY }}'
cd ./integration-test
chmod +x ./run_integration_test.sh
./run_integration_test.sh ${{( github.event.inputs == null && 'uat') || inputs.environment }}
- name: Teardown integration tests
shell: bash
if: ${{ always() }}
run: |
export CUCUMBER_PUBLISH_TOKEN=${{ secrets.CUCUMBER_PUBLISH_TOKEN }}
export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}'
export BIZEVENTS_COSMOS_CONN_STRING='${{ secrets.BIZEVENTS_COSMOS_CONN_STRING }}'
export RECEIPTS_STORAGE_CONN_STRING='${{ secrets.RECEIPTS_STORAGE_CONN_STRING }}'
cd ./integration-test
chmod +x ./run_teardown.sh
./run_teardown.sh ${{( github.event.inputs == null && 'uat') || inputs.environment }}
notify:
needs: [ create_runner, integration_test ]
runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ]
Expand All @@ -99,7 +112,7 @@ jobs:

delete_github_deployments:
runs-on: ubuntu-latest
needs: integration_test
needs: [integration_test]
if: ${{ always() }}
steps:
- name: Delete Previous deployments
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ obj/
**/report*.txt
**/*.lock
**/.env.local
**/copy.js
**/copy.js
.azure/
package-lock.json
yarn.lock
.env
3 changes: 2 additions & 1 deletion .identity/03_github_environment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ locals {
"SUBSCRIPTION_ID" : data.azurerm_subscription.current.subscription_id,
"SUBKEY" : data.azurerm_key_vault_secret.key_vault_integration_test_subkey.value,
"RECEIPTS_COSMOS_CONN_STRING" : "AccountEndpoint=https://pagopa-${var.env_short}-${local.location_short}-${local.domain}-ds-cosmos-account.documents.azure.com:443/;AccountKey=${data.azurerm_cosmosdb_account.receipts_cosmos.primary_key};",
"BIZEVENTS_COSMOS_CONN_STRING" : "AccountEndpoint=https://pagopa-${var.env_short}-${local.location_short}-bizevents-ds-cosmos-account.documents.azure.com:443/;AccountKey=${data.azurerm_cosmosdb_account.bizevents_cosmos.primary_key};"
"BIZEVENTS_COSMOS_CONN_STRING" : "AccountEndpoint=https://pagopa-${var.env_short}-${local.location_short}-bizevents-ds-cosmos-account.documents.azure.com:443/;AccountKey=${data.azurerm_cosmosdb_account.bizevents_cosmos.primary_key};",
"RECEIPTS_STORAGE_CONN_STRING" : data.azurerm_storage_account.receipts_sa.primary_connection_string,
}
env_variables = {
"CONTAINER_APP_ENVIRONMENT_NAME" : local.container_app_environment.name,
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ then replace env variables with correct values
| `PDV_TOKENIZER_RANDOMIZATION_FACTOR` | PDV Tokenizer randomization factor for interval retry calculation | 0.6 |
| `PDV_TOKENIZER_MAX_RETRIES` | PDV Tokenizer max request retry | 3 |
| `TOKENIZER_APIM_HEADER_KEY` | Tokenizer APIM header key | x-api-key |
| `MAX_DATE_DIFF_MILLIS` | Difference in millis between the current time and the date from witch the<br/> receipts will be fetched in massive recover operation | 360000 |
| `RECOVER_FAILED_CRON` | CRON expression for timer trigger function that recover failed receipt | |
| `MAX_DATE_DIFF_MILLIS` | Difference in millis between the current time and the date from witch the<br/> receipts will be fetched in massive recover operation | 360000 |
| `MAX_DATE_DIFF_NOTIFY_MILLIS` | Difference in millis between the current time and the date from witch the<br/> receipts will be fetched in massive recover operation on notification | 360000 |
| `RECOVER_FAILED_CRON` | CRON expression for timer trigger function that recover failed receipt | |
| `TRIGGER_NOTIFY_REC_SCHEDULE` | CRON expression for timer trigger function that recover not notifier receipt | |
| `RECOVER_FAILED_MASSIVE_MAX_DAYS` | Number of days in addition to the current one to executed failed recovery | 0 |
| `RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS` | Number of days in addition to the current one to executed not notified recovery | 0 |
| `AES_SECRET_KEY` | AES encryption secret key | |
| `AES_SALT` | AES encryption salt |

> to doc details about AZ fn config
> see [here](https://stackoverflow.com/questions/62669672/azure-functions-what-is-the-purpose-of-having-host-json-and-local-settings-jso)
Expand Down
4 changes: 1 addition & 3 deletions docker/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ if test -f "$FILE"; then
rm .env
fi
config=$(yq -r '."microservice-chart".envConfig' ../helm/values-$ENV.yaml)
for line in $(echo $config | jq -r '. | to_entries[] | select(.key) | "\(.key)=\(.value)"'); do
echo $line >> .env
done
echo "$config" | jq -r '. | to_entries[] | select(.key) | "\(.key)=\(.value| @sh)"' >> .env

keyvault=$(yq -r '."microservice-chart".keyvault.name' ../helm/values-$ENV.yaml)
secret=$(yq -r '."microservice-chart".envSecret' ../helm/values-$ENV.yaml)
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: pagopareceiptpdfhelpdesk
description: Microservice description
type: application
version: 0.105.0
appVersion: 0.6.4
version: 0.125.0
appVersion: 0.6.24
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
17 changes: 13 additions & 4 deletions 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-receipt-pdf-helpdesk
tag: "0.6.4"
tag: "0.6.24"
pullPolicy: Always
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
livenessProbe:
Expand Down Expand Up @@ -57,8 +57,8 @@ microservice-chart:
memory: "768Mi"
cpu: "300m"
limits:
memory: "768Mi"
cpu: "400m"
memory: "1512Mi"
cpu: "700m"
autoscaling:
enable: true
minReplica: 1
Expand Down Expand Up @@ -110,22 +110,31 @@ microservice-chart:
MAX_DATE_DIFF_MILLIS: "360000"
MAX_DATE_DIFF_NOTIFY_MILLIS: "360000"
TRIGGER_NOTIFY_REC_SCHEDULE: "0 0 */6 * * *"
RECOVER_FAILED_CRON: "0 0 /12 * * *"
RECOVER_FAILED_CRON: "0 0 */12 * * *"
AZURE_FUNCTIONS_MESH_JAVA_OPTS: "-javaagent:/home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar=12345:/home/site/wwwroot/config.yaml -javaagent:/home/site/wwwroot/opentelemetry-javaagent.jar -Xmx768m -XX:+UseG1GC"
FAILED_AUTORECOVER_ENABLED: "true"
NOT_NOTIFIED_AUTORECOVER_ENABLED: "true"
RECOVER_FAILED_MASSIVE_MAX_DAYS: "0"
RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0"
envConfigMapExternals:
template-maps:
BRAND_LOGO_MAP: brand-logo-map
envFieldRef:
APP_NAME: "metadata.labels['app.kubernetes.io/instance']"
APP_VERSION: "metadata.labels['app.kubernetes.io/version']"
envSecret:
APPLICATIONINSIGHTS_CONNECTION_STRING: "ai-d-connection-string"
COSMOS_RECEIPTS_CONN_STRING: "cosmos-receipt-connection-string"
RECEIPTS_STORAGE_CONN_STRING: "receipts-storage-account-connection-string"
AzureWebJobsStorage: "receipts-storage-account-connection-string"
COSMOS_BIZ_EVENT_CONN_STRING: "cosmos-biz-event-d-connection-string"
COSMOS_RECEIPT_KEY: "cosmos-receipt-pkey"
COSMOS_BIZ_EVENT_KEY: "cosmos-bizevent-pkey"
OTEL_EXPORTER_OTLP_HEADERS: 'elastic-otl-secret-token'
PDV_TOKENIZER_SUBSCRIPTION_KEY: "tokenizer-api-key"
OCP_APIM_SUBSCRIPTION_KEY: "shared-apim-d-subscription-key"
AES_SECRET_KEY: "aes-secret-key"
AES_SALT: "aes-salt"
keyvault:
name: "pagopa-d-receipts-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
13 changes: 11 additions & 2 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-receipt-pdf-helpdesk
tag: "0.6.4"
tag: "0.6.24"
pullPolicy: Always
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
livenessProbe:
Expand Down Expand Up @@ -110,22 +110,31 @@ microservice-chart:
MAX_DATE_DIFF_MILLIS: "360000"
MAX_DATE_DIFF_NOTIFY_MILLIS: "360000"
TRIGGER_NOTIFY_REC_SCHEDULE: "0 0 */6 * * *"
RECOVER_FAILED_CRON: "0 0 /12 * * *"
RECOVER_FAILED_CRON: "0 0 */12 * * *"
AZURE_FUNCTIONS_MESH_JAVA_OPTS: "-javaagent:/home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar=12345:/home/site/wwwroot/config.yaml -javaagent:/home/site/wwwroot/opentelemetry-javaagent.jar -Xmx768m -XX:+UseG1GC"
FAILED_AUTORECOVER_ENABLED: "false"
NOT_NOTIFIED_AUTORECOVER_ENABLED: "false"
RECOVER_FAILED_MASSIVE_MAX_DAYS: "0"
RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0"
envConfigMapExternals:
template-maps:
BRAND_LOGO_MAP: brand-logo-map
envFieldRef:
APP_NAME: "metadata.labels['app.kubernetes.io/instance']"
APP_VERSION: "metadata.labels['app.kubernetes.io/version']"
envSecret:
APPLICATIONINSIGHTS_CONNECTION_STRING: "ai-p-connection-string"
COSMOS_RECEIPTS_CONN_STRING: "cosmos-receipt-connection-string"
RECEIPTS_STORAGE_CONN_STRING: "receipts-storage-account-connection-string"
AzureWebJobsStorage: "receipts-storage-account-connection-string"
OCP_APIM_SUBSCRIPTION_KEY: "shared-apim-p-subscription-key"
COSMOS_BIZ_EVENT_CONN_STRING: "cosmos-biz-event-p-connection-string"
COSMOS_RECEIPT_KEY: "cosmos-receipt-pkey"
COSMOS_BIZ_EVENT_KEY: "cosmos-bizevent-pkey"
OTEL_EXPORTER_OTLP_HEADERS: "elastic-otl-secret-token"
PDV_TOKENIZER_SUBSCRIPTION_KEY: "tokenizer-api-key"
AES_SECRET_KEY: "aes-secret-key"
AES_SALT: "aes-salt"
keyvault:
name: "pagopa-p-receipts-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
13 changes: 11 additions & 2 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-receipt-pdf-helpdesk
tag: "0.6.4"
tag: "0.6.24"
pullPolicy: Always
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
livenessProbe:
Expand Down Expand Up @@ -110,22 +110,31 @@ microservice-chart:
MAX_DATE_DIFF_MILLIS: "360000"
MAX_DATE_DIFF_NOTIFY_MILLIS: "360000"
TRIGGER_NOTIFY_REC_SCHEDULE: "0 0 */6 * * *"
RECOVER_FAILED_CRON: "0 0 /12 * * *"
RECOVER_FAILED_CRON: "0 0 */12 * * *"
AZURE_FUNCTIONS_MESH_JAVA_OPTS: "-javaagent:/home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar=12345:/home/site/wwwroot/config.yaml -javaagent:/home/site/wwwroot/opentelemetry-javaagent.jar -Xmx768m -XX:+UseG1GC"
FAILED_AUTORECOVER_ENABLED: "true"
NOT_NOTIFIED_AUTORECOVER_ENABLED: "true"
RECOVER_FAILED_MASSIVE_MAX_DAYS: "0"
RECOVER_NOT_NOTIFIED_MASSIVE_MAX_DAYS: "0"
envConfigMapExternals:
template-maps:
BRAND_LOGO_MAP: brand-logo-map
envFieldRef:
APP_NAME: "metadata.labels['app.kubernetes.io/instance']"
APP_VERSION: "metadata.labels['app.kubernetes.io/version']"
envSecret:
APPLICATIONINSIGHTS_CONNECTION_STRING: "ai-u-connection-string"
COSMOS_RECEIPTS_CONN_STRING: "cosmos-receipt-connection-string"
RECEIPTS_STORAGE_CONN_STRING: "receipts-storage-account-connection-string"
AzureWebJobsStorage: "receipts-storage-account-connection-string"
COSMOS_BIZ_EVENT_CONN_STRING: "cosmos-biz-event-u-connection-string"
COSMOS_RECEIPT_KEY: "cosmos-receipt-pkey"
COSMOS_BIZ_EVENT_KEY: "cosmos-bizevent-pkey"
OTEL_EXPORTER_OTLP_HEADERS: "elastic-otl-secret-token"
PDV_TOKENIZER_SUBSCRIPTION_KEY: "tokenizer-api-key"
OCP_APIM_SUBSCRIPTION_KEY: "shared-apim-u-subscription-key"
AES_SECRET_KEY: "aes-secret-key"
AES_SALT: "aes-salt"
keyvault:
name: "pagopa-u-receipts-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
Expand Down
3 changes: 2 additions & 1 deletion integration-test/run_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ set -e
# run integration tests
cd ./src || exit
yarn install
yarn test:"$1"
yarn test:"$1"

8 changes: 8 additions & 0 deletions integration-test/run_teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

echo "Sleeping for 120 seconds (2 minutes) before running teardown"
sleep 120

cd ./src || exit
yarn install
yarn teardown:"$1"
8 changes: 7 additions & 1 deletion integration-test/src/config/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ BIZ_EVENT_COSMOS_DB_CONTAINER_NAME=biz-events
RECEIPTS_COSMOS_CONN_STRING=<cosmos-connection-string>
RECEIPT_COSMOS_DB_NAME=db
RECEIPT_COSMOS_DB_CONTAINER_NAME=receipts
RECEIPT_ERROR_COSMOS_DB_CONTAINER_NAME=receipts-message-errors

HELPDESK_URL=https://api.dev.platform.pagopa.it/receipts/helpdesk/v1/recoverFailed
RECEIPTS_STORAGE_CONN_STRING=<storage-account-connection-string>
BLOB_STORAGE_CONTAINER_NAME=pagopa-d-weu-receipts-azure-blob-receipt-st-attach

ENVIRONMENT=dev

HELPDESK_URL=https://api.dev.platform.pagopa.it/receipts/helpdesk/v1/
10 changes: 9 additions & 1 deletion integration-test/src/config/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ BIZ_EVENT_COSMOS_DB_CONTAINER_NAME=biz-events

RECEIPTS_COSMOS_CONN_STRING=<cosmos-connection-string>
RECEIPT_COSMOS_DB_NAME=db
RECEIPT_COSMOS_DB_CONTAINER_NAME=receipts
RECEIPT_COSMOS_DB_CONTAINER_NAME=receipts
RECEIPT_ERROR_COSMOS_DB_CONTAINER_NAME=receipts-message-errors

RECEIPTS_STORAGE_CONN_STRING=<storage-account-connection-string>
BLOB_STORAGE_CONTAINER_NAME=pagopa-d-weu-receipts-azure-blob-receipt-st-attach

ENVIRONMENT=local

HELPDESK_URL=http://localhost:60486/
8 changes: 7 additions & 1 deletion integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ BIZ_EVENT_COSMOS_DB_CONTAINER_NAME=biz-events
RECEIPTS_COSMOS_CONN_STRING=<cosmos-connection-string>
RECEIPT_COSMOS_DB_NAME=db
RECEIPT_COSMOS_DB_CONTAINER_NAME=receipts
RECEIPT_ERROR_COSMOS_DB_CONTAINER_NAME=receipts-message-errors

HELPDESK_URL=https://api.uat.platform.pagopa.it/receipts/helpdesk/v1/recoverFailed
RECEIPTS_STORAGE_CONN_STRING=<storage-account-connection-string>
BLOB_STORAGE_CONTAINER_NAME=pagopa-u-weu-receipts-azure-blob-receipt-st-attach

ENVIRONMENT=uat

HELPDESK_URL=https://api.uat.platform.pagopa.it/receipts/helpdesk/v1/
Loading

0 comments on commit 859c551

Please sign in to comment.