diff options
Diffstat (limited to 'roles/onap-chaos-tests/tasks/node-cpu-hog.yaml')
-rw-r--r-- | roles/onap-chaos-tests/tasks/node-cpu-hog.yaml | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/roles/onap-chaos-tests/tasks/node-cpu-hog.yaml b/roles/onap-chaos-tests/tasks/node-cpu-hog.yaml new file mode 100644 index 0000000..c70f339 --- /dev/null +++ b/roles/onap-chaos-tests/tasks/node-cpu-hog.yaml @@ -0,0 +1,86 @@ +--- +- name: create directory for cpu hog scenario + ansible.builtin.file: + path: /tmp/resiliency/node-cpu-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 cpu hog + ansible.builtin.set_fact: + compute_chaos: "{{ first_node_ip }}" + when: compute_chaos is not defined + tags: prepare + +- name: Prepare rbac file for node cpu hog experiment + ansible.builtin.template: + src: node-cpu-hog-rbac.yaml.j2 + dest: /tmp/resiliency/node-cpu-hog/node-cpu-hog-rbac.yaml + mode: 0600 + tags: prepare + +- name: Prepare chaos file for node cpu hog experiment + ansible.builtin.template: + src: node-cpu-hog-chaos.yaml.j2 + dest: /tmp/resiliency/node-cpu-hog/node-cpu-hog-chaos.yaml + mode: 0600 + tags: prepare + +- name: Apply node cpu hog rbac + community.kubernetes.k8s: + state: present + src: /tmp/resiliency/node-cpu-hog/node-cpu-hog-rbac.yaml + +- name: Apply node cpu hog experiment + community.kubernetes.k8s: + state: present + src: /tmp/resiliency/node-cpu-hog/node-cpu-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-cpu + 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-cpu-node-cpu-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" |