summaryrefslogtreecommitdiffstats
path: root/qtip/driver/playbook
diff options
context:
space:
mode:
authorwu.zhihui <wu.zhihui1@zte.com.cn>2017-03-02 18:40:11 +0800
committerzhihui wu <zhihui.wu2006+zte@gmail.com>2017-03-03 00:53:59 +0000
commit7433b1c89e2ffba3b097832f353146f12987e6dd (patch)
tree2e99d8a91417414d4cce6dd299d918a604e4d206 /qtip/driver/playbook
parent473deae9a10162f000c49ca49b4e31b28c4bf0d8 (diff)
Refactor dhrystone playbook
- Break previous one playbook into three playbooks: setup.yaml: setup test environment. run.yaml: execute test steps clean.yaml: cleanup test environment to restore environment The advantage is cleaning part will never be blocked by another. - Just do testing on remote hosts, parse logfile on localhost. - Use ansible module instead of shell command. - Move up all files under /ansible and remove ansible directory. Under /ansible, ansible package cann't be imported. Change-Id: I43c65be23869b7d42ca769994d4decb9a012d196 Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
Diffstat (limited to 'qtip/driver/playbook')
-rw-r--r--qtip/driver/playbook/bwn_ng.yaml23
-rw-r--r--qtip/driver/playbook/dhrystone/clean.yaml27
-rw-r--r--qtip/driver/playbook/dhrystone/run.yaml63
-rw-r--r--qtip/driver/playbook/dhrystone/setup.yaml66
-rw-r--r--qtip/driver/playbook/inxi.yaml23
-rw-r--r--qtip/driver/playbook/prepare_env.yaml54
-rw-r--r--qtip/driver/playbook/top.yaml10
7 files changed, 266 insertions, 0 deletions
diff --git a/qtip/driver/playbook/bwn_ng.yaml b/qtip/driver/playbook/bwn_ng.yaml
new file mode 100644
index 00000000..99477856
--- /dev/null
+++ b/qtip/driver/playbook/bwn_ng.yaml
@@ -0,0 +1,23 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+- name: Install bwm-ng when CentOS
+ yum:
+ name: bwm-ng
+ state: present
+ when: ansible_os_family == "RedHat"
+
+- name: Install bwm-ng when Ubuntu
+ apt:
+ name: bwm-ng
+ state: present
+ update_cache: yes
+ when: ansible_os_family == "Debian"
+
+- name: Run bwm-ng
+ shell: bwm-ng -o plain -c 1 > $HOME/qtip_result/bwm-dump.log \ No newline at end of file
diff --git a/qtip/driver/playbook/dhrystone/clean.yaml b/qtip/driver/playbook/dhrystone/clean.yaml
new file mode 100644
index 00000000..72bfab7e
--- /dev/null
+++ b/qtip/driver/playbook/dhrystone/clean.yaml
@@ -0,0 +1,27 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+- hosts: hosts
+ become: yes
+ remote_user: root
+
+ tasks:
+ - name: Checking home directory
+ shell: echo $HOME
+ register: home_dir
+
+ - name: Cleaning tempT
+ file:
+ path: '{{ home_dir.stdout }}/tempT'
+ state: absent
+
+ - name: Cleaning qtip_result
+ file:
+ path: '{{ home_dir.stdout }}/qtip_result'
+ state: absent
diff --git a/qtip/driver/playbook/dhrystone/run.yaml b/qtip/driver/playbook/dhrystone/run.yaml
new file mode 100644
index 00000000..55de6597
--- /dev/null
+++ b/qtip/driver/playbook/dhrystone/run.yaml
@@ -0,0 +1,63 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+- hosts: hosts
+ become: yes
+ remote_user: root
+
+ tasks:
+ - name: Get current timestamp
+ set_fact:
+ timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M') }}"
+
+ - name: Checking home directory
+ shell: echo $HOME
+ register: home_dir
+
+ - name: Fetch hostname
+ shell: hostname
+ register: host_name
+
+ - name: Make UnixBench
+ shell: make --directory $HOME/tempT/UnixBench/
+
+ - name: Make some directories needed
+ file:
+ path: '{{ home_dir.stdout }}/qtip_result/{{ timestamp }}/{{ host_name.stdout }}'
+ state: directory
+
+ - include: ../inxi.yaml
+
+ - include: ../top.yaml
+
+ - name: Run dhrystone
+ shell: ./Run -v dhrystone
+ args:
+ chdir: '{{ home_dir.stdout }}/tempT/UnixBench/'
+
+ - name: Copying result to qtip result directory
+ shell: cp -r $HOME/tempT/UnixBench/results/* ./
+ args:
+ chdir: '{{ home_dir.stdout }}/qtip_result/{{ timestamp }}/{{ host_name.stdout }}'
+
+ - name: Copy top log to qtip result directory
+ shell: mv $HOME/qtip_result/top.log ./
+ args:
+ chdir: '{{ home_dir.stdout }}/qtip_result/{{ timestamp }}/{{ host_name.stdout }}'
+
+ - name: Copy inxi log to qtip result directory
+ shell: mv $HOME/qtip_result/inxi.log ./
+ args:
+ chdir: '{{ home_dir.stdout }}/qtip_result/{{ timestamp }}/{{ host_name.stdout }}'
+
+ - name: Fetch result files to local manchine
+ synchronize:
+ mode: pull
+ src: '{{ home_dir.stdout }}/qtip_result/'
+ dest: '{{ result_dir }}/dhrystone/logs/'
diff --git a/qtip/driver/playbook/dhrystone/setup.yaml b/qtip/driver/playbook/dhrystone/setup.yaml
new file mode 100644
index 00000000..430670c1
--- /dev/null
+++ b/qtip/driver/playbook/dhrystone/setup.yaml
@@ -0,0 +1,66 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+- hosts: localhost
+ connection: local
+ gather_facts: no
+
+ tasks:
+ - name: Making dhrystone directory
+ file:
+ path: '{{ result_dir }}/dhrystone/logs/'
+ state: directory
+
+- hosts: hosts
+ become: yes
+ remote_user: root
+
+ tasks:
+ - name: Checking home directory
+ shell: echo $HOME
+ register: home_dir
+
+ - name: Cleaning tempT directory
+ file:
+ path: '{{ home_dir.stdout }}/tempT'
+ state: absent
+
+ - name: Cleaning qtip_result directory
+ file:
+ path: '{{ home_dir.stdout }}/qtip_result'
+ state: absent
+
+ - include: ../prepare_env.yaml
+
+ - name: Installing UnixBench dependencies if CentOS
+ yum:
+ name: '{{ item }}'
+ state: present
+ when: ansible_os_family == "RedHat"
+ with_items:
+ - git
+ - gcc
+ - patch
+ - perl-Time-HiRes
+
+ - name: Installing UnixBench dependencies if Ubuntu
+ apt:
+ name: '{{ item }}'
+ state: present
+ when: ansible_os_family == "Debian"
+ with_items:
+ - git
+ - gcc
+ - patch
+ - perl
+
+ - name: Clone unixbench
+ git:
+ repo: https://github.com/kdlucas/byte-unixbench.git
+ dest: '{{ home_dir.stdout }}/tempT'
diff --git a/qtip/driver/playbook/inxi.yaml b/qtip/driver/playbook/inxi.yaml
new file mode 100644
index 00000000..f6a0311d
--- /dev/null
+++ b/qtip/driver/playbook/inxi.yaml
@@ -0,0 +1,23 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+- name: Install Inxi when CentOS
+ yum:
+ name: inxi
+ state: present
+ when: ansible_os_family == "RedHat"
+
+- name: Install Inxi when Ubuntu
+ apt:
+ name: inxi
+ state: present
+ update_cache: yes
+ when: ansible_os_family == "Debian"
+
+- name: Run inxi
+ shell: inxi -b -c0 -n > $HOME/qtip_result/inxi.log
diff --git a/qtip/driver/playbook/prepare_env.yaml b/qtip/driver/playbook/prepare_env.yaml
new file mode 100644
index 00000000..1ec71520
--- /dev/null
+++ b/qtip/driver/playbook/prepare_env.yaml
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+- name: Epel Release install when CentOS
+ yum:
+ name: epel-release
+ state: present
+ when: ansible_os_family == "RedHat"
+
+- name: Software Properties Common
+ apt:
+ name: software-properties-common
+ state: present
+ when: ansible_os_family == "Debian"
+
+- name: Adding ubuntu backport main repo
+ apt_repository:
+ repo: deb http://archive.ubuntu.com/ubuntu/ {{ansible_distribution_release}}-backports main restricted universe multiverse
+ state: present
+ when: ansible_os_family == "Debian"
+
+- name: Adding ubuntu main repo
+ apt_repository:
+ repo: deb http://archive.ubuntu.com/ubuntu/ {{ansible_distribution_release}} main restricted universe multiverse
+ when: ansible_os_family == "Debian"
+
+- name: Install ansible copy dependencies if remote host has selinux enabled
+ yum:
+ name: libselinux-python
+ state: present
+ when: ansible_os_family == "RedHat"
+
+- name: Install ansiblle copy dependencies if remote host has selinux enaled
+ apt:
+ name: python-selinux
+ state: present
+ when: ansible_os_family == "Debian"
+
+- name: Install rsync when CentOS
+ yum:
+ name: rsync
+ state: present
+ when: ansible_os_family == "RedHat"
+
+- name: Install rsync when Ubuntu
+ apt:
+ name: rsync
+ state: present
+ when: ansible_os_family == "Debian"
diff --git a/qtip/driver/playbook/top.yaml b/qtip/driver/playbook/top.yaml
new file mode 100644
index 00000000..8de7e3d6
--- /dev/null
+++ b/qtip/driver/playbook/top.yaml
@@ -0,0 +1,10 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+- name: Collect cpu usage
+ shell: top -bn1 > $HOME/qtip_result/top.log