Add test for pre-defined image tags

This commit adds a test to verify that pre-defined image tags are
preserved during development pipeline runs. The deployment-flow configmap
is checked which would contain the original image tag and the image.json
is also checked which would contain the image tag that is actually used.
The test checks if the configmap tag matches the image.json tag, which it
should. The test skips if there is no pre-defined tag.

Change-Id: Ic7661dfc23bc92a460b3b0d5328a6f85b42a6ed4
This commit is contained in:
Bartra, Rick (rb560u) 2021-03-31 22:01:14 -04:00 committed by Rick Bartra
parent 460a817d57
commit ad8ab089a0
3 changed files with 28 additions and 3 deletions

View File

@ -26,6 +26,9 @@ spec:
image: {{ $.Values.tasks.functional.functionalTestImage }}
script: |
/jarvis/functional_test.sh
volumeMounts:
- mountPath: $(workspaces.development_pipeline_data.path)/config
name: kubeconfig
volumes:
- name: helm-publish-creds
secret:

View File

@ -1,4 +1,26 @@
#Test pre-defined image tag
- name: test pre-defined image tag
shell: |
echo "Checking if pre-defined image tag is preserved during development pipeline run" ;
# The original image tag is what is in the deployment-flow configmap
ORIGINAL_TAG=$(kubectl get cm deployment-flow -o json | jq -r .'data'.'"image.json"' | jq -r .'[0]'.'tag')
# The actual image tag is the tag that is assigned during the development pipeline run and is ultimately
# what is used to tag the image in Harbor
ACTUAL_TAG=$(helm --kubeconfig /workspace/development_pipeline_data/config/kubeconfig ls -n mongodb -o json | jq -r .[0].app_version)
if [ "${ORIGINAL_TAG}" == "null" ] || [ "${ORIGINAL_TAG}" == "" ]; then
echo "Skipping as there is no pre-defined tag that should be used on the image"
else
if [ "${ACTUAL_TAG}" == "${ORIGINAL_TAG}" ]; then
echo "Actual tag: ${ACTUAL_TAG} matches expected tag: ${ORIGINAL_TAG}"
else
echo "Actual tag: ${ACTUAL_TAG} does NOT match expected tag: ${ORIGINAL_TAG}"
exit 1
fi
fi
args:
executable: /bin/bash
#Test Deployed CNF
- name: Chart has no Helm Tests, echo for now
shell: echo "There are no helm tests yet"
# shell: echo 'helm test --kubeconfig="{{ cluster_kubeconfig_path }}/kubeconfig" "{{ name }}"'
# shell: echo 'helm test --kubeconfig="{{ cluster_kubeconfig_path }}/kubeconfig" "{{ name }}"'

View File

@ -53,5 +53,5 @@
when: stage == "test"
block:
#Test Deployed CNF
- name: Chart currently has no Helm Tests, echo for now
shell: echo "There are no helm tests yet"
- name: Run tests
include_tasks: ./roles/functional/tasks/functional-test.yaml