litmus/experiments/generic/disk_fill/disk_fill_ansible_logic.yml

131 lines
4.2 KiB
YAML

---
- hosts: localhost
connection: local
vars_files:
- /chaoslib/litmus/disk_fill/test_vars_diskfill.yml
vars:
c_util: "/chaoslib/litmus/disk_fill/disk_fill_by_litmus.yml"
c_container: "{{ lookup('env','TARGET_CONTAINER') }}"
c_experiment: "disk-fill"
c_duration: "{{ lookup('env','TOTAL_CHAOS_DURATION') }}"
ramp_time: "{{ lookup('env','RAMP_TIME') }}"
a_ns: "{{ lookup('env','APP_NAMESPACE') }}"
a_label: "{{ lookup('env','APP_LABEL') }}"
fill_percentage: "{{ lookup('env','FILL_PERCENTAGE') }}"
auxiliary_appinfo: "{{ lookup('env','AUXILIARY_APPINFO') }}"
chaos_uid: "{{ lookup('env','CHAOS_UID') }}"
c_engine: "{{ lookup('env','CHAOSENGINE') }}"
chaos_pod_name: "{{ lookup('env','POD_NAME') }}"
tasks:
- block:
- name: Getting the chaos namespace
set_fact:
c_ns: "{{ a_ns }}"
## 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-EXPERIMENT IN LITMUSCHAOS RESULT CR
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'SOT'
namespace: "{{ c_ns }}"
## 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
# Auxiliary application health check status
- block:
- name: Record auxiliary appinfo
set_fact:
auxiliary_appinfo_list: "{{ auxiliary_appinfo.split(',') }}"
- include: /utils/common/status_app_pod.yml
vars:
app_ns: "{{ item.split(':')[0] }}"
app_label: "{{ item.split(':')[1] }}"
delay: 2
retries: 90
with_items:
- "{{ auxiliary_appinfo_list }}"
when: auxiliary_appinfo is defined and auxiliary_appinfo != ''
## 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: "AUT is Running successfully"
when: "c_engine is defined and c_engine != ''"
## FAULT INJECTION
- include_tasks: "{{ c_util }}"
vars:
action: "disk-fill"
## POST-CHAOS APPLICATION LIVENESS CHECK
- 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
# Auxiliary application health check status
- block:
- include: /utils/common/status_app_pod.yml
vars:
app_ns: "{{ item.split(':')[0] }}"
app_label: "{{ item.split(':')[1] }}"
delay: 2
retries: 90
with_items:
- "{{ auxiliary_appinfo_list }}"
when: auxiliary_appinfo is defined and auxiliary_appinfo != ''
## 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: "AUT is Running successfully"
when: "c_engine is defined and c_engine != ''"
- 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 LITMUSCHAOS RESULT CR
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'EOT'
namespace: "{{ c_ns }}"