187 lines
6.2 KiB
YAML
187 lines
6.2 KiB
YAML
---
|
|
- hosts: localhost
|
|
connection: local
|
|
|
|
vars:
|
|
a_label: "{{ lookup('env','APP_LABEL') }}"
|
|
a_ns: "{{ lookup('env','APP_NAMESPACE') }}"
|
|
a_pvc: "{{ lookup('env','APP_PVC') }}"
|
|
c_experiment: openebs-target-pod-failure
|
|
c_force: "{{ lookup('env','FORCE') }}"
|
|
c_interval: "{{ lookup('env','CHAOS_INTERVAL') }}"
|
|
chaos_duration: "{{ lookup('env','TOTAL_CHAOS_DURATION') }}"
|
|
data_persistence: "{{ lookup('env','DATA_PERSISTENCE') }}"
|
|
deploy_type: "{{ lookup('env','DEPLOY_TYPE') }}"
|
|
liveness_label: "{{ lookup('env','LIVENESS_APP_LABEL') }}"
|
|
liveness_namespace: "{{ lookup('env','LIVENESS_APP_NAMESPACE') }}"
|
|
openebs_ns: "{{ lookup('env','OPENEBS_NAMESPACE') }}"
|
|
c_engine: "{{ lookup('env','CHAOSENGINE') }}"
|
|
chaos_pod_name: "{{ lookup('env','POD_NAME') }}"
|
|
chaos_uid: "{{ lookup('env','CHAOS_UID') }}"
|
|
|
|
vars_files:
|
|
- /mnt/parameters.yml
|
|
- /experiments/openebs/openebs_components.yml
|
|
|
|
tasks:
|
|
- block:
|
|
|
|
## PRE-CHAOS APPLICATION LIVENESS CHECK
|
|
- include_tasks: /utils/common/application_liveness_check.yml
|
|
when: liveness_label != ''
|
|
|
|
- include: openebs_target_pod_failure_ansible_prerequisites.yml
|
|
|
|
- include_vars:
|
|
file: data_persistence.yml
|
|
|
|
- include_vars:
|
|
file: chaosutil.yml
|
|
|
|
- name: Record the chaos util path
|
|
set_fact:
|
|
chaos_util_path: "{{ chaosutil }}"
|
|
|
|
- name: Getting the chaos namespace
|
|
set_fact:
|
|
c_ns: "{{ a_ns }}"
|
|
|
|
- name: Record the data consistency util path
|
|
set_fact:
|
|
data_consistency_util_path: "{{ consistencyutil }}"
|
|
when: data_persistence != ''
|
|
|
|
- include_tasks: /utils/runtime/create_testname.yml
|
|
|
|
## GENERATE EXP RESULT NAME
|
|
- name: Construct chaos result name
|
|
set_fact:
|
|
c_result: "{{ c_engine }}-{{ c_experiment }}"
|
|
when: "c_engine is defined and c_engine != ''"
|
|
|
|
## RECORD START-OF-TEST IN CHAOS RESULT CR
|
|
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
|
|
vars:
|
|
status: 'SOT'
|
|
namespace: "{{ c_ns }}"
|
|
|
|
## DISPLAY APP INFORMATION
|
|
|
|
- name: Display the app information passed via the test job
|
|
debug:
|
|
msg:
|
|
- "The application info is as follows:"
|
|
- "Namespace : {{ a_ns }}"
|
|
- "Target Namespace : {{ openebs_ns }}"
|
|
- "Label : {{ a_label }}"
|
|
- "PVC : {{ a_pvc }}"
|
|
- "StorageClass : {{ sc }}"
|
|
|
|
## PRE-CHAOS APPLICATION LIVENESS CHECK
|
|
|
|
- name: Verify that the AUT (Application Under Test) is running
|
|
include_tasks: "/utils/common/status_app_pod.yml"
|
|
vars:
|
|
app_ns: "{{ a_ns }}"
|
|
app_label: "{{ a_label }}"
|
|
delay: 2
|
|
retries: 90
|
|
|
|
## RECORD EVENT FOR PRE-CHAOS CHECK
|
|
- include_tasks: /utils/common/generate-kubernetes-chaos-events.yml
|
|
vars:
|
|
stage: "PreChaosCheck"
|
|
exp_pod_name: "{{ chaos_pod_name }}"
|
|
engine_ns: "{{ c_ns }}"
|
|
message: "OpenEBS components and AUT is Running successfully"
|
|
when: "c_engine is defined and c_engine != ''"
|
|
|
|
- name: Get application pod name
|
|
shell: >
|
|
kubectl get pods -n {{ a_ns }} -l {{ a_label }} --no-headers
|
|
-o=custom-columns=NAME:".metadata.name"
|
|
args:
|
|
executable: /bin/bash
|
|
register: app_pod_name
|
|
|
|
- name: Create some test data
|
|
include: "{{ data_consistency_util_path }}"
|
|
vars:
|
|
status: 'LOAD'
|
|
ns: "{{ a_ns }}"
|
|
pod_name: "{{ app_pod_name.stdout }}"
|
|
when: data_persistence != ''
|
|
|
|
## STORAGE FAULT INJECTION
|
|
|
|
- include: "{{ chaos_util_path }}"
|
|
|
|
## POST-CHAOS APPLICATION LIVENESS CHECK
|
|
|
|
- name: Wait (soak) for I/O on pools
|
|
wait_for:
|
|
timeout: "{{ chaos_duration }}"
|
|
|
|
- name: Verify AUT liveness post fault-injection
|
|
include_tasks: "/utils/common/status_app_pod.yml"
|
|
vars:
|
|
app_ns: "{{ a_ns }}"
|
|
app_label: "{{ a_label }}"
|
|
delay: 2
|
|
retries: 90
|
|
|
|
## RECORD EVENT FOR POST-CHAOS CHECK
|
|
- include_tasks: /utils/common/generate-kubernetes-chaos-events.yml
|
|
vars:
|
|
stage: "PostChaosCheck"
|
|
exp_pod_name: "{{ chaos_pod_name }}"
|
|
engine_ns: "{{ c_ns }}"
|
|
message: "OpenEBS components and AUT is Running successfully"
|
|
when: "c_engine is defined and c_engine != ''"
|
|
|
|
## POST-CHAOS APPLICATION LIVENESS CHECK
|
|
- include_tasks: /utils/common/application_liveness_check.yml
|
|
when: liveness_label != ''
|
|
|
|
- name: Get application pod name
|
|
shell: >
|
|
kubectl get pods -n {{ a_ns }} -l {{ a_label }} --no-headers
|
|
-o=custom-columns=NAME:".metadata.name"
|
|
args:
|
|
executable: /bin/bash
|
|
register: rescheduled_app_pod
|
|
|
|
- name: Verify application data persistence
|
|
include: "{{ data_consistency_util_path }}"
|
|
vars:
|
|
status: 'VERIFY'
|
|
ns: "{{ a_ns }}"
|
|
label: "{{ a_label }}"
|
|
pod_name: "{{ rescheduled_app_pod.stdout }}"
|
|
when: data_persistence != ''
|
|
|
|
## Check application-target pod affinity
|
|
- include_tasks: /utils/apps/openebs/target_affinity_check.yml
|
|
when: deploy_type == 'deployment'
|
|
|
|
## Check statefulset application-target pod affinity
|
|
- include_tasks: /utils/apps/openebs/sts_target_affinity_check.yml
|
|
when: deploy_type == 'statefulset'
|
|
|
|
- set_fact:
|
|
flag: "Pass"
|
|
|
|
rescue:
|
|
- set_fact:
|
|
flag: "Fail"
|
|
|
|
always:
|
|
|
|
## Getting failure step from experiment-pod
|
|
- include_tasks: /utils/runtime/getting_failure_step.yml
|
|
|
|
## RECORD END-OF-TEST IN CHAOS RESULT CR
|
|
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
|
|
vars:
|
|
status: 'EOT'
|
|
namespace: "{{ c_ns }}" |