-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e-test): Add e2e-test for lvm volume resize support
feat(e2e-test): Add e2e-test for lvm volume resize support
- Loading branch information
Showing
4 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
e2e-tests/experiments/functional/lvm-volume-resize/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## About this experiment | ||
|
||
This experiment verifies the volume resize feature of lvm-localpv. For resize the volume we just need to update the pvc yaml with desired size and apply it. We can directly edit the pvc by ```kubectl edit pvc <pvc_name> -n <namespace>``` command and update the spec.resources.requests.storage field with desired volume size. One thing need to be noted that volume resize can only be done from lower pvc size to higher pvc size. We can not resize the volume from higher pvc size to lower one, in-short volume shrink is not possible. lvm driver supports online volume expansion, so that for using the resized volume, application pod restart is not required. For resize, storage-class which will provision the pvc should have `allowVolumeExpansion: true` field. | ||
|
||
for e.g. | ||
``` | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: openebs-lvmsc | ||
allowVolumeExpansion: true | ||
parameters: | ||
volgroup: "lvmvg" | ||
provisioner: local.csi.openebs.io | ||
``` | ||
|
||
## Supported platforms: | ||
|
||
K8S : 1.17+ | ||
|
||
OS : Ubuntu | ||
|
||
LVM version : LVM 2 | ||
|
||
## Entry-criteria | ||
|
||
- K8s cluster should be in healthy state including all the nodes in ready state. | ||
- lvm-controller and csi node-agent daemonset pods should be in running state. | ||
- storage class with `allowVolumeExpansion: true` enable should be present. | ||
- Application should be deployed succesfully consuming the lvm-localpv storage. | ||
|
||
## Exit-criteria | ||
|
||
- Volume should be resized successfully and application should be accessible seamlessly. | ||
- Application should be able to use the new resize volume space. | ||
|
||
## How to run | ||
|
||
- This experiment accepts the parameters in form of kubernetes job environmental variables. | ||
- For running this experiment of lvm volume resize, clone openens/lvm-localpv[https://github.com/openebs/lvm-localpv] repo and then first apply rbac and crds for e2e-framework. | ||
``` | ||
kubectl apply -f lvm-localpv/e2e-tests/hack/rbac.yaml | ||
kubectl apply -f lvm-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. |
51 changes: 51 additions & 0 deletions
51
e2e-tests/experiments/functional/lvm-volume-resize/run_e2e_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
generateName: lvm-vol-resize- | ||
namespace: e2e | ||
spec: | ||
template: | ||
metadata: | ||
name: lvm-vol-resize | ||
labels: | ||
app: lvm-vol-resize | ||
|
||
spec: | ||
serviceAccountName: e2e | ||
restartPolicy: Never | ||
containers: | ||
- name: ansibletest | ||
image: openebs/lvm-localpv-e2e:ci | ||
imagePullPolicy: IfNotPresent | ||
|
||
env: | ||
- name: ANSIBLE_STDOUT_CALLBACK | ||
value: default | ||
|
||
# This is the namespace where application pod is running | ||
- name: APP_NAMESPACE | ||
value: '' | ||
|
||
# Name of the application pvc | ||
- name: APP_PVC | ||
value: '' | ||
|
||
# Application pod label in `key=value` format | ||
- name: APP_LABEL | ||
value: '' | ||
|
||
# Storage class name used for `APP_PVC` provision | ||
- name: STORAGE_CLASS | ||
value: '' | ||
|
||
# PVC size (for eg. 5Gi) | ||
- name: OLD_PV_CAPACITY | ||
value: '' | ||
|
||
# Resized PVC size (for eg. 10Gi) | ||
- name: NEW_PV_CAPACITY | ||
value: '' | ||
|
||
command: ["/bin/bash"] | ||
args: ["-c", "ansible-playbook ./e2e-tests/experiments/functional/lvm-volume-resize/test.yml -i /etc/ansible/hosts -vv; exit 0"] |
149 changes: 149 additions & 0 deletions
149
e2e-tests/experiments/functional/lvm-volume-resize/test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
gather_facts: False | ||
|
||
vars_files: | ||
- test_vars.yml | ||
|
||
tasks: | ||
- block: | ||
|
||
## Generating the testname for lvm volume resize 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: Check if the desired PVC is bound | ||
shell: > | ||
kubectl get pvc {{ app_pvc }} -n {{ app_ns }} --no-headers | ||
-o custom-columns=:.status.phase | ||
args: | ||
executable: /bin/bash | ||
register: pvc_status | ||
failed_when: "'Bound' not in pvc_status.stdout" | ||
|
||
- name: Get the application pod name using {{ app_pvc }} pvc | ||
shell: > | ||
kubectl get pod -n {{ app_ns }} -l {{ app_label }} --no-headers | ||
-o custom-columns=:.metadata.name | ||
args: | ||
executable: /bin/bash | ||
register: app_pod | ||
|
||
- name: Obtain the mount path for the application | ||
shell: > | ||
kubectl get pod {{ app_pod.stdout }} -n {{ app_ns }} | ||
-o custom-columns=:.spec.containers[].volumeMounts[].mountPath --no-headers | ||
args: | ||
executable: /bin/bash | ||
register: mount | ||
|
||
- name: Fetch the Storage from PVC using namespace | ||
shell: kubectl get pvc -n {{ app_ns }} -o jsonpath={.items[0].spec.resources.requests.storage} | ||
args: | ||
executable: /bin/bash | ||
register: storage_capacity | ||
|
||
- name: Fetch the alphabet(G,M,m,g) from storage capacity | ||
shell: echo "{{ storage_capacity.stdout }}" | grep -o -E '[0-9]+' | ||
args: | ||
executable: /bin/bash | ||
register: value_str | ||
|
||
- name: Obtain the PVC spec | ||
shell: > | ||
kubectl get pvc {{ app_pvc }} -n {{ app_ns }} | ||
--no-headers -o yaml > pvc.yml | ||
args: | ||
executable: /bin/bash | ||
|
||
- name: Update the desired capacity in PVC spec | ||
replace: | ||
path: pvc.yml | ||
before: 'storageClassName: {{ storage_class }}' | ||
regexp: "storage: {{ vol_size }}" | ||
replace: "storage: {{ desired_vol_size }}" | ||
|
||
- name: Configure PVC with the new capacity | ||
shell: kubectl apply -f pvc.yml | ||
args: | ||
executable: /bin/bash | ||
register: result | ||
failed_when: "result.rc != 0" | ||
|
||
- name: Check if the desired PVC is bound | ||
shell: > | ||
kubectl get pvc {{ app_pvc }} -n {{ app_ns }} --no-headers | ||
-o custom-columns=:.status.phase | ||
args: | ||
executable: /bin/bash | ||
register: pvc_status | ||
failed_when: "'Bound' not in pvc_status.stdout" | ||
|
||
- name: Check if the storage capacity is updated in PVC | ||
shell: > | ||
kubectl get pvc {{ app_pvc }} -n {{ app_ns }} --no-headers | ||
-o custom-columns=:status.capacity.storage | ||
args: | ||
executable: /bin/bash | ||
register: capacity | ||
until: "desired_vol_size in capacity.stdout" | ||
delay: 10 | ||
retries: 50 | ||
|
||
- name: Restart the application pod after resizing the volume | ||
shell: kubectl delete pod {{ app_pod.stdout }} -n {{ app_ns }} | ||
args: | ||
executable: /bin/bash | ||
register: app_pod_status | ||
failed_when: app_pod_status.rc != 0 | ||
|
||
- name: Verify that application pod is deleted successfully. | ||
shell: > | ||
kubectl get pods -n {{ app_ns }} | ||
args: | ||
executable: /bin/bash | ||
register: app_pod_list | ||
until: '"{{ app_pod.stdout }}" not in app_pod_list.stdout' | ||
delay: 2 | ||
retries: 30 | ||
|
||
- name: Get the name of application pod after Restart | ||
shell: > | ||
kubectl get pod -n {{ app_ns }} -l {{ app_label }} --no-headers | ||
-o custom-columns=:.metadata.name | ||
args: | ||
executable: /bin/bash | ||
register: app_pod_name | ||
|
||
## Here we will dump +1Gi data than to previous pvc size | ||
- set_fact: | ||
value_num: '{{ ( (value_str.stdout | int + 1 | int) * 262144) | int }}' | ||
|
||
- name: Dump some more dummy data in the application mount point for using resized volume | ||
shell: > | ||
kubectl exec -it "{{ app_pod_name.stdout }}" -n "{{ app_ns }}" | ||
-- sh -c "cd {{ mount.stdout }} && dd if=/dev/urandom of=volume.txt bs=4k count={{ value_num }}" | ||
args: | ||
executable: /bin/bash | ||
register: load | ||
failed_when: "load.rc != 0" | ||
|
||
- 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' |
14 changes: 14 additions & 0 deletions
14
e2e-tests/experiments/functional/lvm-volume-resize/test_vars.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
test_name: lvm-volume-resize | ||
|
||
app_ns: "{{ lookup('env','APP_NAMESPACE') }}" | ||
|
||
app_label: "{{ lookup('env','APP_LABEL') }}" | ||
|
||
app_pvc: "{{ lookup('env','APP_PVC') }}" | ||
|
||
vol_size: "{{ lookup('env','OLD_PV_CAPACITY') }}" | ||
|
||
desired_vol_size: "{{ lookup('env','NEW_PV_CAPACITY') }}" | ||
|
||
storage_class: "{{ lookup('env','STORAGE_CLASS') }}" |