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,52 @@
## About this experiment
This experiment verifies that zvolume properties are same as set via the stoarge-class.
## Supported platforms:
K8s : 1.18+
OS : Ubuntu, CentOS
ZFS : 0.7, 0.8
## Entry-Criteria
- K8s cluster should be in healthy state including all desired nodes in ready state.
- zfs-controller and node-agent daemonset pods should be in running state.
## Steps performed
- Get the zvolume name and the storage class name by which volume was provisioned.
- After that following properties are verified to be same from zvol properties as well as from storage class.
1. File-system type
2. Compression
3. Dedup
4. Recordsize / volblocksize
## How to run
- This experiment accepts the parameters in form of kubernetes job environmental variables.
- For running this experiment of zv properties verify, clone openens/zfs-localpv[https://github.com/openebs/zfs-localpv] repo and then first apply rbac and crds for e2e-framework.
```
kubectl apply -f zfs-localpv/e2e-tests/hack/rbac.yaml
kubectl apply -f zfs-localpv/e2e-tests/hack/crds.yaml
```
then update the needed test specific values in run_e2e_test.yml file and create the kubernetes job.
```
kubectl create -f run_e2e_test.yml
```
All the env variables description is provided with the comments in the same file.
After creating kubernetes job, when the jobs pod is instantiated, we can see the logs of that pod which is executing the test-case.
```
kubectl get pods -n e2e
kubectl logs -f <zv-properties-verify-xxxxx-xxxxx> -n e2e
```
To get the test-case result, get the corresponding e2e custom-resource `e2eresult` (short name: e2er ) and check its phase (Running or Completed) and result (Pass or Fail).
```
kubectl get e2er
kubectl get e2er zv-properties-verify -n e2e --no-headers -o custom-columns=:.spec.testStatus.phase
kubectl get e2er zv-properties-verify -n e2e --no-headers -o custom-columns=:.spec.testStatus.result
```

View file

@ -0,0 +1,36 @@
apiVersion: batch/v1
kind: Job
metadata:
generateName: zv-properties-verify-
namespace: e2e
spec:
template:
metadata:
labels:
test: zv-properties-verify
spec:
serviceAccountName: e2e
restartPolicy: Never
containers:
- name: ansibletest
image: openebs/zfs-localpv-e2e:ci
imagePullPolicy: IfNotPresent
env:
- name: ANSIBLE_STDOUT_CALLBACK
value: default
## Namespace in which application is deployed
- name: APP_NAMESPACE
value: ''
## PersistentVolumeClaim Name for the application
- name: APP_PVC
value: ''
# This is the namespace where the zfs driver created all its resources.
# By default it is in openebs namespace.
- name: ZFS_OPERATOR_NAMESPACE
value: 'openebs'
command: ["/bin/bash"]
args: ["-c", "ansible-playbook ./e2e-tests/experiments/functional/zv-properties-verify/test.yml -i /etc/ansible/hosts -vv; exit 0"]

View file

@ -0,0 +1,152 @@
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- test_vars.yml
tasks:
- block:
## Generating the testname for zfs volume properties verify test
- include_tasks: /e2e-tests/hack/create_testname.yml
## Record SOT (start of test) in e2e result e2e-cr (e2e-custom-resource)
- include_tasks: /e2e-tests/hack/update_e2e_result_resource.yml
vars:
status: 'SOT'
- block:
- name: Get the zvolume name
shell: >
kubectl get pvc {{ pvc_name }} -n {{ app_ns }} --no-headers
-o custom-columns=:.spec.volumeName
args:
executable: /bin/bash
register: zvol_name
- name: Record the zvolume name
set_fact:
zv_name: "{{ zvol_name.stdout }}"
- name: Get the storage class name used to create volume
shell: >
kubectl get pvc {{ pvc_name }} -n {{ app_ns }} --no-headers
-o custom-columns=:.spec.storageClassName
args:
executable: /bin/bash
register: stg_class_name
- name: Record the storage class name
set_fact:
sc_name: "{{ stg_class_name.stdout }}"
- name: Get the value of compression parameter from the storage class
shell: >
kubectl get sc {{ sc_name }} --no-headers
-o custom-columns=:.parameters.compression
args:
executable: /bin/bash
register: compression_parameter
- name: Compare this value with the compression field in zvolume
shell: >
kubectl get zv {{ zv_name }} -n {{ zfs_operator_ns }} --no-headers
-o custom-columns=:.spec.compression
args:
executable: /bin/bash
register: result
failed_when: compression_parameter.stdout != result.stdout
- name: Get the value of dedup parameter from the storage class
shell: >
kubectl get sc {{ sc_name }} --no-headers
-o custom-columns=:.parameters.dedup
args:
executable: /bin/bash
register: dedup_parameter
- name: Compare this value with the dedup field in zvolume
shell: >
kubectl get zv {{ zv_name }} -n {{ zfs_operator_ns }} --no-headers
-o custom-columns=:.spec.dedup
args:
executable: /bin/bash
register: result
failed_when: dedup_parameter.stdout != result.stdout
- name: Get the file system type to be created on application mount from the storage class
shell: >
kubectl get sc {{ sc_name }} --no-headers
-o custom-columns=:.parameters.fstype
args:
executable: /bin/bash
register: fstype_parameter
- name: Compare this value with the fstype field in zvolume
shell: >
kubectl get zv {{ zv_name }} -n {{ zfs_operator_ns }} --no-headers
-o custom-columns=:.spec.fsType
args:
executable: /bin/bash
register: result
failed_when: fstype_parameter.stdout != result.stdout
- block:
- name: Get the value of recordsize from the storage class when fstype is zfs
shell: >
kubectl get sc {{ sc_name }} --no-headers
-o custom-columns=:.parameters.recordsize
args:
executable: /bin/bash
register: recordsize_parameter
- name: Compare this value with the recordsize field in zvolume
shell: >
kubectl get zv {{ zv_name }} -n {{ zfs_operator_ns }} --no-headers
-o custom-columns=:.spec.recordsize
args:
executable: /bin/bash
register: result
failed_when: recordsize_parameter.stdout != result.stdout
when: fstype_parameter.stdout == "zfs"
- block:
- name: Get the value of volblocksize from the storage class when fstype is xfs or ext
shell: >
kubectl get sc {{ sc_name }} --no-headers
-o custom-columns=:.parameters.volblocksize
args:
executable: /bin/bash
register: volblocksize_parameter
- name: Compare this value with the volblocksize field in the zvolume
shell: >
kubectl get zv {{ zv_name }} -n {{ zfs_operator_ns }} --no-headers
-o custom-columns=:.spec.volblocksize
args:
executable: /bin/bash
register: result
failed_when: volblocksize_parameter.stdout != result.stdout
when:
- fstype_parameter.stdout == "xfs" or fstype_parameter.stdout == "ext4" or
fstype_parameter.stdout == "ext3" or fstype_parameter.stdout == "ext2" or
fstype_parameter.stdout == "btrfs"
- set_fact:
flag: "Pass"
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,7 @@
test_name: zv-properties-verify
app_ns: "{{ lookup('env','APP_NAMESPACE') }}"
pvc_name: "{{ lookup('env','APP_PVC') }}"
zfs_operator_ns: "{{ lookup('env','ZFS_OPERATOR_NAMESPACE') }}"