feat(e2e-test): Add e2e-tests for zfs-localpv (#298)

Signed-off-by: w3aman <aman.gupta@mayadata.io>
This commit is contained in:
Aman Gupta 2021-06-09 21:21:39 +05:30 committed by GitHub
parent 53f872fcf1
commit 4e73638b5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
137 changed files with 8745 additions and 0 deletions

View file

@ -0,0 +1,80 @@
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: app-namespace
labels:
name: app-namespace
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: app-namespace
namespace: app-namespace
labels:
name: app-namespace
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: app-namespace
labels:
name: app-namespace
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: app-namespace
subjects:
- kind: ServiceAccount
name: app-namespace
namespace: app-namespace
---
apiVersion: batch/v1
kind: Job
metadata:
generateName: busybox-liveness-
namespace: app-namespace
spec:
template:
metadata:
name: busybox-liveness
namespace: app-namespace
labels:
liveness: busybox-liveness
# label used for mass-liveness check upon infra-chaos
infra-aid: liveness
spec:
serviceAccountName: app-namespace
restartPolicy: Never
containers:
- name: busybox-liveness
image: openebs/busybox-client
imagePullPolicy: Always
env:
- name: LIVENESS_TIMEOUT_SECONDS
value: "liveness-timeout-seconds"
# number of retries when livenss-fails
- name: LIVENESS_RETRY_COUNT
value: "liveness-retry-count"
# Namespace in which busybox is running
- name: NAMESPACE
value: app-namespace
- name: POD_NAME
value: pod-name
command: ["/bin/bash"]
args: ["-c", "./liveness.sh; exit 0"]

View file

@ -0,0 +1,57 @@
---
apiVersion: batch/v1
kind: Job
metadata:
generateName: busybox-liveness-
namespace: e2e
spec:
activeDeadlineSeconds: 5400
template:
metadata:
name: busybox-liveness
namespace: e2e
labels:
liveness: busybox-liveness
# label used for mass-liveness check upon infra-chaos
infra-aid: liveness
spec:
serviceAccountName: e2e
restartPolicy: Never
containers:
- name: ansibletest
image: openebs/zfs-localpv-e2e:ci
imagePullPolicy: IfNotPresent
env:
- name: ANSIBLE_STDOUT_CALLBACK
value: default
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: LIVENESS_TIMEOUT_SECONDS
value: "10"
# number of retries when livenss-fails
- name: LIVENESS_RETRY_COUNT
value: "5"
# This is the namespace where busybox application is running
- name: APP_NAMESPACE
value: 'busybox'
# Application label for busybox in `key=value` format
- name: APP_LABEL
value: 'app=busybox'
# Use: `provision` to apply the liveness-probe checks for busybox application
# Use: `deprovision` to deprovision the liveness-probe
- name: ACTION
value: 'provision'
command: ["/bin/bash"]
args: ["-c", "ansible-playbook ./e2e-tests/apps/busybox/liveness/test.yml -i /etc/ansible/hosts -v; exit 0"]

View file

@ -0,0 +1,96 @@
---
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- test_vars.yml
tasks:
- block:
- block:
- name: Record test instance/run ID
set_fact:
run_id: "{{ lookup('env','RUN_ID') }}"
- name: Construct testname appended with runID
set_fact:
test_name: "{{ test_name }}-{{ run_id }}"
when: lookup('env','RUN_ID')
## RECORD START-OF-TEST IN e2e RESULT CR
- include_tasks: /e2e-tests/hack/update_e2e_result_resource.yml
vars:
status: 'SOT'
- block:
- name: Getting the application pod name
shell: kubectl get pod -n {{ namespace }} -l {{ app_label }} -o jsonpath={.items[0].metadata.name}
register: pod_name
- name: Replacing the placeholder for pod-name
replace:
path: "{{ busybox_liveness }}"
regexp: "pod-name"
replace: "{{ pod_name.stdout }}"
- name: Replacing the placeholder for namespace
replace:
path: "{{ busybox_liveness }}"
regexp: "app-namespace"
replace: "{{ namespace }}"
- name: Replacing the placeholder for liveness-retry-count
replace:
path: "{{ busybox_liveness }}"
regexp: "liveness-retry-count"
replace: "{{ liveness_retry }}"
- name: Replacing the placeholder for liveness-timeout
replace:
path: "{{ busybox_liveness }}"
regexp: "liveness-timeout-seconds"
replace: "{{ liveness_timeout }}"
- name: Creating busybox-liveness job
shell: kubectl create -f {{ busybox_liveness }}
- name: Verifying whether liveness pod is started successfully
shell: kubectl get pod -n {{ namespace }} -l liveness=busybox-liveness -o jsonpath={.items[0].status.phase}
register: pod_status
until: "'Running' in pod_status.stdout"
delay: 5
retries: 40
- set_fact:
flag: "Pass"
when: "'deprovision' not in action"
- block:
- name: Getting the busybox liveness job
shell: kubectl get job -l liveness=busybox-liveness -n {{ namespace }} -o jsonpath='{.items[0].metadata.name}'
register: liveness_job
- name: Deleting busybox liveness job
shell: kubectl delete job {{ liveness_job.stdout }} -n {{ namespace }}
- set_fact:
flag: "Pass"
when: "'deprovision' is in action"
rescue:
- set_fact:
flag: "Fail"
always:
## RECORD END-OF-TEST IN e2e RESULT CR
- include_tasks: /e2e-tests/hack/update_e2e_result_resource.yml
vars:
status: 'EOT'

View file

@ -0,0 +1,15 @@
test_name: busybox-liveness
namespace: "{{ lookup('env','APP_NAMESPACE') }}"
app_label: "{{ lookup('env','APP_LABEL') }}"
busybox_liveness: busybox_liveness.yml
liveness_retry: "{{ lookup('env','LIVENESS_RETRY_COUNT') }}"
liveness_timeout: "{{ lookup('env','LIVENESS_TIMEOUT_SECONDS') }}"
liveness_log: "liveness-running"
action: "{{ lookup('env','ACTION') }}"