Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.
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
11 changes: 11 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ 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 `<subscription id>`
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
Expand Down
80 changes: 80 additions & 0 deletions tests/introspection-clean-data-logic-app.json
Original file line number Diff line number Diff line change
@@ -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/<subscription id>/resourceGroups/<resource group>/providers/Microsoft.Web/connections/azuretables",
"connectionName": "azuretables",
"id": "/subscriptions/<subscription id>/providers/Microsoft.Web/locations/centralus/managedApis/azuretables"
}
}
}
}
}
21 changes: 2 additions & 19 deletions tests/introspection-validations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."