Commit bebbcf34 authored by DJ Mountney's avatar DJ Mountney

Add a helm test for the unicorn chart.

parent 56cce6b1
Pipeline #25423930 failed with stages
in 16 minutes and 37 seconds
......@@ -300,6 +300,30 @@ qa:
refs:
- branches
review_helm_test:
stage: qa
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://gitlab-$CI_ENVIRONMENT_SLUG.$AUTO_DEVOPS_DOMAIN
script:
- export TILLER_NAMESPACE=$KUBE_NAMESPACE
- helm test "$CI_ENVIRONMENT_SLUG"
except:
refs:
- master
production_helm_test:
stage: qa
environment:
name: production
url: https://gitlab.$AUTO_DEVOPS_DOMAIN
script:
- export TILLER_NAMESPACE=$KUBE_NAMESPACE
- helm test "$CI_ENVIRONMENT_SLUG"
only:
refs:
- master
debug_review:
stage: qa
when: on_failure
......@@ -523,7 +547,7 @@ changelog_manager:
}
function cleanup() {
kubectl -n "$KUBE_NAMESPACE" get ingress,svc,pdb,hpa,deploy,statefulset,job,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa 2>&1 \
kubectl -n "$KUBE_NAMESPACE" get ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa 2>&1 \
| grep "$CI_ENVIRONMENT_SLUG" \
| awk '{print $1}' \
| xargs kubectl -n "$KUBE_NAMESPACE" delete \
......
{{- if .Values.enabled -}}
apiVersion: v1
kind: Pod
metadata:
name: {{ template "fullname" . }}-test-runner-{{ randAlphaNum 5 | lower }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: test-runner
image: {{ .Values.image.repository }}:{{ coalesce .Values.image.tag (include "gitlab.versionTag" . ) }}
command: ['sh', '/tests/test_login']
volumeMounts:
- name: tests
mountPath: '/tests'
- name: root-password
readOnly: true
mountPath: /initial_root_password
subPath: initial_root_password
volumes:
- name: tests
configMap:
name: {{ template "fullname" . }}-tests
- name: root-password
secret:
secretName: {{ template "gitlab.migrations.initialRootPassword.secret" . }}
items:
- key: {{ template "gitlab.migrations.initialRootPassword.key" . }}
path: initial_root_password
restartPolicy: Never
{{- end }}
{{- if .Values.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fullname" . }}-tests
data:
test_login: |
set -e
echo 'Start Test'
endpoint="{{ template "gitlab.gitlab.url" . }}"
cookie_read="-c /tmp/test_login.cookie"
cookie_readwrite="$cookie_read -b /tmp/test_login.cookie"
signin_url="$endpoint/users/sign_in"
echo "Login to create a session: $signin_url"
csrf=$(curl $signin_url --fail -s $cookie_read | grep -Po '<meta.*name="csrf-token".*content="\K[a-zA-Z0-9\+=\-\/]*')
curl --fail -X POST $signin_url -s $cookie_readwrite -F "authenticity_token=$csrf" -F 'user[login]=root' -F "user[password]=$(cat /initial_root_password)"
profile_url="$endpoint/profile"
echo "Confirm session valid: $profile_url"
profile_status=$(curl -s -o /tmp/profile_output -w "%{http_code}" $cookie_readwrite $profile_url)
if [ "$profile_status" != "200" ]; then
echo "Error: Session Invalid"
cat /tmp/profile_output
exit 1
fi
echo 'Test Passed'
exit 0
# Leave this here - This line denotes end of block to the parser.
{{- end }}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment