From 41cc058304a1437c9d8959b39e69351c21894252 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Wed, 11 Mar 2020 15:45:03 -0700 Subject: [PATCH 01/10] Add create ring integration test --- tests/functions.sh | 5 +++-- tests/validations.sh | 44 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/tests/functions.sh b/tests/functions.sh index ff5e179bb..fa2174751 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -291,6 +291,7 @@ function verify_pipeline_with_poll () { local pipeline_name=$3 poll_timeout=$4 poll_interval=$5 + expected_build_count=$6 end=$((SECONDS+$poll_timeout)) loop_result="unknown" @@ -304,8 +305,8 @@ function verify_pipeline_with_poll () { # We expect only 1 build right now build_count=$(tr '"\""' '"\\"' <<< "$pipeline_builds" | jq '. | length') - if [ "$build_count" != "1" ]; then - echo "Expected 1 build for pipeline: $pipeline_name-$pipeline_id but found $build_count" + if [ "$build_count" != "$expected_build_count" ]; then + echo "Expected $expected_build_count build for pipeline: $pipeline_name-$pipeline_id but found $build_count" exit 1 fi diff --git a/tests/validations.sh b/tests/validations.sh index 1fdbf0a81..5ead33aac 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -151,7 +151,7 @@ spk hld install-manifest-pipeline --org-name $AZDO_ORG -d $AZDO_PROJECT --person pipeline_created=$(az pipelines show --name $hld_to_manifest_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT) # Verify hld to manifest pipeline run was successful -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 1 ################################## # External Helm Chart Repo Setup START @@ -265,7 +265,7 @@ spk project install-lifecycle-pipeline --org-name $AZDO_ORG --devops-project $AZ pipeline_created=$(az pipelines show --name $lifecycle_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT) # Verify lifecycle pipeline run was successful -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 1 1 # Approve pull request from lifecycle pipeline echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." @@ -287,12 +287,50 @@ spk service install-build-pipeline --org-name $AZDO_ORG -u $remote_repo_url -d $ pipeline_created=$(az pipelines show --name $frontend_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT) # Verify frontend service pipeline run was successful -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $frontend_pipeline_name 300 15 +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $frontend_pipeline_name 300 15 1 echo "Finding pull request that $frontend_pipeline_name pipeline created..." approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Updating $FrontEnd image tag to master" # -------------------------------- +################################## +# App Mono Repo create ring +################################## +ring_name=test + +cd $TEST_WORKSPACE +cd $mono_repo_dir + +echo "Create ring" +spk ring create $ring_name +git add -A +git commit -m "Adding test ring" +git push -u origin --all + +# Wait for the lifecycle pipeline to finish and approve the pull request +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 2 +echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." +approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" + +# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 4 + +# Verify the file was added in the manifest repository +cd $TEST_WORKSPACE +cd $manifests_dir + +git pull origin master +#/prod/fabrikam2019/fabrikam-acme-front-end/test/*.yaml +#prod/fabrikam2019/fabrikam-acme-frontend/ +ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/test" +if [ ! -d "$ring_dir" ]; then + echo "Directory '$ring_dir' does not exist" + exit 1 +fi + +echo "Successfully created a ring." +# -------------------------------- + ################################## # App Mono Repo Service Revision START ################################## From feb3dda9237d3d30979cb2b57c41a1ea3e35b6e9 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Wed, 11 Mar 2020 16:06:59 -0700 Subject: [PATCH 02/10] Fix parameter --- tests/validations.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/validations.sh b/tests/validations.sh index 67e9255b2..d8dfdc55e 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -266,7 +266,7 @@ spk project install-lifecycle-pipeline --org-name $AZDO_ORG --devops-project $AZ pipeline_created=$(az pipelines show --name $lifecycle_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT) # Verify lifecycle pipeline run was successful -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 1 1 +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 1 # Approve pull request from lifecycle pipeline echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." From c32587950f1764f2bc934e92819818a72bd03fe9 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Wed, 11 Mar 2020 16:08:11 -0700 Subject: [PATCH 03/10] Remove comment --- tests/validations.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/validations.sh b/tests/validations.sh index d8dfdc55e..787614923 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -321,8 +321,7 @@ cd $TEST_WORKSPACE cd $manifests_dir git pull origin master -#/prod/fabrikam2019/fabrikam-acme-front-end/test/*.yaml -#prod/fabrikam2019/fabrikam-acme-frontend/ + ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/test" if [ ! -d "$ring_dir" ]; then echo "Directory '$ring_dir' does not exist" From 573aed8dc02a849201816be6c961f60b9668c791 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Wed, 11 Mar 2020 16:12:23 -0700 Subject: [PATCH 04/10] Fix directory --- tests/validations.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/validations.sh b/tests/validations.sh index 787614923..d033de78d 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -334,6 +334,8 @@ echo "Successfully created a ring." ################################## # App Mono Repo Service Revision START ################################## +cd $TEST_WORKSPACE +cd $mono_repo_dir echo "Creating service revision" git branch $branchName From 3aa0d50bd70ef4c099560c0d8baf7fc5aae07174 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Wed, 11 Mar 2020 17:04:02 -0700 Subject: [PATCH 05/10] Validate file contents --- tests/validations.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/validations.sh b/tests/validations.sh index d033de78d..eeb72dc84 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -297,7 +297,7 @@ approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Updating $FrontEnd image tag t ################################## # App Mono Repo create ring ################################## -ring_name=test +ring_name=qa-ring cd $TEST_WORKSPACE cd $mono_repo_dir @@ -322,12 +322,16 @@ cd $manifests_dir git pull origin master -ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/test" +ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/$ring_name" if [ ! -d "$ring_dir" ]; then echo "Directory '$ring_dir' does not exist" exit 1 fi +echo "Validating ingress routes" + +validate_file "$ring_dir/static.yaml" "'PathPrefix(\`/fabrikam-acme-frontend\`) && Headers(\`Ring\`, \`qa-ring\`)'" + echo "Successfully created a ring." # -------------------------------- From ca291d2d18b3ac2a32923baeca978e4aa5bfc625 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Wed, 11 Mar 2020 17:38:31 -0700 Subject: [PATCH 06/10] Re-order test --- tests/validations.sh | 84 +++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/tests/validations.sh b/tests/validations.sh index eeb72dc84..633401332 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -294,47 +294,6 @@ echo "Finding pull request that $frontend_pipeline_name pipeline created..." approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Updating $FrontEnd image tag to master" # -------------------------------- -################################## -# App Mono Repo create ring -################################## -ring_name=qa-ring - -cd $TEST_WORKSPACE -cd $mono_repo_dir - -echo "Create ring" -spk ring create $ring_name -git add -A -git commit -m "Adding test ring" -git push -u origin --all - -# Wait for the lifecycle pipeline to finish and approve the pull request -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 2 -echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." -approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" - -# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 4 - -# Verify the file was added in the manifest repository -cd $TEST_WORKSPACE -cd $manifests_dir - -git pull origin master - -ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/$ring_name" -if [ ! -d "$ring_dir" ]; then - echo "Directory '$ring_dir' does not exist" - exit 1 -fi - -echo "Validating ingress routes" - -validate_file "$ring_dir/static.yaml" "'PathPrefix(\`/fabrikam-acme-frontend\`) && Headers(\`Ring\`, \`qa-ring\`)'" - -echo "Successfully created a ring." -# -------------------------------- - ################################## # App Mono Repo Service Revision START ################################## @@ -385,6 +344,49 @@ validate_file "$TEST_WORKSPACE/$manifests_dir/prod/$mono_repo_dir/$FrontEndCompl # Eventually add rings as some stage.... # -------------------------------- +################################## +# App Mono Repo create ring +################################## +ring_name=qa-ring + +cd $TEST_WORKSPACE +cd $mono_repo_dir + +echo "Create ring" +git checkout master +git pull origin master +spk ring create $ring_name +git add -A +git commit -m "Adding test ring" +git push -u origin --all + +# Wait for the lifecycle pipeline to finish and approve the pull request +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 3 +echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." +approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" + +# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 4 + +# Verify the file was added in the manifest repository +cd $TEST_WORKSPACE +cd $manifests_dir + +git pull origin master + +ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/$ring_name" +if [ ! -d "$ring_dir" ]; then + echo "Directory '$ring_dir' does not exist" + exit 1 +fi + +echo "Validating ingress routes" + +validate_file "$ring_dir/static.yaml" "'PathPrefix(\`/fabrikam-acme-frontend\`) && Headers(\`Ring\`, \`qa-ring\`)'" + +echo "Successfully created a ring." +# -------------------------------- + echo "Successfully reached the end of the service validations scripts." # ################################## From a0e0382112d41aef9c79ecd6645f3eafb7d36b42 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Thu, 12 Mar 2020 16:13:59 -0700 Subject: [PATCH 07/10] Fix timeout --- tests/validations.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/validations.sh b/tests/validations.sh index 633401332..12615beeb 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -317,6 +317,12 @@ spk service create-revision -t "$pr_title" -d "Adding my new file" --org-name $A echo "Attempting to approve pull request: '$pr_title'" # Get the id of the pr created and set the PR to be approved approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "$pr_title" +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 400 15 2 +echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." +approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" + +# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 400 15 4 # -------------------------------- ################################## @@ -361,12 +367,12 @@ git commit -m "Adding test ring" git push -u origin --all # Wait for the lifecycle pipeline to finish and approve the pull request -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 180 15 3 +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 300 15 3 echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" # Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 4 +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 5 # Verify the file was added in the manifest repository cd $TEST_WORKSPACE From 7de9cacf9c759f107423074e2d00c172527fe2ab Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Fri, 13 Mar 2020 12:25:39 -0700 Subject: [PATCH 08/10] Update pipeline id for introspection test --- tests/validations.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/validations.sh b/tests/validations.sh index 12615beeb..476a63be2 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -317,12 +317,6 @@ spk service create-revision -t "$pr_title" -d "Adding my new file" --org-name $A echo "Attempting to approve pull request: '$pr_title'" # Get the id of the pr created and set the PR to be approved approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "$pr_title" -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 400 15 2 -echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." -approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" - -# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 400 15 4 # -------------------------------- ################################## @@ -350,9 +344,18 @@ validate_file "$TEST_WORKSPACE/$manifests_dir/prod/$mono_repo_dir/$FrontEndCompl # Eventually add rings as some stage.... # -------------------------------- +# Get the current pipeline/build id at this stage. This will be used by the introspection integration test. +pipeline1id=$(az pipelines build list --definition-ids $pipeline_id --organization $AZDO_ORG_URL --project $AZDO_PROJECT | jq '.[0].id') + ################################## # App Mono Repo create ring ################################## +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 400 15 2 +echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." +approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" + +# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish +verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 400 15 4 ring_name=qa-ring cd $TEST_WORKSPACE @@ -416,7 +419,7 @@ else fi # Compare $pipeline_id with the data returned by get. -pipeline1id=$(az pipelines build list --definition-ids $pipeline_id --organization $AZDO_ORG_URL --project $AZDO_PROJECT | jq '.[0].id') + listofIds=$(cat file.json | jq '.[].srcToDockerBuild.id') if [[ $listofIds == *"$pipeline1id"* ]]; then From 851b41ee436e6735a2a2b0a497d025041f6413e2 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Mon, 16 Mar 2020 15:33:32 -0700 Subject: [PATCH 09/10] Add instructions for test as comment --- tests/validations.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/validations.sh b/tests/validations.sh index 476a63be2..8b53b643e 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -394,6 +394,13 @@ echo "Validating ingress routes" validate_file "$ring_dir/static.yaml" "'PathPrefix(\`/fabrikam-acme-frontend\`) && Headers(\`Ring\`, \`qa-ring\`)'" echo "Successfully created a ring." + +# -------------------------------- +# Push the ring branch +# git branch $ring_name +# git checkout $ring_name + + # -------------------------------- echo "Successfully reached the end of the service validations scripts." From fdb861defdc0f90f52b36ed56be888873fd78fb6 Mon Sep 17 00:00:00 2001 From: Edaena Salinas Date: Thu, 19 Mar 2020 13:06:02 -0700 Subject: [PATCH 10/10] Commenting out rings test --- tests/validations.sh | 66 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/validations.sh b/tests/validations.sh index 8b53b643e..4da1d0ed6 100644 --- a/tests/validations.sh +++ b/tests/validations.sh @@ -350,50 +350,50 @@ pipeline1id=$(az pipelines build list --definition-ids $pipeline_id --organizati ################################## # App Mono Repo create ring ################################## -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 400 15 2 -echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." -approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" +# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 400 15 2 +# echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." +# approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" -# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 400 15 4 -ring_name=qa-ring +# # Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish +# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 400 15 4 +# ring_name=qa-ring -cd $TEST_WORKSPACE -cd $mono_repo_dir +# cd $TEST_WORKSPACE +# cd $mono_repo_dir -echo "Create ring" -git checkout master -git pull origin master -spk ring create $ring_name -git add -A -git commit -m "Adding test ring" -git push -u origin --all +# echo "Create ring" +# git checkout master +# git pull origin master +# spk ring create $ring_name +# git add -A +# git commit -m "Adding test ring" +# git push -u origin --all -# Wait for the lifecycle pipeline to finish and approve the pull request -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 300 15 3 -echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." -approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" +# # Wait for the lifecycle pipeline to finish and approve the pull request +# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name 300 15 3 +# echo "Finding pull request that $lifecycle_pipeline_name pipeline created..." +# approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "Reconciling HLD" -# Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish -verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 5 +# # Wait for fabrikam-hld-to-fabrikam-manifests pipeline to finish +# verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 5 -# Verify the file was added in the manifest repository -cd $TEST_WORKSPACE -cd $manifests_dir +# # Verify the file was added in the manifest repository +# cd $TEST_WORKSPACE +# cd $manifests_dir -git pull origin master +# git pull origin master -ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/$ring_name" -if [ ! -d "$ring_dir" ]; then - echo "Directory '$ring_dir' does not exist" - exit 1 -fi +# ring_dir="prod/$mono_repo_dir/fabrikam-acme-frontend/$ring_name" +# if [ ! -d "$ring_dir" ]; then +# echo "Directory '$ring_dir' does not exist" +# exit 1 +# fi -echo "Validating ingress routes" +# echo "Validating ingress routes" -validate_file "$ring_dir/static.yaml" "'PathPrefix(\`/fabrikam-acme-frontend\`) && Headers(\`Ring\`, \`qa-ring\`)'" +# validate_file "$ring_dir/static.yaml" "'PathPrefix(\`/fabrikam-acme-frontend\`) && Headers(\`Ring\`, \`qa-ring\`)'" -echo "Successfully created a ring." +# echo "Successfully created a ring." # -------------------------------- # Push the ring branch