Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing check in integration check steps js #98

Merged
merged 9 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ 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 SUBKEY='${{ secrets.SUBKEY }}'
cd ./integration-test
chmod +x ./run_integration_test.sh
./run_integration_test.sh local
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ 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 SUBKEY='${{ secrets.SUBKEY }}'
cd ./integration-test
chmod +x ./run_integration_test.sh
./run_integration_test.sh ${{( github.event.inputs == null && 'uat') || inputs.environment }}
Expand Down
6 changes: 6 additions & 0 deletions .identity/03_github_environment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ locals {
"CLIENT_ID" : module.github_runner_app.application_id,
"TENANT_ID" : data.azurerm_client_config.current.tenant_id,
"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};"
}
Expand Down Expand Up @@ -96,3 +97,8 @@ resource "github_actions_secret" "secret_slack_webhook" {
secret_name = "SLACK_WEBHOOK_URL"
plaintext_value = data.azurerm_key_vault_secret.key_vault_integration_test_webhook_slack.value
}

data "azurerm_key_vault_secret" "key_vault_integration_test_subkey" {
name = "apikey-datastore-receipt" # "integration-test-subkey"
key_vault_id = data.azurerm_key_vault.key_vault_domain.id
}
4 changes: 3 additions & 1 deletion integration-test/src/config/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ 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

DATASTORE_URL=https://api.dev.platform.pagopa.it/receipts/datastore/v1/recoverFailed
4 changes: 3 additions & 1 deletion integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ 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

DATASTORE_URL=https://api.uat.platform.pagopa.it/receipts/datastore/v1/recoverFailed
6 changes: 3 additions & 3 deletions integration-test/src/step_definitions/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ function createReceipt(id, fiscalCode, pdfName) {
async function recoverFailedEvent(eventId) {

var data = {}
if (eventId == null) {
data = { "eventId": eventId };
if (eventId != null) {
data = JSON.stringify({ "eventId": eventId });
}

return await axios.put(datastore_url, data, {})
.then(res => {
return res.data;
return res;
})
.catch(error => {
return error.response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ setDefaultTimeout(360 * 1000);
// initialize variables
this.eventId = null;
this.responseToCheck = null;
this.response = null;
this.receiptId = null;
this.event = null;

Expand Down Expand Up @@ -61,22 +62,27 @@ Then('the receipt has not the status {string}', function (targetStatus) {
Given('a random receipt with id {string} stored with status FAILED', async function (id) {
this.eventId = id;
// prior cancellation to avoid dirty cases
await updateReceiptToFailed(this.eventId);
document = await getDocumentByIdFromReceiptsDatastore(this.eventId);
await updateReceiptToFailed(document.resources[0].id, this.eventId);
});

When('HTTP recovery request is called', async function () {
// boundary time spent by azure function to process event
this.responseToCheck = await recoverFailedEvent(eventId);
this.response = await recoverFailedEvent(this.eventId);
});

Then('the receipt has not the status {string} after {int} ms', async function (targetStatus, time) {
await sleep(time);
this.responseToCheck = await getDocumentByIdFromReceiptsDatastore(eventId);
this.responseToCheck = await getDocumentByIdFromReceiptsDatastore(this.eventId);
assert.notStrictEqual(this.responseToCheck.resources[0].status, targetStatus);
});

When('HTTP recovery request is called without eventId', async function () {
this.responseToCheck = await recoverFailedEvent(null);
this.response = await recoverFailedEvent(null);
});

Then('response has a {int} Http status', function (expectedStatus) {
assert.strictEqual(this.response.status, expectedStatus);
});


Expand Down
Loading