From 0d86fa67a60438cb93224c67af05a6341adb5b62 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Fri, 6 Mar 2020 16:01:15 -0800 Subject: [PATCH 1/3] Create unique tables in the onboard test --- tests/introspection-validations.sh | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tests/introspection-validations.sh b/tests/introspection-validations.sh index 4451e81bf..c5577811b 100644 --- a/tests/introspection-validations.sh +++ b/tests/introspection-validations.sh @@ -64,28 +64,11 @@ fi cd $TEST_WORKSPACE # spk deployment onboard validation test -sat_onboard_name=smokedeploymentstest +sat_onboard_name='spktest'$RANDOM subscription_id=$(az account list | jq '.[] | select(.isDefault == true) | .id' -r) storage_account_exists $AZ_STORAGE_ACCOUNT $AZ_RESOURCE_GROUP "fail" -storage_account_table_exists $sat_onboard_name $AZ_STORAGE_ACCOUNT "delete" - -wait_delete_seconds=120 -start=0 -wait_seconds=10 -while [ $start -lt $wait_delete_seconds ]; do - onboard_result=$(spk deployment onboard -s $AZ_STORAGE_ACCOUNT -t $sat_onboard_name -l $sa_location -r $AZ_RESOURCE_GROUP --subscription-id $subscription_id --service-principal-id $SP_APP_ID --service-principal-password $SP_PASS --tenant-id $SP_TENANT) - if [[ $onboard_result == *"table is being deleted"* ]]; then - echo "Table $sat_onboard_name is still being deleted" - echo "Wait $wait_seconds seconds..." - sleep $wait_seconds - start=$((start + wait_seconds)) - else - echo "onboard finished" - break - fi -done +onboard_result=$(spk deployment onboard -s $AZ_STORAGE_ACCOUNT -t $sat_onboard_name -l $sa_location -r $AZ_RESOURCE_GROUP --subscription-id $subscription_id --service-principal-id $SP_APP_ID --service-principal-password $SP_PASS --tenant-id $SP_TENANT) storage_account_table_exists $sat_onboard_name $AZ_STORAGE_ACCOUNT "fail" -storage_account_table_exists $sat_onboard_name $AZ_STORAGE_ACCOUNT "delete" echo "Successfully validated spk deployment onboard." From a0be0c52bf6cc62ecd297b3c76522ea93526a673 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Mon, 9 Mar 2020 10:52:44 -0700 Subject: [PATCH 2/3] Add logic app template --- tests/README.md | 9 +++ tests/introspection-clean-data-logic-app.json | 80 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 tests/introspection-clean-data-logic-app.json diff --git a/tests/README.md b/tests/README.md index 642676129..3944f3b0c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -24,6 +24,15 @@ tests. - This file orchestrates the service introspection scenarios and is designed to fail on first error. +## Introspection validations data + +The `introspection-validations.sh` test will create a new Azure Storage Table in +the given storage account each time it is run. To automatically clean up the +data, set up a Logic App to delete it. You can use the template +[`introspection-clean-data-logic-app.json`](./introspection-clean-data-logic-app.json) +for this. Edit the values in `parameters` and fill in your `` +and `resource group` where the storage account is. + # Scenarios Exercised So Far - As a developer create a mono-repo and add services diff --git a/tests/introspection-clean-data-logic-app.json b/tests/introspection-clean-data-logic-app.json new file mode 100644 index 000000000..9130b4ff1 --- /dev/null +++ b/tests/introspection-clean-data-logic-app.json @@ -0,0 +1,80 @@ +{ + "definition": { + "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", + "actions": { + "Filter_array": { + "inputs": { + "from": "@body('List_tables')?['value']", + "where": "@startsWith(item()?['TableName'], 'spktest')" + }, + "runAfter": { + "List_tables": ["Succeeded"] + }, + "type": "Query" + }, + "For_each": { + "actions": { + "Delete_a_table": { + "inputs": { + "host": { + "connection": { + "name": "@parameters('$connections')['azuretables']['connectionId']" + } + }, + "method": "delete", + "path": "/Tables/@{encodeURIComponent(items('For_each')?['TableName'])}" + }, + "runAfter": {}, + "type": "ApiConnection" + } + }, + "foreach": "@body('Filter_array')", + "runAfter": { + "Filter_array": ["Succeeded"] + }, + "type": "Foreach" + }, + "List_tables": { + "inputs": { + "host": { + "connection": { + "name": "@parameters('$connections')['azuretables']['connectionId']" + } + }, + "method": "get", + "path": "/Tables" + }, + "runAfter": {}, + "type": "ApiConnection" + } + }, + "contentVersion": "1.0.0.0", + "outputs": {}, + "parameters": { + "$connections": { + "defaultValue": {}, + "type": "Object" + } + }, + "triggers": { + "Recurrence": { + "recurrence": { + "frequency": "Day", + "interval": 1 + }, + "type": "Recurrence" + } + } + }, + "parameters": { + "$connections": { + "value": { + "azuretables": { + "connectionId": "/subscriptions//resourceGroups//providers/Microsoft.Web/connections/azuretables", + "connectionName": "azuretables", + "id": "/subscriptions//providers/Microsoft.Web/locations/centralus/managedApis/azuretables" + } + } + } + } +} From 9af269ad867b0dd482527569635e96c6d263cf45 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Mon, 9 Mar 2020 15:17:41 -0700 Subject: [PATCH 3/3] Update README.md --- tests/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/README.md b/tests/README.md index 3944f3b0c..b6e03ba92 100644 --- a/tests/README.md +++ b/tests/README.md @@ -33,6 +33,8 @@ data, set up a Logic App to delete it. You can use the template for this. Edit the values in `parameters` and fill in your `` and `resource group` where the storage account is. +To check existing Logic Apps in your subscription, go to the [portal.azure.com](http://portal.azure.com) and search for Logic Apps. + # Scenarios Exercised So Far - As a developer create a mono-repo and add services