From 7433b1c89e2ffba3b097832f353146f12987e6dd Mon Sep 17 00:00:00 2001 From: "wu.zhihui" Date: Thu, 2 Mar 2017 18:40:11 +0800 Subject: 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 --- qtip/driver/ansible.py | 14 ++++++ qtip/driver/ansible/__init__.py | 0 qtip/driver/ansible/ansible.py | 14 ------ qtip/driver/ansible/playbook/bwn_ng.yaml | 23 ---------- qtip/driver/ansible/playbook/inxi.yaml | 23 ---------- qtip/driver/ansible/playbook/prepare_env.yaml | 42 ----------------- qtip/driver/ansible/playbook/top.yaml | 10 ---- qtip/driver/playbook/bwn_ng.yaml | 23 ++++++++++ qtip/driver/playbook/dhrystone/clean.yaml | 27 +++++++++++ qtip/driver/playbook/dhrystone/run.yaml | 63 +++++++++++++++++++++++++ qtip/driver/playbook/dhrystone/setup.yaml | 66 +++++++++++++++++++++++++++ qtip/driver/playbook/inxi.yaml | 23 ++++++++++ qtip/driver/playbook/prepare_env.yaml | 54 ++++++++++++++++++++++ qtip/driver/playbook/top.yaml | 10 ++++ 14 files changed, 280 insertions(+), 112 deletions(-) create mode 100644 qtip/driver/ansible.py delete mode 100644 qtip/driver/ansible/__init__.py delete mode 100644 qtip/driver/ansible/ansible.py delete mode 100644 qtip/driver/ansible/playbook/bwn_ng.yaml delete mode 100644 qtip/driver/ansible/playbook/inxi.yaml delete mode 100644 qtip/driver/ansible/playbook/prepare_env.yaml delete mode 100644 qtip/driver/ansible/playbook/top.yaml create mode 100644 qtip/driver/playbook/bwn_ng.yaml create mode 100644 qtip/driver/playbook/dhrystone/clean.yaml create mode 100644 qtip/driver/playbook/dhrystone/run.yaml create mode 100644 qtip/driver/playbook/dhrystone/setup.yaml create mode 100644 qtip/driver/playbook/inxi.yaml create mode 100644 qtip/driver/playbook/prepare_env.yaml create mode 100644 qtip/driver/playbook/top.yaml (limited to 'qtip/driver') diff --git a/qtip/driver/ansible.py b/qtip/driver/ansible.py new file mode 100644 index 00000000..cd17625d --- /dev/null +++ b/qtip/driver/ansible.py @@ -0,0 +1,14 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp 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 +############################################################################## + +from qtip.driver.base import BaseDriver + + +class AnsibleDriver(BaseDriver): + """driver for running performance tests with Ansible""" diff --git a/qtip/driver/ansible/__init__.py b/qtip/driver/ansible/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/qtip/driver/ansible/ansible.py b/qtip/driver/ansible/ansible.py deleted file mode 100644 index cd17625d..00000000 --- a/qtip/driver/ansible/ansible.py +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################## -# Copyright (c) 2016 ZTE Corp 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 -############################################################################## - -from qtip.driver.base import BaseDriver - - -class AnsibleDriver(BaseDriver): - """driver for running performance tests with Ansible""" diff --git a/qtip/driver/ansible/playbook/bwn_ng.yaml b/qtip/driver/ansible/playbook/bwn_ng.yaml deleted file mode 100644 index 99477856..00000000 --- a/qtip/driver/ansible/playbook/bwn_ng.yaml +++ /dev/null @@ -1,23 +0,0 @@ -############################################################################## -# 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/ansible/playbook/inxi.yaml b/qtip/driver/ansible/playbook/inxi.yaml deleted file mode 100644 index f6a0311d..00000000 --- a/qtip/driver/ansible/playbook/inxi.yaml +++ /dev/null @@ -1,23 +0,0 @@ -############################################################################## -# 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/ansible/playbook/prepare_env.yaml b/qtip/driver/ansible/playbook/prepare_env.yaml deleted file mode 100644 index 0595d988..00000000 --- a/qtip/driver/ansible/playbook/prepare_env.yaml +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################## -# 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" diff --git a/qtip/driver/ansible/playbook/top.yaml b/qtip/driver/ansible/playbook/top.yaml deleted file mode 100644 index 8de7e3d6..00000000 --- a/qtip/driver/ansible/playbook/top.yaml +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################## -# 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 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 -- cgit 1.2.3-korg