Skip to content

Commit

Permalink
(refactor): Refactor experiments to make them uniform (#1206)
Browse files Browse the repository at this point in the history
Signed-off-by: shubhamchaudhary <shubham.chaudhary@mayadata.io>
  • Loading branch information
ispeakc0de authored Feb 12, 2020
1 parent 2fe9454 commit 6a20d23
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 65 deletions.
4 changes: 2 additions & 2 deletions experiments/coredns/pod_delete/chaosutil.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if c_lib is defined and c_lib == 'powerfulseal' %}
c_util: /chaoslib/powerfulseal/pod_failure_by_powerfulseal.yml
c_util: /chaoslib/powerfulseal/pod_failure_by_powerfulseal.yml
{% else %}
c_util: /chaoslib/litmus/pod_failure_by_litmus.yml
c_util: /chaoslib/litmus/pod_failure_by_litmus.yml
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@
tasks:
- block:

- include_tasks: /utils/runtime/create_testname.yml

- include_tasks: openebs_pool_network_delay_ansible_prerequisites.yml

# GENERATE EXPERIMENT RESULT NAME AND CREATE CHAOS RESULT RESOURCE
- block:
- name: Construct chaos result name (experiment_name)
set_fact:
c_experiment: "{{ lookup('env','CHAOSENGINE') }}-{{ c_experiment }}"
when: lookup('env','CHAOSENGINE')

- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'SOT'
namespace: "{{ a_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 }}"
- "Label : {{ a_label }}"
- "PVC : {{ a_pvc }}"
- include_tasks: /utils/runtime/create_testname.yml

- include_tasks: openebs_pool_network_delay_ansible_prerequisites.yml

# GENERATE EXPERIMENT RESULT NAME
- block:
- name: Construct chaos result name (experiment_name)
set_fact:
c_experiment: "{{ lookup('env','CHAOSENGINE') }}-{{ c_experiment }}"
when: lookup('env','CHAOSENGINE')

# CREATE CHAOS RESULT RESOURCE
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'SOT'
namespace: "{{ a_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 }}"
- "Label : {{ a_label }}"
- "PVC : {{ a_pvc }}"

# PRE_CHAOS CHECKS
- block:
# PRE_CHAOS CHECKS
- name: Verify that cStor pool is healthy
shell: >
kubectl get csp -n {{ openebs_ns }} -o jsonpath='{.items[*].status.phase}'
Expand Down Expand Up @@ -81,12 +81,11 @@
pod_name: "{{ app_pod.stdout }}"
when: data_persistence | length > 0

# INJECTING CHAOS
- name: Injecting the chaos
include_tasks: "{{ c_util }}"
# INJECTING CHAOS
- name: Injecting the chaos
include_tasks: "{{ c_util }}"

# POST CHAOS CHECKS
- block:
# POST CHAOS CHECKS
- name: Verify that cStor pool is healthy
shell: >
kubectl get csp -n {{ openebs_ns }} -o jsonpath='{.items[*].status.phase}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
include_tasks: /utils/apps/openebs/fetch_sc_and_provisioner.yml

- block:

- name: Derive PV name from PVC to query storage engine type (openebs)
shell: >
kubectl get pvc {{ a_pvc }} -n {{ a_ns }}
Expand All @@ -21,6 +22,7 @@
- name: Record the storage engine name
set_fact:
stg_engine: "{{ openebs_stg_engine.stdout }}"

when: stg_prov == "openebs.io/provisioner-iscsi"

- name: Identify the chaos util to be invoked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,34 @@

tasks:
- block:
- include_tasks: /utils/runtime/create_testname.yml

- include: openebs_pool_network_loss_ansible_prerequisites.yml

# GENERATE EXPERIMENT RESULT NAME AND CREATE CHAOS RESULT RESOURCE
- block:
- name: Construct chaos result name (experiment_name)
set_fact:
c_experiment: "{{ lookup('env','CHAOSENGINE') }}-{{ c_experiment }}"
when: lookup('env','CHAOSENGINE')

- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'SOT'
namespace: "{{ a_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 }}"
- "Label : {{ a_label }}"
- "PVC : {{ a_pvc }}"

- include_tasks: /utils/runtime/create_testname.yml

- include: openebs_pool_network_loss_ansible_prerequisites.yml

# GENERATE EXPERIMENT RESULT NAME
- block:
- name: Construct chaos result name (experiment_name)
set_fact:
c_experiment: "{{ lookup('env','CHAOSENGINE') }}-{{ c_experiment }}"
when: lookup('env','CHAOSENGINE')

# GENERATE EXPERIMENT RESULT NAME AND CREATE CHAOS RESULT RESOURCE
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'SOT'
namespace: "{{ a_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 }}"
- "Label : {{ a_label }}"
- "PVC : {{ a_pvc }}"

# # PRE_CHAOS CHECKS
- block:
## PRE_CHAOS CHECKS
- name: Verify that cStor pool is healthy
shell: >
kubectl get csp -n {{ openebs_ns }} -o jsonpath='{.items[*].status.phase}'
Expand Down Expand Up @@ -80,12 +81,11 @@
pod_name: "{{ app_pod.stdout }}"
when: data_persistence | length > 0

# INJECTING CHAOS
- name: Injecting the chaos
include_tasks: "{{ c_util }}"
# INJECTING CHAOS
- name: Injecting the chaos
include_tasks: "{{ c_util }}"

# POST CHAOS CHECKS
- block:
# POST CHAOS CHECKS
- name: Verify that cStor pool is healthy
shell: >
kubectl get csp -n {{ openebs_ns }} -o jsonpath='{.items[*].status.phase}'
Expand All @@ -109,7 +109,7 @@
ns: "{{ a_ns }}"
label: "{{ a_label }}"
pod_name: "{{ app_pod.stdout }}"
when: data_persistence != ''
when: data_persistence | length > 0

- set_fact:
flag: "Pass"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
include_tasks: /utils/apps/openebs/fetch_sc_and_provisioner.yml

- block:

- name: Derive PV name from PVC to query storage engine type (openebs)
shell: >
kubectl get pvc {{ a_pvc }} -n {{ a_ns }}
Expand All @@ -25,6 +26,7 @@
- name: Record the storage engine name
set_fact:
stg_engine: "{{ openebs_stg_engine.stdout }}"

when: stg_prov == "openebs.io/provisioner-iscsi"

- name: Identify the chaos util to be invoked
Expand Down

0 comments on commit 6a20d23

Please sign in to comment.