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

Commit 614bee9

Browse files
edaenaEdaena SalinasEdaena SalinasEdaena Salinasmtarng
authored
spk rings integration test (#394)
* Add create ring integration test * Fix parameter * Remove comment * Fix directory * Validate file contents * Re-order test * Fix timeout * Update pipeline id for introspection test * Add instructions for test as comment * Commenting out rings test Co-authored-by: Edaena Salinas <[email protected]> Co-authored-by: Edaena Salinas <[email protected]> Co-authored-by: Edaena Salinas <[email protected]> Co-authored-by: Michael Tarng <[email protected]> Co-authored-by: Yvonne Radsmikham <[email protected]>
1 parent db4f224 commit 614bee9

File tree

2 files changed

+68
-6
lines changed

2 files changed

+68
-6
lines changed

tests/functions.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ function verify_pipeline_with_poll () {
291291
local pipeline_name=$3
292292
poll_timeout=$4
293293
poll_interval=$5
294+
expected_build_count=$6
294295
end=$((SECONDS+$poll_timeout))
295296
loop_result="unknown"
296297

@@ -304,8 +305,8 @@ function verify_pipeline_with_poll () {
304305

305306
# We expect only 1 build right now
306307
build_count=$(tr '"\""' '"\\"' <<< "$pipeline_builds" | jq '. | length')
307-
if [ "$build_count" != "1" ]; then
308-
echo "Expected 1 build for pipeline: $pipeline_name-$pipeline_id but found $build_count"
308+
if [ "$build_count" != "$expected_build_count" ]; then
309+
echo "Expected $expected_build_count build for pipeline: $pipeline_name-$pipeline_id but found $build_count"
309310
exit 1
310311
fi
311312

tests/validations.sh

+65-4
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ spk hld install-manifest-pipeline --org-name $AZDO_ORG -d $AZDO_PROJECT --person
152152
pipeline_created=$(az pipelines show --name $hld_to_manifest_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT)
153153

154154
# Verify hld to manifest pipeline run was successful
155-
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15
155+
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 1
156156

157157
##################################
158158
# External Helm Chart Repo Setup START
@@ -266,7 +266,7 @@ spk project install-lifecycle-pipeline --org-name $AZDO_ORG --devops-project $AZ
266266
pipeline_created=$(az pipelines show --name $lifecycle_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT)
267267

268268
# Verify lifecycle pipeline run was successful
269-
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15
269+
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 1
270270

271271
# Approve pull request from lifecycle pipeline
272272
echo "Finding pull request that $lifecycle_pipeline_name pipeline created..."
@@ -288,7 +288,7 @@ spk service install-build-pipeline --org-name $AZDO_ORG -u $remote_repo_url -d $
288288
pipeline_created=$(az pipelines show --name $frontend_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT)
289289

290290
# Verify frontend service pipeline run was successful
291-
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $frontend_pipeline_name 300 15
291+
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $frontend_pipeline_name 300 15 1
292292

293293
echo "Finding pull request that $frontend_pipeline_name pipeline created..."
294294
approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Updating $FrontEnd image tag to master"
@@ -297,6 +297,8 @@ approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Updating $FrontEnd image tag t
297297
##################################
298298
# App Mono Repo Service Revision START
299299
##################################
300+
cd $TEST_WORKSPACE
301+
cd $mono_repo_dir
300302

301303
echo "Creating service revision"
302304
git branch $branchName
@@ -342,6 +344,65 @@ validate_file "$TEST_WORKSPACE/$manifests_dir/prod/$mono_repo_dir/$FrontEndCompl
342344
# Eventually add rings as some stage....
343345
# --------------------------------
344346

347+
# Get the current pipeline/build id at this stage. This will be used by the introspection integration test.
348+
pipeline1id=$(az pipelines build list --definition-ids $pipeline_id --organization $AZDO_ORG_URL --project $AZDO_PROJECT | jq '.[0].id')
349+
350+
##################################
351+
# App Mono Repo create ring
352+
##################################
353+
# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 400 15 2
354+
# echo "Finding pull request that $lifecycle_pipeline_name pipeline created..."
355+
# approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD"
356+
357+
# # Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish
358+
# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 400 15 4
359+
# ring_name=qa-ring
360+
361+
# cd $TEST_WORKSPACE
362+
# cd $mono_repo_dir
363+
364+
# echo "Create ring"
365+
# git checkout master
366+
# git pull origin master
367+
# spk ring create $ring_name
368+
# git add -A
369+
# git commit -m "Adding test ring"
370+
# git push -u origin --all
371+
372+
# # Wait for the lifecycle pipeline to finish and approve the pull request
373+
# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 300 15 3
374+
# echo "Finding pull request that $lifecycle_pipeline_name pipeline created..."
375+
# approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD"
376+
377+
# # Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish
378+
# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 5
379+
380+
# # Verify the file was added in the manifest repository
381+
# cd $TEST_WORKSPACE
382+
# cd $manifests_dir
383+
384+
# git pull origin master
385+
386+
# ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/$ring_name"
387+
# if [ ! -d "$ring_dir" ]; then
388+
# echo "Directory '$ring_dir' does not exist"
389+
# exit 1
390+
# fi
391+
392+
# echo "Validating ingress routes"
393+
394+
# validate_file "$ring_dir/static.yaml" "'PathPrefix(\`/fabrikam-acme-frontend\`) && Headers(\`Ring\`, \`qa-ring\`)'"
395+
396+
# echo "Successfully created a ring."
397+
398+
# --------------------------------
399+
# Push the ring branch
400+
# git branch $ring_name
401+
# git checkout $ring_name
402+
403+
404+
# --------------------------------
405+
345406
echo "Successfully reached the end of the service validations scripts."
346407

347408
# ##################################
@@ -365,7 +426,7 @@ else
365426
fi
366427

367428
# Compare $pipeline_id with the data returned by get.
368-
pipeline1id=$(az pipelines build list --definition-ids $pipeline_id --organization $AZDO_ORG_URL --project $AZDO_PROJECT | jq '.[0].id')
429+
369430
listofIds=$(cat file.json | jq '.[].srcToDockerBuild.id')
370431

371432
if [[ $listofIds == *"$pipeline1id"* ]]; then

0 commit comments

Comments
 (0)