aboutsummaryrefslogtreecommitdiffstats
path: root/roles/onap-chaos-tests/tasks/node-cpu-hog.yaml
diff options
context:
space:
mode:
authorAndreas Geissler <andreas-geissler@telekom.de>2022-10-19 17:49:04 +0200
committerAndreas Geissler <andreas-geissler@telekom.de>2022-10-19 17:52:13 +0200
commitd273edeccd97122de1caec74243d702a652cacb9 (patch)
tree4414e752f4a6aebc6fa29ef79b36d9b5f5571858 /roles/onap-chaos-tests/tasks/node-cpu-hog.yaml
parented3c78887493baa5855ac5256683b68ab7b74073 (diff)
[GITLAB] Initial content for gitlab project xtesting-onap
Issue-ID: INT-2150 Signed-off-by: Andreas Geissler <andreas-geissler@telekom.de> Change-Id: I6a429e2f661474fe54b13b6513eca64f13e99b50
Diffstat (limited to 'roles/onap-chaos-tests/tasks/node-cpu-hog.yaml')
-rw-r--r--roles/onap-chaos-tests/tasks/node-cpu-hog.yaml86
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"