Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 3ec06b1

Browse files
authored
Create unique tables in the onboard test (#377)
1 parent 658a0e8 commit 3ec06b1

File tree

3 files changed

+93
-19
lines changed

3 files changed

+93
-19
lines changed

tests/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ tests.
2424
- This file orchestrates the service introspection scenarios and is designed to
2525
fail on first error.
2626

27+
## Introspection validations data
28+
29+
The `introspection-validations.sh` test will create a new Azure Storage Table in
30+
the given storage account each time it is run. To automatically clean up the
31+
data, set up a Logic App to delete it. You can use the template
32+
[`introspection-clean-data-logic-app.json`](./introspection-clean-data-logic-app.json)
33+
for this. Edit the values in `parameters` and fill in your `<subscription id>`
34+
and `resource group` where the storage account is.
35+
36+
To check existing Logic Apps in your subscription, go to the [portal.azure.com](http://portal.azure.com) and search for Logic Apps.
37+
2738
# Scenarios Exercised So Far
2839

2940
- As a developer create a mono-repo and add services
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"definition": {
3+
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
4+
"actions": {
5+
"Filter_array": {
6+
"inputs": {
7+
"from": "@body('List_tables')?['value']",
8+
"where": "@startsWith(item()?['TableName'], 'spktest')"
9+
},
10+
"runAfter": {
11+
"List_tables": ["Succeeded"]
12+
},
13+
"type": "Query"
14+
},
15+
"For_each": {
16+
"actions": {
17+
"Delete_a_table": {
18+
"inputs": {
19+
"host": {
20+
"connection": {
21+
"name": "@parameters('$connections')['azuretables']['connectionId']"
22+
}
23+
},
24+
"method": "delete",
25+
"path": "/Tables/@{encodeURIComponent(items('For_each')?['TableName'])}"
26+
},
27+
"runAfter": {},
28+
"type": "ApiConnection"
29+
}
30+
},
31+
"foreach": "@body('Filter_array')",
32+
"runAfter": {
33+
"Filter_array": ["Succeeded"]
34+
},
35+
"type": "Foreach"
36+
},
37+
"List_tables": {
38+
"inputs": {
39+
"host": {
40+
"connection": {
41+
"name": "@parameters('$connections')['azuretables']['connectionId']"
42+
}
43+
},
44+
"method": "get",
45+
"path": "/Tables"
46+
},
47+
"runAfter": {},
48+
"type": "ApiConnection"
49+
}
50+
},
51+
"contentVersion": "1.0.0.0",
52+
"outputs": {},
53+
"parameters": {
54+
"$connections": {
55+
"defaultValue": {},
56+
"type": "Object"
57+
}
58+
},
59+
"triggers": {
60+
"Recurrence": {
61+
"recurrence": {
62+
"frequency": "Day",
63+
"interval": 1
64+
},
65+
"type": "Recurrence"
66+
}
67+
}
68+
},
69+
"parameters": {
70+
"$connections": {
71+
"value": {
72+
"azuretables": {
73+
"connectionId": "/subscriptions/<subscription id>/resourceGroups/<resource group>/providers/Microsoft.Web/connections/azuretables",
74+
"connectionName": "azuretables",
75+
"id": "/subscriptions/<subscription id>/providers/Microsoft.Web/locations/centralus/managedApis/azuretables"
76+
}
77+
}
78+
}
79+
}
80+
}

tests/introspection-validations.sh

+2-19
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,11 @@ fi
6464
cd $TEST_WORKSPACE
6565

6666
# spk deployment onboard validation test
67-
sat_onboard_name=smokedeploymentstest
67+
sat_onboard_name='spktest'$RANDOM
6868
subscription_id=$(az account list | jq '.[] | select(.isDefault == true) | .id' -r)
6969
storage_account_exists $AZ_STORAGE_ACCOUNT $AZ_RESOURCE_GROUP "fail"
70-
storage_account_table_exists $sat_onboard_name $AZ_STORAGE_ACCOUNT "delete"
71-
72-
wait_delete_seconds=120
73-
start=0
74-
wait_seconds=10
75-
while [ $start -lt $wait_delete_seconds ]; do
76-
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)
77-
if [[ $onboard_result == *"table is being deleted"* ]]; then
78-
echo "Table $sat_onboard_name is still being deleted"
79-
echo "Wait $wait_seconds seconds..."
80-
sleep $wait_seconds
81-
start=$((start + wait_seconds))
82-
else
83-
echo "onboard finished"
84-
break
85-
fi
86-
done
8770

71+
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)
8872
storage_account_table_exists $sat_onboard_name $AZ_STORAGE_ACCOUNT "fail"
89-
storage_account_table_exists $sat_onboard_name $AZ_STORAGE_ACCOUNT "delete"
9073

9174
echo "Successfully validated spk deployment onboard."

0 commit comments

Comments
 (0)