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

Commit 2599f59

Browse files
authored
Smoke test fixes (#154)
1 parent 20d6d5f commit 2599f59

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

tests/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ If you wish to run these tests locally, skip ahead to
9494
following key/values:
9595
- AZDO_PROJECT (e.g. `bedrock`)
9696
- AZDO_ORG (e.g. `epicstuff`)
97-
- AZDO_PAT (e.g. Personal Access Token with access to AZDO_PROJECT) <-- 🔒
97+
- AZDO_PAT (e.g. Personal Access Token with _read/write/manage_ access to
98+
AZDO_PROJECT) <-- 🔒
9899
- SP_APP_ID (e.g Service Principal App Id)
99100
- SP_PASS (e.g Service Principal Password) <-- 🔒
100101
- SP_TENANT (e.g Service Principal Tenant Id)

tests/functions.sh

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ function verify_pipeline_with_poll () {
208208
pipeline_status=$(tr '"\""' '"\\"' <<< "$pipeline_builds" | jq .[0].status)
209209
echo "pipeline_status this iteration --> $pipeline_status"
210210
if [ "$(echo $pipeline_status | grep 'completed')" != "" ]; then
211-
pipeline_result=$(tr '"\""' '"\\"' <<< "$pipeline_builds" | jq .[0].result)
212-
if [ "$(echo $pipeline_result | grep 'succeeded')" != "" ]; then
213-
echo "Successful build for pipeline id $pipeline_id!"
214-
loop_result=$pipeline_result
215-
break
216-
else
217-
echo "Expected successful build for pipeline id $pipeline_id but result is $pipeline_result"
218-
exit 1
219-
fi
211+
pipeline_result=$(tr '"\""' '"\\"' <<< "$pipeline_builds" | jq .[0].result)
212+
if [ "$(echo $pipeline_result | grep 'succeeded')" != "" ]; then
213+
echo "Successful build for pipeline id $pipeline_id!"
214+
loop_result=$pipeline_result
215+
break
216+
else
217+
echo "Expected successful build for pipeline id $pipeline_id but result is $pipeline_result"
218+
exit 1
219+
fi
220220
else
221221
echo "Pipeline Id $pipeline_id status is $pipeline_status. Sleeping for $poll_interval seconds"
222222
sleep $poll_interval
@@ -231,14 +231,20 @@ function verify_pipeline_with_poll () {
231231
function approve_pull_request () {
232232
all_prs=$(az repos pr list --org $1 --p $2)
233233
pr_title=$3
234-
pr_exists=$(tr '"\""' '"\\"' <<< "$all_prs" | jq -r --arg pr_title $pr_title '.[] | select(.title == $pr_title) | != null')
234+
235+
pr_exists=$(echo $all_prs | jq -r --arg pr_title "$pr_title" '.[] | select(.title == $pr_title) != null')
235236
if [ "$pr_exists" != "true" ]; then
236237
echo "PR for '$pr_title' not found"
237238
exit 1
238239
fi
239-
pull_request_id=$(tr '"\""' '"\\"' <<< "$all_prs" | jq -r --arg pr_title $pr_title '.[] | select(.title == $pr_title) | .pullRequestId')
240+
pull_request_id=$(echo $all_prs | jq -r --arg pr_title "$pr_title" '.[] | select(.title == $pr_title) | .pullRequestId')
240241
echo "Found pull request id $pull_request_id for '$pr_title'"
241-
approve_result=$(az repos pr update --id $pull_request_id --auto-complete true -—org $1 --p $2)
242-
echo "PR $pull_request_id approved"
243-
# TODO verify actually successful
242+
approve_result=$(az repos pr update --id "$pull_request_id" --auto-complete true --output json )
243+
244+
if [ "$(echo $approve_result | jq '.mergeStatus' | grep 'succeeded')" != "" ]; then
245+
echo "PR $pull_request_id approved"
246+
else
247+
echo "Issue approving PR $pull_request_id"
248+
exit 1
249+
fi
244250
}

tests/validations.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ spk hld install-manifest-pipeline -o $AZDO_ORG -d $AZDO_PROJECT -p $ACCESS_TOKEN
131131
pipeline_created=$(az pipelines show --name $hld_dir-to-$manifests_dir --org $AZDO_ORG_URL --p $AZDO_PROJECT)
132132

133133
# Verify the pipeline run was successful
134-
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_dir-to-$manifests_dir 180 15
134+
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_dir-to-$manifests_dir 300 15
135135

136136
# App Code Mono Repo set up
137137
mkdir $mono_repo_dir
@@ -197,7 +197,7 @@ spk service install-build-pipeline -o $AZDO_ORG -r $mono_repo_dir -u $remote_rep
197197
pipeline_created=$(az pipelines show --name $pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT)
198198

199199
# Verify the pipeline run was successful
200-
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $pipeline_name 180 25
200+
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $pipeline_name 300 25
201201
# TODO approve the PR this build creates on the HLD
202202

203203
# Start creating a service revision
@@ -212,10 +212,10 @@ git push --set-upstream origin $branchName
212212
current_time=$(date +"%Y-%m-%d-%H-%M-%S")
213213
pr_title="Automated Test PR $current_time"
214214
echo "Creating pull request: '$pr_title'"
215-
spk service create-revision -t $pr_title -d "Adding my new file" --org-name $AZDO_ORG --personal-access-token "$ACCESS_TOKEN_SECRET" --remote-url $remote_repo_url >> $TEST_WORKSPACE/log.txt
215+
spk service create-revision -t "$pr_title" -d "Adding my new file" --org-name $AZDO_ORG --personal-access-token $ACCESS_TOKEN_SECRET --remote-url $remote_repo_url >> $TEST_WORKSPACE/log.txt
216216

217217
echo "Attempting to approve pull request: '$pr_title'"
218218
# Get the id of the pr created and set the PR to be approved
219-
approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT $pr_title
220-
219+
approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "$pr_title"
221220

221+
# TODO hook up helm chart, approve HLD pull request, verify manifest gen pipeline

0 commit comments

Comments
 (0)