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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"open": "^6.4.0",
"shelljs": "^0.8.3",
"simple-git": "^1.126.0",
"spektate": "^1.0.2",
"spektate": "^1.0.4",
"ssh-url": "^0.1.5",
"uuid": "^3.3.3",
"winston": "^3.2.1"
Expand Down
1 change: 0 additions & 1 deletion src/commands/deployment/dashboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */

jest.mock("open");
import open from "open";
jest.mock("../../config");
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fileutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ const manifestGenerationPipelineYaml = (): string => {
`get_spk_version`,
`download_spk`,
`message="$(Build.SourceVersionMessage)"`,
`if [[ $message == *"Merged PR"* ]]; then`,
`if [[ $message == *"Merge"* ]]; then`,
`pr_id=$(echo $message | grep -oE '[0-9]+' | head -1 | sed -e 's/^0\\+//')`,
`./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p3 $(Build.BuildId) --hld-commit-id $commitId --pr $pr_id`,
`else`,
Expand Down
2 changes: 1 addition & 1 deletion src/test/mockFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export const createTestHldAzurePipelinesYaml = (
`get_spk_version`,
`download_spk`,
`message="$(Build.SourceVersionMessage)"`,
`if [[ $message == *"Merged PR"* ]]; then`,
`if [[ $message == *"Merge"* ]]; then`,
`pr_id=$(echo $message | grep -oE '[0-9]+' | head -1 | sed -e 's/^0\\+//')`,
`./spk/spk deployment create -n $(INTROSPECTION_ACCOUNT_NAME) -k $(INTROSPECTION_ACCOUNT_KEY) -t $(INTROSPECTION_TABLE_NAME) -p $(INTROSPECTION_PARTITION_KEY) --p3 $(Build.BuildId) --hld-commit-id $commitId --pr $pr_id`,
`else`,
Expand Down
3 changes: 3 additions & 0 deletions tests/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ function verify_pipeline_with_poll () {

# We expect only 1 build right now
build_count=$(tr '"\""' '"\\"' <<< "$pipeline_builds" | jq '. | length')
if [[ -z "$expected_build_count" ]]; then
expected_build_count=1
fi
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
Expand Down
38 changes: 29 additions & 9 deletions tests/validations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ echo "hld_repo_url $hld_repo_url"
echo "manifest_repo_url $manifest_repo_url"
spk hld install-manifest-pipeline --org-name $AZDO_ORG -d $AZDO_PROJECT --personal-access-token $ACCESS_TOKEN_SECRET -u https://$hld_repo_url -m https://$manifest_repo_url >> $TEST_WORKSPACE/log.txt

##################################
# Temporary: Add a variable group to hld to manifest pipeline manually for testing introspection
# Will no longer be needed once install-manifest-pipeline supports adding a VG
##################################
cd $hld_dir
echo -e "variables:\n - group: $vg_name" | cat - manifest-generation.yaml > temp && mv temp manifest-generation.yaml
git add .
git commit -m "Adding variable group $vg_name to pipeline"
git push origin master
echo "Successfully added variable group $vg_name to hld pipeline"

# Verify hld to manifest pipeline was created
pipeline_created=$(az pipelines show --name $hld_to_manifest_pipeline_name --org $AZDO_ORG_URL --p $AZDO_PROJECT)

Expand Down Expand Up @@ -409,32 +420,41 @@ echo "Successfully reached the end of the service validations scripts."
# # SPK Introspection Validation START
# ##################################

pipeline1id=$(az pipelines build list --definition-ids $pipeline_id --organization $AZDO_ORG_URL --project $AZDO_PROJECT | jq '.[0].id')

# Verify hld to manifest pipeline run was successful, to verify the full end-end capture of
# introspection data
verify_pipeline_with_poll $AZDO_ORG_URL $AZDO_PROJECT $hld_to_manifest_pipeline_name 300 15 3

cd $TEST_WORKSPACE
cd ..
if [ -d "tests" ]; then
cd tests
fi
export sa_access_key=$(echo "$sa_access_key" | tr -d '"')
spk init -f ./spk-config-test.yaml
export output=$(spk deployment get -O json > file.json )
spk deployment get --build-id $pipeline1id
export output=$(spk deployment get --build-id $pipeline1id -O json > file.json )
length=$(cat file.json | jq 'length')
if (( length > 0 )); then
echo "$length deployments were returned by spk deployment get"
echo "$length deployment(s) were returned by spk deployment get"
else
echo "Error: Empty JSON was returned from spk deployment get"
exit 1
fi

# Compare $pipeline_id with the data returned by get.
# Parse the response to verify data from get command
srcPipelineId=$(cat file.json | jq '.[].srcToDockerBuild.id')
acrPipelineId=$(cat file.json | jq '.[].dockerToHldReleaseStage.id')
hldPipelineId=$(cat file.json | jq '.[].hldToManifestBuild.id')
prId=$(cat file.json | jq '.[].pr')

listofIds=$(cat file.json | jq '.[].srcToDockerBuild.id')

if [[ $listofIds == *"$pipeline1id"* ]]; then
echo "Pipeline Id $pipeline1id exists. Verified that data exists in storage and could be retrieved."
if [[ "$srcPipelineId" == "$pipeline1id" && "$acrPipelineId" == "$srcPipelineId" && "$hldPipelineId" != "" && "$prId" != "" && "$prId" != "null" ]]; then
echo "Verified that srcPipeline:$srcPipelineId acrPipelineId:$acrPipelineId hldPipelineId:$hldPipelineId pullrequest:$prId are all linked together correctly."
else
echo "Error: Pipeline Id $pipeline1id is not found in data returned from get. "
echo "Error: Data returned from get command does not match expected output:"
cat file.json
exit 1
fi
# --------------------------------

echo "Successfully reached the end of spk deployment get tests."
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6674,10 +6674,10 @@ spdx-license-ids@^3.0.0:
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz#3694b5804567a458d3c8045842a6358632f62654"
integrity sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==

spektate@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/spektate/-/spektate-1.0.3.tgz#83be22d3b27b780082b37dee19024d6fba14b296"
integrity sha512-bv8ZJhtcOZrUQaqXOkpxi72ZefKc7xm6sR+CMchBOUhpx4VmROMHB81VvepYP4TOyPzL1r2WqNKm9oaYn1m78g==
spektate@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/spektate/-/spektate-1.0.4.tgz#672e6d7cdf282adadddaf455d1ae41513d522637"
integrity sha512-Yd31la4eMPg9lX9RztoATeu7fzONunvpPVncbO9jdhoJPkvdrT9jcctFjf1j1rb5/us8rxA0F1Ufju1u3UIv0A==
dependencies:
axios "^0.19.0"
azure-storage "^2.10.3"
Expand Down