aboutsummaryrefslogtreecommitdiffstats
path: root/roles/onap-chaos-tests/tasks/node-memory-hog.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/onap-chaos-tests/tasks/node-memory-hog.yaml')
-rw-r--r--roles/onap-chaos-tests/tasks/node-memory-hog.yaml86
1 files changed, 86 insertions, 0 deletions
diff --git a/roles/onap-chaos-tests/tasks/node-memory-hog.yaml b/roles/onap-chaos-tests/tasks/node-memory-hog.yaml
new file mode 100644
index 0000000..82ad014
--- /dev/null
+++ b/roles/onap-chaos-tests/tasks/node-memory-hog.yaml
@@ -0,0 +1,86 @@
+---
+- name: create directory for memory hog scenario
+ ansible.builtin.file:
+ path: /tmp/resiliency/node-memory-hog
+ state: directory
+ mode: '0755'
+ tags: prepare
+
+- name: Get compute node list
+ community.kubernetes.k8s_info:
+ kind: Node
+ label_selectors: "! node-role.kubernetes.io/master"
+ register: kubernetes_computer_node_list
+ tags: prepare
+
+- name: Set Fact first compute node Internal IP
+ ansible.builtin.set_fact:
+ first_node_ip: "{{ item.address }}"
+ when: "'Hostname' in item.type"
+ with_items:
+ "{{ (kubernetes_computer_node_list.resources | first).status.addresses }}"
+ tags: prepare
+
+- name: Set Compute for the node memory hog
+ ansible.builtin.set_fact:
+ compute_chaos: "{{ first_node_ip }}"
+ when: compute_chaos is not defined
+ tags: prepare
+
+- name: Prepare rbac file for node memory hog experiment
+ ansible.builtin.template:
+ src: node-memory-hog-rbac.yaml.j2
+ dest: /tmp/resiliency/node-memory-hog/node-memory-hog-rbac.yaml
+ mode: 0600
+ tags: prepare
+
+- name: Prepare chaos file for node memory hog experiment
+ ansible.builtin.template:
+ src: node-memory-hog-chaos.yaml.j2
+ dest: /tmp/resiliency/node-memory-hog/node-memory-hog-chaos.yaml
+ mode: 0600
+ tags: prepare
+
+- name: Apply node memory hog rbac
+ community.kubernetes.k8s:
+ state: present
+ src: /tmp/resiliency/node-memory-hog/node-memory-hog-rbac.yaml
+
+- name: Apply node memory hog experiment
+ community.kubernetes.k8s:
+ state: present
+ src: /tmp/resiliency/node-memory-hog/node-memory-hog-chaos.yaml
+
+- name: wait for the end of chaos
+ run_once: true
+ community.kubernetes.k8s_info:
+ kind: ChaosEngine
+ api_version: litmuschaos.io/v1alpha1
+ name: onap-chaos-memory
+ namespace: "{{ onap_namespace }}"
+ register: chaosengine_status
+ changed_when:
+ &chaos_test chaosengine_status is defined and
+ chaosengine_status.resources[0].status.engineStatus == "completed"
+ until: *chaos_test
+ retries: 5
+ delay: 120
+
+- name: get results
+ run_once: true
+ community.kubernetes.k8s_info:
+ kind: ChaosResult
+ api_version: litmuschaos.io/v1alpha1
+ name: onap-chaos-memory-node-memory-hog
+ namespace: "{{ onap_namespace }}"
+ register: chaosresult_drain
+ changed_when:
+ &chaos_result chaosresult_drain is defined and
+ (chaosresult_drain.resources[0].status.experimentStatus.verdict == "Pass" or
+ chaosresult_drain.resources[0].status.experimentStatus.verdict == "Fail" )
+ until: *chaos_result
+ retries: 5
+ delay: 20
+- name: Print the chaos result verdict
+ ansible.builtin.debug:
+ msg: " The test is {{ chaosresult_drain.resources[0].status.experimentStatus.verdict}}-ed"