mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
feat(e2e-test): Add e2e-tests for zfs-localpv (#298)
Signed-off-by: w3aman <aman.gupta@mayadata.io>
This commit is contained in:
parent
53f872fcf1
commit
4e73638b5a
137 changed files with 8745 additions and 0 deletions
|
|
@ -0,0 +1,108 @@
|
|||
---
|
||||
- block:
|
||||
|
||||
- name: Create some test data in the busybox app
|
||||
shell: >
|
||||
kubectl exec {{ pod_name }} -n {{ ns }}
|
||||
-- sh -c "{{ item }}"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: result
|
||||
failed_when: "result.rc != 0"
|
||||
with_items:
|
||||
- "dd if=/dev/urandom of=/busybox/{{ testfile }} bs={{ blocksize }} count={{ blockcount }}"
|
||||
- "md5sum /busybox/{{ testfile }} > /busybox/{{ testfile }}-pre-chaos-md5"
|
||||
- "sync;sync;sync"
|
||||
|
||||
when: status == "LOAD"
|
||||
|
||||
- block:
|
||||
|
||||
- name: Kill the application pod
|
||||
shell: >
|
||||
kubectl delete pod {{ pod_name }} -n {{ ns }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Verify if the application pod is deleted
|
||||
shell: >
|
||||
kubectl get pods -n {{ ns }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: podstatus
|
||||
until: '"{{ pod_name }}" not in podstatus.stdout'
|
||||
retries: 2
|
||||
delay: 150
|
||||
|
||||
- name: Obtain the newly created pod name for application
|
||||
shell: >
|
||||
kubectl get pods -n {{ ns }} -l {{ label }} -o jsonpath='{.items[].metadata.name}'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: newpod_name
|
||||
|
||||
- name: Checking application pod is in running state
|
||||
shell: kubectl get pods -n {{ ns }} -o jsonpath='{.items[?(@.metadata.name=="{{ newpod_name.stdout }}")].status.phase}'
|
||||
register: result
|
||||
until: "((result.stdout.split()|unique)|length) == 1 and 'Running' in result.stdout"
|
||||
delay: 2
|
||||
retries: 150
|
||||
|
||||
- name: Get the container status of application.
|
||||
shell: >
|
||||
kubectl get pods -n {{ ns }} -o jsonpath='{.items[?(@.metadata.name=="{{ newpod_name.stdout }}")].status.containerStatuses[].state}' | grep running
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: containerStatus
|
||||
until: "'running' in containerStatus.stdout"
|
||||
delay: 2
|
||||
retries: 150
|
||||
|
||||
- name: Check the md5sum of stored data file
|
||||
shell: >
|
||||
kubectl exec {{ newpod_name.stdout }} -n {{ ns }}
|
||||
-- sh -c "md5sum /busybox/{{ testfile }} > /busybox/{{ testfile }}-post-chaos-md5"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: status
|
||||
failed_when: "status.rc != 0"
|
||||
|
||||
- name: Verify whether data is consistent
|
||||
shell: >
|
||||
kubectl exec {{ newpod_name.stdout }} -n {{ ns }}
|
||||
-- sh -c "diff /busybox/{{ testfile }}-pre-chaos-md5 /busybox/{{ testfile }}-post-chaos-md5"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: result
|
||||
failed_when: "result.rc != 0 or result.stdout != ''"
|
||||
|
||||
when: status == "VERIFY"
|
||||
|
||||
- block:
|
||||
|
||||
- name: Obtain the current pod name for application
|
||||
shell: >
|
||||
kubectl get pods -n {{ ns }} -l {{ label }} -o jsonpath='{.items[].metadata.name}'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: newpod_name
|
||||
|
||||
- name: Delete/drop the files
|
||||
shell: >
|
||||
kubectl exec {{ newpod_name.stdout }} -n {{ ns }}
|
||||
-- sh -c "rm -f /busybox/{{ testfile }}*"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: status
|
||||
|
||||
- name: Verify successful file delete
|
||||
shell: >
|
||||
kubectl exec {{ newpod_name.stdout }} -n {{ ns }}
|
||||
-- ls /busybox/
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: result
|
||||
failed_when: "testfile in result.stdout"
|
||||
|
||||
when: status == "DELETE"
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#Check if the database is ready for connection, upper bound wait time: 900s
|
||||
- name: Check if db is ready for connections
|
||||
shell: kubectl logs {{ pod_name.resources.0.metadata.name }} -n {{ app_ns }} | grep 'ready for connections' | wc -l
|
||||
register: initcheck
|
||||
until: initcheck.stdout == "2"
|
||||
delay: 5
|
||||
retries: 180
|
||||
|
||||
108
e2e-tests/utils/applications/mysql/mysql_data_persistence.yml
Normal file
108
e2e-tests/utils/applications/mysql/mysql_data_persistence.yml
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
---
|
||||
- block:
|
||||
|
||||
- name: Create some test data in the mysql database
|
||||
shell: >
|
||||
kubectl exec {{ pod_name }} -n {{ ns }}
|
||||
-- {{ item }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: result
|
||||
failed_when: "result.rc != 0"
|
||||
with_items:
|
||||
- mysql -u{{ dbuser }} -p{{ dbpassword }} -e 'create database {{ dbname }};'
|
||||
- mysql -u{{ dbuser }} -p{{ dbpassword }} -e 'create table ttbl (Data VARCHAR(20));' {{ dbname }}
|
||||
- mysql -u{{ dbuser }} -p{{ dbpassword }} -e 'insert into ttbl (Data) VALUES ("tdata");' {{ dbname }}
|
||||
|
||||
when: status == "LOAD"
|
||||
|
||||
- block:
|
||||
|
||||
- name: Kill the application pod
|
||||
shell: >
|
||||
kubectl delete pod {{ pod_name }} -n {{ ns }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Verify if the application pod is deleted
|
||||
shell: >
|
||||
kubectl get pods -n {{ ns }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: podstatus
|
||||
until: '"{{ pod_name }}" not in podstatus.stdout'
|
||||
retries: 2
|
||||
delay: 150
|
||||
|
||||
- name: Obtain the newly created pod name for application
|
||||
shell: >
|
||||
kubectl get pods -n {{ ns }} -l {{ label }} -o jsonpath='{.items[].metadata.name}'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: newpod_name
|
||||
|
||||
- name: Checking application pod is in running state
|
||||
shell: kubectl get pods -n {{ ns }} -o jsonpath='{.items[?(@.metadata.name=="{{ newpod_name.stdout }}")].status.phase}'
|
||||
register: result
|
||||
until: "((result.stdout.split()|unique)|length) == 1 and 'Running' in result.stdout"
|
||||
delay: 2
|
||||
retries: 150
|
||||
|
||||
- name: Get the container status of application.
|
||||
shell: >
|
||||
kubectl get pods -n {{ ns }} -o jsonpath='{.items[?(@.metadata.name=="{{ newpod_name.stdout }}")].status.containerStatuses[].state}' | grep running
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: containerStatus
|
||||
until: "'running' in containerStatus.stdout"
|
||||
delay: 2
|
||||
retries: 150
|
||||
|
||||
- name: Check if db is ready for connections
|
||||
shell: kubectl logs {{ newpod_name.stdout }} -n {{ ns }} | grep 'ready for connections'
|
||||
register: initcheck
|
||||
until: "'ready for connections' in initcheck.stdout"
|
||||
delay: 5
|
||||
retries: 180
|
||||
|
||||
- name: Checking for the Corrupted tables
|
||||
shell: >
|
||||
kubectl exec {{ newpod_name.stdout }} -n {{ ns }}
|
||||
-- mysqlcheck -c {{ dbname }} -u{{ dbuser }} -p{{ dbpassword }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: status
|
||||
failed_when: "'OK' not in status.stdout"
|
||||
|
||||
- name: Verify mysql data persistence
|
||||
shell: >
|
||||
kubectl exec {{ newpod_name.stdout }} -n {{ ns }}
|
||||
-- mysql -u{{ dbuser }} -p{{ dbpassword }} -e 'select * from ttbl' {{ dbname }};
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: result
|
||||
failed_when: "'tdata' not in result.stdout"
|
||||
|
||||
when: status == "VERIFY"
|
||||
|
||||
- block:
|
||||
|
||||
- name: Delete/drop MySQL database
|
||||
shell: >
|
||||
kubectl exec {{ pod_name }} -n {{ ns }}
|
||||
-- mysql -u{{ dbuser }} -p{{ dbpassword }} -e 'drop database {{ dbname }}';
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: status
|
||||
|
||||
- name: Verify successful db delete
|
||||
shell: >
|
||||
kubectl exec {{ pod_name }} -n {{ ns }}
|
||||
-- mysql -u{{ dbuser }} -p{{ dbpassword }} -e 'show databases';
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: result
|
||||
failed_when: "dbname in result.stdout"
|
||||
|
||||
when: status == "DELETE"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue