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,42 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-busybox
labels:
lkey: lvalue
spec:
selector:
matchLabels:
lkey: lvalue
template:
metadata:
labels:
lkey: lvalue
spec:
containers:
- name: app-busybox
imagePullPolicy: IfNotPresent
image: gcr.io/google-containers/busybox
command: ["/bin/sh"]
args: ["-c", "while true; do sleep 10;done"]
env:
volumeMounts:
- name: data-vol
mountPath: /busybox
volumes:
- name: data-vol
persistentVolumeClaim:
claimName: testclaim
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: testclaim
spec:
storageClassName: testclass
accessModes:
- ReadWriteOnce
resources:
requests:
storage: teststorage

View file

@ -0,0 +1,36 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: app-busybox
labels:
lkey: lvalue
spec:
selector:
matchLabels:
lkey: lvalue
template:
metadata:
labels:
lkey: lvalue
spec:
containers:
- name: app-busybox
image: gcr.io/google-containers/busybox
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- 'date > /busybox/date.txt; sync; sleep 5; sync; tail -f /dev/null;'
volumeMounts:
- name: testclaim
mountPath: /busybox
volumeClaimTemplates:
- metadata:
name: testclaim
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: testclass
resources:
requests:
storage: teststorage

View file

@ -0,0 +1,55 @@
---
apiVersion: batch/v1
kind: Job
metadata:
generateName: busybox-deploy-
namespace: e2e
spec:
template:
metadata:
name: busybox-deploy
labels:
app: busybox
spec:
serviceAccountName: e2e
restartPolicy: Never
containers:
- name: ansibletest
image: openebs/zfs-localpv-e2e:ci
imagePullPolicy: IfNotPresent
env:
- name: ANSIBLE_STDOUT_CALLBACK
value: default
# Name of the storage class to use for volume provisioning
- name: STORAGE_CLASS
value: 'zfspv-sc'
# This is the namespace where busybox application will be deployed
- name: APP_NAMESPACE
value: 'busybox'
# Application label for busybox deployment/statefulset in `key=value` format
- name: APP_LABEL
value: 'app=busybox'
# Application PVC name
- name: APP_PVC
value: 'busybox-pvc'
# Persistent volume storage capacity (for e.g, 5Gi)
- name: PV_CAPACITY
value: '5Gi'
# Use: `statefuleset` to deploy busybox application as statefulset
# Use: `deployment` to deploy busybox application as deployment
- name: DEPLOY_TYPE
value: 'deployment'
# Use: `provision` to deploy the application
# Use: `deprovision` to deprovision the application
- name: ACTION
value: 'provision'
command: ["/bin/bash"]
args: ["-c", "ansible-playbook ./e2e-tests/apps/busybox/deployers/test.yml -i /etc/ansible/hosts -v; exit 0"]

View file

@ -0,0 +1,78 @@
---
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- test_vars.yml
tasks:
- block:
## Generating the testname for deployment
- include_tasks: /e2e-tests/hack/create_testname.yml
## RECORD START-OF-TEST IN e2e RESULT CR
- include_tasks: /e2e-tests/hack/update_e2e_result_resource.yml
vars:
status: 'SOT'
- block:
- block:
## Prerequisite tasks such as, namespace creation and replacing placeholder
## with test specific values, before deploying application
- include_tasks: /e2e-tests/utils/k8s/pre_create_app_deploy.yml
vars:
application: "{{ application_statefulset }}"
## Deploying the application
- include_tasks: /e2e-tests/utils/k8s/deploy_single_app.yml
vars:
application: "{{ application_statefulset }}"
when: "'deprovision' not in action"
- name: Deprovisioning the Application
include_tasks: /e2e-tests/utils/k8s/deprovision_statefulset.yml
vars:
app_deployer: "{{ application_statefulset }}"
when: "'deprovision' is in action"
when: lookup('env','DEPLOY_TYPE') == 'statefulset'
- block:
- block:
## Prerequisite tasks such as, namespace creation and replacing placeholder
## with test specific values, before deploying application
- include_tasks: /e2e-tests/utils/k8s/pre_create_app_deploy.yml
vars:
application: "{{ application_deployment }}"
## Deploying the application
- include_tasks: /e2e-tests/utils/k8s/deploy_single_app.yml
vars:
application: "{{ application_deployment }}"
when: "'deprovision' not in action"
- name: Deprovisioning the Application
include_tasks: /e2e-tests/utils/k8s/deprovision_deployment.yml
vars:
app_deployer: "{{ application_deployment }}"
when: "'deprovision' is in action"
when: lookup('env','DEPLOY_TYPE') == 'deployment'
- set_fact:
flag: "Pass"
rescue:
- name: Setting fail flag
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,19 @@
test_name: "busybox-{{ action }}-{{ app_ns }}"
application_name: "busybox"
application_statefulset: busybox_statefulset.yml
application_deployment: busybox_deployment.yml
storage_class: "{{ lookup('env','STORAGE_CLASS') }}"
app_ns: "{{ lookup('env','APP_NAMESPACE') }}"
app_label: "{{ lookup('env','APP_LABEL') }}"
app_pvc: "{{ lookup('env','APP_PVC') }}"
deploy_type: "{{ lookup('env','DEPLOY_TYPE') }}"
action: "{{ lookup('env','ACTION') }}"