Browse Source

Add tests to Jenkins pipeline

master
Gyulai Dániel 4 years ago
parent
commit
739169de14
  1. 45
      Jenkinsfile
  2. 10
      ci/cleanup.sh
  3. 38
      ci/helm_test.sh
  4. 19
      ci/kube.config
  5. 13
      ci/tests/config.py
  6. 21
      ci/tests/test_auth.py
  7. 17
      ci/tests/test_case.py
  8. 9
      ci/tests/test_doc.py
  9. 21
      helm/covidok/templates/NOTES.txt
  10. 11
      helm/covidok/templates/_helpers.tpl
  11. 14
      helm/covidok/templates/deployment.yaml
  12. 21
      helm/covidok/values.yaml

45
Jenkinsfile

@ -27,6 +27,17 @@ spec:
mountPath: /var/run
- name: docker-local-certs
mountPath: /etc/docker/certs.d/docker.local
- name: python
image: docker.local/ci/python:latest
imagePullPolicy: Always
command: ["cat"]
- name: helm
image: docker.local/ci/helm:latest
imagePullPolicy: Always
env:
- name: KUBECONFIG
value: /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/kube.config
command: ["cat"]
''') {
node(POD_LABEL) {
@ -34,10 +45,40 @@ spec:
git url: 'https://gyulai.cloud/git/bme/covidok-backend.git',
credentialsId: '1b1c30a0-590d-41d4-b775-bdb90e837bc8'
container('docker') {
stage('Build and publish dev Docker image') {
sh 'docker build -f /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/CoviDok/Dockerfile.CI -t docker.local/bme/covidok:latest /home/jenkins/agent/workspace && docker push docker.local/bme/covidok'
stage('Build dev image') {
sh 'docker build -f /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/CoviDok/Dockerfile.CI -t docker.local/bme/covidok:dev /home/jenkins/agent/workspace'
}
stage('Push dev image')
sh 'docker push docker.local/bme/covidok:dev'
}
}
container('helm') {
stage('Helm lint'){
sh 'helm lint /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/helm/covidok'
}
stage('Install dev') {
sh '/home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/helm_test.sh'
}
}
container('python') {
stage('API test'){
sh 'python3 -m pytest /home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/tests'
}
}
container('docker') {
stage('Push tested image'){
sh 'docker tag docker.local/bme/covidok:dev docker.local/bme/covidok:latest'
sh 'docker push docker.local/bme/covidok:latest'
}
}
container('helm'){
post{
always {
sh '/home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/ci/cleanup.sh'
}
}
}
archiveArtifacts artifacts: '/home/jenkins/agent/workspace/gitea-bme_covidok-backend_master/covidok*tgz', followSymlinks: false, onlyIfSuccessful: true
}
}
}

10
ci/cleanup.sh

@ -0,0 +1,10 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -f "$DIR/namespace" ]
then
kubectl delete namespace `cat "$DIR/namespace"`
fi

38
ci/helm_test.sh

@ -0,0 +1,38 @@
#!/bin/bash
set -e
if [ ! -d "$1" ]
then
echo "Helm dir does not exist!"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
POSTFIX=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
NAMESPACE="covidok-ci-$POSTFIX"
HELM_PACKAGE="covid-$POSTFIX"
printf "$NAMESPACE" > "$DIR/namespace"
kubectl create namespace "$NAMESPACE"
helm install -f "$DIR/ci_values.yaml" -n "$NAMESPACE" "$HELM_PACKAGE" "$1"
i=0
while [ "$(kubectl get pod -n "$NAMESPACE" -l=app.kubernetes.io/name=covidok -o jsonpath='{.items[*].status.containerStatuses[0].ready}')" != "true" ]; do
echo "Covidok backend is not yet ready..."
if [ $i -gt 10 ]
then
echo "Timeout reached while waiting for backend to start"
exit 1
else
sleep 5
fi
done
echo "Covidok backend is up"
CLUSTERIP=$(kubectl get svc -n test1 -l=app.kubernetes.io/name=covidok -o jsonpath='{.items[*].spec.clusterIP}')
echo "ClusterIP of service is $CLUSTERIP, writing to file"
printf $CLUSTERIP > $DIR/tests/host.file

19
ci/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yenl2SHQxa0Y4NjloSUo5Q1dnQVNodzl4OVhTa3lnb3cwb2NUNmFKZm9JbHA3MDNLeGVuCms4QTdqWVVEeU40a2hQUzNVYUtIUjU2MFhHWXFBRndVYjd3Mk4wUFVneENJWlZRcEpJVlg4N2Zrby96TkZaU3UKRDlkMFpyWnRTdm4zZWhHTkw4MWkrclRRY3kwOENvNGZ5RmhPL0dydTdNTW00WS9YSmEzSHhpQVBGbUtYeEpMRwpUMTB2aVpkL1lZWFF6K0lHVnZPVnZmVHROaUVITERWWk9TU3pmVHA3bkZJNjJoQW0vQ1BSM2xLZWtyYz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
server: https://192.168.0.101:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJUEZUSDI2cTVDeDh3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TURBNE1UUXhPVFV5TURoYUZ3MHlNVEE0TVRReE9UVXlNVEZhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXhQSE5ieE9RUTFLZkZTSzcKbVJDOUlGMzFmaC9JVTI4Q1dvV2NmZWZ1dEgrV2VmVVpES2JkL2xGU3ZGUm1tQlY0S3lzc2oyUmNSV3VFd09LRgpLM05yRlFlQXRERVlMa0wvdzVDZmVCdGU3SkF1Qmp0Y2dnVW9hT3BQZENFSzlzWHhndjdmZmFHSnBoUHNkeVprCko5T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__file__)), "host.file")
def load_host():
with open(host_file) as f:
return f.read().strip()
def url_base():
return "http://" + load_host()

21
tests/test_auth.py → ci/tests/test_auth.py

@ -1,11 +1,10 @@
import requests
import json
url_base = "http://localhost:56030"
from config import url_base
def test_auth_basic():
body = {"Email": "a", "Password": "a"}
response = requests.post(url_base + "/api/Auth/login", json=body)
response = requests.post(url_base() + "/api/Auth/login", json=body)
data = json.loads(response.text)
assert data["firstName"] == "Sajt"
assert data["lastName"] == "Osperec"
@ -13,48 +12,48 @@ def test_auth_basic():
def test_auth_fail():
body = {"Email": "b", "Password": "b"}
response = requests.post(url_base + "/api/Auth/login", json=body)
response = requests.post(url_base() + "/api/Auth/login", json=body)
assert response.status_code == 401
def test_auth_register():
body = {"Email": "b", "FirstName": "a", "LastName": "a", "Password": "a", "Role": 0}
response = requests.post(url_base + "/api/Auth/register", json=body)
response = requests.post(url_base() + "/api/Auth/register", json=body)
data = json.loads(response.text)
assert data["status"] == 0
def test_auth_register_bad_pass():
body = {"Email": "b", "FirstName": "a", "LastName": "a", "Password": "1", "Role": 0}
response = requests.post(url_base + "/api/Auth/register", json=body)
response = requests.post(url_base() + "/api/Auth/register", json=body)
data = json.loads(response.text)
assert data["status"] == 1
assert data["body"]["reason"] == "Password does not meet complexity requirements!"
def test_auth_register_email_taken():
body = {"Email": "a", "FirstName": "a", "LastName": "a", "Password": "a", "Role": 0}
response = requests.post(url_base + "/api/Auth/register", json=body)
response = requests.post(url_base() + "/api/Auth/register", json=body)
data = json.loads(response.text)
assert data["status"] == 1
assert data["body"]["reason"] == "a is already registered!"
def test_auth_child():
body = {"SessionId": "id", "FirstName": "a", "LastName": "a", "BirthDate": "x", "SocSecNum": "2"}
response = requests.post(url_base + "/api/Auth/child", json=body)
response = requests.post(url_base() + "/api/Auth/child", json=body)
data = json.loads(response.text)
assert data["status"] == 0
assert "childID" in data["body"]
def test_auth_child_ssn_taken():
body = {"SessionId": "id", "FirstName": "a", "LastName": "a", "BirthDate": "x", "SocSecNum": "111111111"}
response = requests.post(url_base + "/api/Auth/child", json=body)
response = requests.post(url_base() + "/api/Auth/child", json=body)
data = json.loads(response.text)
assert data["status"] == 1
assert "SSN" in data["body"]["reason"]
def test_auth_child_unauthorized():
body = {"SessionId": "a", "FirstName": "a", "LastName": "a", "BirthDate": "x", "SocSecNum": "2"}
response = requests.post(url_base + "/api/Auth/child", json=body)
response = requests.post(url_base() + "/api/Auth/child", json=body)
assert response.status_code == 401
body = {"Email": "a", "FirstName": "a", "LastName": "a", "Password": "1", "Role": 0}
response = requests.post(url_base + "/api/Auth/register", json=body)
response = requests.post(url_base() + "/api/Auth/register", json=body)
print(response.text)

17
tests/test_case.py → ci/tests/test_case.py

@ -1,12 +1,11 @@
import requests
import json
url_base = "http://localhost:56030"
from config import url_base
def test_case_basic():
case_id = "1f4g5"
body = {"SessionID": "a"}
response = requests.post(url_base + "/api/Case/"+case_id, json=body)
response = requests.post(url_base() + "/api/Case/"+case_id, json=body)
data = json.loads(response.text)
print(data)
assert data["id"] == case_id
@ -14,37 +13,37 @@ def test_case_basic():
def test_case_unauthorized():
case_id = "1f4g5"
body = {"SessionID": "b"}
response = requests.post(url_base + "/api/Case/"+case_id, json=body)
response = requests.post(url_base() + "/api/Case/"+case_id, json=body)
assert response.status_code == 401
def test_case_update():
case_id = "5f6h4"
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "a"}
response = requests.put(url_base + "/api/Case/"+case_id+"/update", json=body)
response = requests.put(url_base() + "/api/Case/"+case_id+"/update", json=body)
assert response.status_code == 200
def test_case_update_unauthorized():
case_id = "5f6h4"
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "b"}
response = requests.put(url_base + "/api/Case/"+case_id+"/update", json=body)
response = requests.put(url_base() + "/api/Case/"+case_id+"/update", json=body)
assert response.status_code == 401
def test_case_close():
case_id = "5f6h4"
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "a"}
response = requests.put(url_base + "/api/Case/"+case_id+"/close", json=body)
response = requests.put(url_base() + "/api/Case/"+case_id+"/close", json=body)
assert response.status_code == 200
def test_case_close_unauthorized():
case_id = "5f6h4"
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "b"}
response = requests.put(url_base + "/api/Case/"+case_id+"/close", json=body)
response = requests.put(url_base() + "/api/Case/"+case_id+"/close", json=body)
assert response.status_code == 401
def test_case_filter():
parent_id = "34g5g53"
body = {"SessionID": "a", "Filters": {"ParentID": parent_id}}
response = requests.post(url_base + "/api/Case/filter", json=body)
response = requests.post(url_base() + "/api/Case/filter", json=body)
data = json.loads(response.text)
for i in data["cases"]:
assert i["parentID"] == parent_id

9
tests/test_doc.py → ci/tests/test_doc.py

@ -1,10 +1,9 @@
import requests
import json
url_base = "http://localhost:56030"
from config import url_base
def test_doc_get():
response = requests.get(url_base + "/api/Doc")
response = requests.get(url_base() + "/api/Doc")
data = json.loads(response.text)
assert data["status"] == 0
for val in data["body"].values():
@ -12,7 +11,7 @@ def test_doc_get():
def test_doc_assistants():
doc_id = "a23f"
response = requests.get(url_base + "/api/Doc/" + doc_id + "/assistants")
response = requests.get(url_base() + "/api/Doc/" + doc_id + "/assistants")
data = json.loads(response.text)
assert data["status"] == 0
for key, val in data["body"].items():
@ -22,7 +21,7 @@ def test_doc_assistants():
def test_doc_children():
doc_id = "a23f"
response = requests.get(url_base + "/api/Doc/" + doc_id + "/children")
response = requests.get(url_base() + "/api/Doc/" + doc_id + "/children")
data = json.loads(response.text)
assert data["status"] == 0
for key, val in data["body"].items():

21
helm/covidok/templates/NOTES.txt

@ -1,21 +0,0 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "covidok.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "covidok.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "covidok.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "covidok.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}

11
helm/covidok/templates/_helpers.tpl

@ -49,14 +49,3 @@ Selector labels
app.kubernetes.io/name: {{ include "covidok.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "covidok.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "covidok.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

14
helm/covidok/templates/deployment.yaml

@ -24,22 +24,12 @@ spec:
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{ .Values.images.covidok.name }}:{{ .Values.images.covidok.tag }}"
imagePullPolicy: {{ .Values.images.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}

21
helm/covidok/values.yaml

@ -2,25 +2,20 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
repository: nginx
pullPolicy: IfNotPresent
images:
covidok:
name: docker.local/bme/covidok
tag: latest
mysql:
name: mysql
tag: 8.0
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
service:

Loading…
Cancel
Save