From e579659699b4571a69990efc5861914e4701a4f6 Mon Sep 17 00:00:00 2001 From: Yujun Zhang Date: Sat, 22 Apr 2017 22:19:27 +0800 Subject: Unify workdir - use role variable `workdir` - download dependencies to remote workdir with checksum Change-Id: I2a7991e014e365fec532520c2b57a3fe480914d8 Signed-off-by: Yujun Zhang --- resources/ansible_roles/nDPI/defaults/main.yml | 12 ------ resources/ansible_roles/nDPI/tasks/main.yml | 48 +++++++++++----------- resources/ansible_roles/nDPI/vars/main.yml | 12 ++++++ .../ansible_roles/qtip-workspace/defaults/main.yml | 1 + .../qtip-workspace/files/custom/ansible.cfg | 4 +- .../qtip-workspace/files/custom/group_vars/all.yml | 3 +- .../qtip-workspace/files/defaults/teardown.yml | 19 +++++++++ .../qtip/tasks/install-deps-redhat.yml | 2 +- resources/ansible_roles/qtip/tasks/setup-node.yml | 7 +++- resources/ansible_roles/qtip/tasks/teardown.yml | 16 ++++++++ resources/ansible_roles/ramspeed/defaults/main.yml | 11 ----- resources/ansible_roles/ramspeed/tasks/main.yml | 25 +++++++---- resources/ansible_roles/ramspeed/vars/main.yml | 11 +++++ .../ansible_roles/unixbench/defaults/main.yml | 12 ------ resources/ansible_roles/unixbench/tasks/main.yml | 26 ++++++++---- resources/ansible_roles/unixbench/vars/main.yml | 12 ++++++ 16 files changed, 140 insertions(+), 81 deletions(-) delete mode 100644 resources/ansible_roles/nDPI/defaults/main.yml create mode 100644 resources/ansible_roles/nDPI/vars/main.yml create mode 100644 resources/ansible_roles/qtip-workspace/files/defaults/teardown.yml create mode 100644 resources/ansible_roles/qtip/tasks/teardown.yml delete mode 100644 resources/ansible_roles/ramspeed/defaults/main.yml create mode 100644 resources/ansible_roles/ramspeed/vars/main.yml delete mode 100644 resources/ansible_roles/unixbench/defaults/main.yml create mode 100644 resources/ansible_roles/unixbench/vars/main.yml diff --git a/resources/ansible_roles/nDPI/defaults/main.yml b/resources/ansible_roles/nDPI/defaults/main.yml deleted file mode 100644 index d8aae81a..00000000 --- a/resources/ansible_roles/nDPI/defaults/main.yml +++ /dev/null @@ -1,12 +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 -############################################################################# - ---- -nDPI_cwd: "{{ ansible_env.HOME }}/qtip/nDPI" -nDPI_file: "dpi.pcap" diff --git a/resources/ansible_roles/nDPI/tasks/main.yml b/resources/ansible_roles/nDPI/tasks/main.yml index d8bee591..e8d359e5 100644 --- a/resources/ansible_roles/nDPI/tasks/main.yml +++ b/resources/ansible_roles/nDPI/tasks/main.yml @@ -7,26 +7,24 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - -- name: prepare sample pcap file - get_url: - url: "http://artifacts.opnfv.org/qtip/utilities/test.pcap" - dest: "{{ qtip_cache }}/{{ nDPI_file }}" - # validate_certs: no # required when using proxy for https - run_once: yes - delegate_to: localhost +--- - name: making nDPI temporary directory file: - path: "{{ nDPI_cwd }}" + path: "{{ workdir }}" state: directory -- name: clone nDPI - git: - repo: https://github.com/ntop/nDPI.git - dest: "{{ nDPI_cwd }}" - depth: 1 - update: no +- name: downloading nDPI + get_url: + url: https://github.com/ntop/nDPI/archive/1.6.tar.gz + dest: "{{ workdir }}" + checksum: "sha256:0863c7096f70c785e1b27a34f7b40939ac1a0e3a734ea3dcaa5cf161360a2561" + +- name: extracting nDPI + command: "tar zxf nDPI-1.6.tar.gz" + args: + chdir: "{{ workdir }}" + creates: nDPI-1.6 - name: build nDPI library command: '{{ item }}' @@ -35,23 +33,25 @@ - ./configure - make args: - chdir: "{{ nDPI_cwd }}" + chdir: "{{ workdir }}/nDPI-1.6" creates: example/ndpiReader -- name: copy sample packet file - copy: - src: "{{ qtip_cache}}/{{ nDPI_file }}" - dest: "{{ nDPI_cwd }}/example/{{ nDPI_file }}" +- name: downloading sample pcap file + get_url: + url: "https://build.opnfv.org/artifacts.opnfv.org/qtip/utilities/test.pcap" + dest: "{{ workdir }}/nDPI-1.6/example/{{ sample_pcap }}" + checksum: "sha256:ac5d1501d91a6d8a8d3bfcef6f74a87bf660cd2c2ab11b9791535aa5193e4f71" + validate_certs: no # required when using proxy for https - name: - command: "./ndpiReader -i {{ nDPI_file }}" + command: "./ndpiReader -i {{ sample_pcap }}" args: - chdir: "{{ nDPI_cwd }}/example/" - register: nDPI_out + chdir: "{{ workdir }}/nDPI-1.6/example/" + register: ndpi_out - name: collect DPI metrics from nDPI collect: - string: "{{ nDPI_out.stdout }}" + string: "{{ ndpi_out.stdout }}" patterns: # nDPI throughput: 1.46 M pps / 13.69 Gb/sec # TODO(yujunz) convert "M pps" and "K pps" to number diff --git a/resources/ansible_roles/nDPI/vars/main.yml b/resources/ansible_roles/nDPI/vars/main.yml new file mode 100644 index 00000000..a39e9836 --- /dev/null +++ b/resources/ansible_roles/nDPI/vars/main.yml @@ -0,0 +1,12 @@ +############################################################################# +# 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 +############################################################################# + +--- +workdir: "{{ qtip_workdir }}/ndpi" +sample_pcap: "dpi.pcap" diff --git a/resources/ansible_roles/qtip-workspace/defaults/main.yml b/resources/ansible_roles/qtip-workspace/defaults/main.yml index 01923073..102a706e 100644 --- a/resources/ansible_roles/qtip-workspace/defaults/main.yml +++ b/resources/ansible_roles/qtip-workspace/defaults/main.yml @@ -17,3 +17,4 @@ installer_master_group: workspace: "workspace" qtip_package: ../../.. +qtip_cache: .qtip-cache \ No newline at end of file diff --git a/resources/ansible_roles/qtip-workspace/files/custom/ansible.cfg b/resources/ansible_roles/qtip-workspace/files/custom/ansible.cfg index 220cf0b3..a80d4ae4 100644 --- a/resources/ansible_roles/qtip-workspace/files/custom/ansible.cfg +++ b/resources/ansible_roles/qtip-workspace/files/custom/ansible.cfg @@ -223,7 +223,9 @@ filter_plugins = {{ qtip_package }}/qtip/ansible_library/plugins/filter # wanting to use, for example, IP information from one group of servers # without having to talk to them in the same playbook run to get their # current IP information. -#fact_caching = memory +fact_caching = jsonfile +fact_caching_connection = {{ qtip_cache }} +fact_caching_timeout = 86400 # retry files diff --git a/resources/ansible_roles/qtip-workspace/files/custom/group_vars/all.yml b/resources/ansible_roles/qtip-workspace/files/custom/group_vars/all.yml index d85eaabf..0f9016b4 100644 --- a/resources/ansible_roles/qtip-workspace/files/custom/group_vars/all.yml +++ b/resources/ansible_roles/qtip-workspace/files/custom/group_vars/all.yml @@ -11,7 +11,8 @@ qtip_resources: "{{ qtip_package }}/resources" qtip_results: results qtip_fixtures: fixtures qtip_dump: dump -qtip_cache: .cache +qtip_cache: "{{ qtip_cache }}" +qtip_workdir: "qtip-workdir-{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}" installer_master_group: fuel: fuel-masters apex: apex-underclouds diff --git a/resources/ansible_roles/qtip-workspace/files/defaults/teardown.yml b/resources/ansible_roles/qtip-workspace/files/defaults/teardown.yml new file mode 100644 index 00000000..4d51b64f --- /dev/null +++ b/resources/ansible_roles/qtip-workspace/files/defaults/teardown.yml @@ -0,0 +1,19 @@ +############################################################################## +# 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: compute + + vars_prompt: + - name: remove_workdir + prompt: "WARNING: remove work dir from system under test? (yes|no)" + default: no + + roles: + # teardown environment + - { role: qtip, tasks: teardown } diff --git a/resources/ansible_roles/qtip/tasks/install-deps-redhat.yml b/resources/ansible_roles/qtip/tasks/install-deps-redhat.yml index 32df3a41..82232273 100644 --- a/resources/ansible_roles/qtip/tasks/install-deps-redhat.yml +++ b/resources/ansible_roles/qtip/tasks/install-deps-redhat.yml @@ -13,7 +13,7 @@ name: epel-release state: present -- name: installing dependencis +- name: installing dependencies yum: name: "{{ item }}" state: present diff --git a/resources/ansible_roles/qtip/tasks/setup-node.yml b/resources/ansible_roles/qtip/tasks/setup-node.yml index b40cc625..92ee66bc 100644 --- a/resources/ansible_roles/qtip/tasks/setup-node.yml +++ b/resources/ansible_roles/qtip/tasks/setup-node.yml @@ -13,10 +13,15 @@ set_fact: qtip_results: "{{ hostvars['localhost']['qtip_results_base']}}/{{ inventory_hostname }}" -- name: create result directory +- name: creating result directory file: path: "{{ qtip_results }}" state: directory delegate_to: localhost +- name: creating work directory + file: + path: "{{ qtip_workdir }}" + state: directory + - include: install-deps.yml diff --git a/resources/ansible_roles/qtip/tasks/teardown.yml b/resources/ansible_roles/qtip/tasks/teardown.yml new file mode 100644 index 00000000..660b3a6a --- /dev/null +++ b/resources/ansible_roles/qtip/tasks/teardown.yml @@ -0,0 +1,16 @@ +############################################################################## +# 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: removing work directory + file: + path: "{{ qtip_workdir }}" + state: absent + when: remove_workdir|bool diff --git a/resources/ansible_roles/ramspeed/defaults/main.yml b/resources/ansible_roles/ramspeed/defaults/main.yml deleted file mode 100644 index 0cc06cf6..00000000 --- a/resources/ansible_roles/ramspeed/defaults/main.yml +++ /dev/null @@ -1,11 +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 -############################################################################# - ---- -cwd: "{{ ansible_env.HOME }}/qtip/ramspeed" diff --git a/resources/ansible_roles/ramspeed/tasks/main.yml b/resources/ansible_roles/ramspeed/tasks/main.yml index 2616cccc..2ecf4279 100644 --- a/resources/ansible_roles/ramspeed/tasks/main.yml +++ b/resources/ansible_roles/ramspeed/tasks/main.yml @@ -9,35 +9,42 @@ - name: making ramspeed working directory file: - path: "{{ cwd }}" + path: "{{ workdir }}" state: directory tags: [setup] -- name: download ramspeed/ramsmp - unarchive: - src: http://www.alasir.com/software/ramspeed/ramsmp-3.5.0.tar.gz - dest: "{{ cwd }}" - remote_src: yes +- name: downloading ramsmp + get_url: + url: http://www.alasir.com/software/ramspeed/ramsmp-3.5.0.tar.gz + dest: "{{ workdir }}" + checksum: "sha256:39fb15493fb3c293575746d56f6ab9faaa1d876d8b1f0d8e5a4042d2ace95839" tags: [setup] +- name: extracting ramsmp + # TODO(yujunz) unarchive may not work with long path (local: macOS, workdir: /root/qtip-workdir-20170423-0836/) + command: "tar zxf ramsmp-3.5.0.tar.gz" + args: + chdir: "{{ workdir }}" + creates: ramsmp-3.5.0 + - name: build ramsmp command: ./build.sh args: - chdir: "{{ cwd }}/ramsmp-3.5.0" + chdir: "{{ workdir }}/ramsmp-3.5.0" creates: ramsmp tags: [setup] - name: intmem benchmarking command: ./ramsmp -b 3 -l 5 -p 1 args: - chdir: "{{ cwd }}/ramsmp-3.5.0" + chdir: "{{ workdir }}/ramsmp-3.5.0" register: ramsmp_intmem_out tags: [run] - name: floatmem benchmarking command: ./ramsmp -b 6 -l 5 -p 1 args: - chdir: "{{ cwd }}/ramsmp-3.5.0" + chdir: "{{ workdir }}/ramsmp-3.5.0" register: ramsmp_floatmem_out tags: [run] diff --git a/resources/ansible_roles/ramspeed/vars/main.yml b/resources/ansible_roles/ramspeed/vars/main.yml new file mode 100644 index 00000000..b8737585 --- /dev/null +++ b/resources/ansible_roles/ramspeed/vars/main.yml @@ -0,0 +1,11 @@ +############################################################################# +# 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 +############################################################################# + +--- +workdir: "{{ qtip_workdir }}/ramspeed" diff --git a/resources/ansible_roles/unixbench/defaults/main.yml b/resources/ansible_roles/unixbench/defaults/main.yml deleted file mode 100644 index d1facef5..00000000 --- a/resources/ansible_roles/unixbench/defaults/main.yml +++ /dev/null @@ -1,12 +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 -############################################################################# - -cwd: "{{ ansible_env.HOME }}/qtip/unixbench" -iterations: 1 -parallel_copies: 1 \ No newline at end of file diff --git a/resources/ansible_roles/unixbench/tasks/main.yml b/resources/ansible_roles/unixbench/tasks/main.yml index 58f0608d..ff2c3534 100644 --- a/resources/ansible_roles/unixbench/tasks/main.yml +++ b/resources/ansible_roles/unixbench/tasks/main.yml @@ -9,29 +9,37 @@ - name: make unixbench working directory file: - path: "{{ cwd }}" + path: "{{ workdir }}" state: directory -- name: download unixbench source code - unarchive: - src: https://github.com/kdlucas/byte-unixbench/archive/v5.1.3.tar.gz - dest: "{{ cwd }}" - remote_src: yes +- name: downloading unixbench source code + get_url: + url: https://github.com/kdlucas/byte-unixbench/archive/v5.1.3.tar.gz + dest: "{{ workdir }}" + checksum: "sha256:3a6bb00f270a5329682dff20fd2c1ab5332ef046eb54a96a0d7bd371005d31a3" + +- name: extracting unixbench source code + # TODO(yujunz) unarchive may not work with long path (local: macOS, workdir: /root/qtip-workdir-20170423-0836/) + command: "tar zxf byte-unixbench-5.1.3.tar.gz" + args: + chdir: "{{ workdir }}" + creates: byte-unixbench-5.1.3 - name: build UnixBench command: "make" args: - chdir: "{{ cwd }}/byte-unixbench-5.1.3/UnixBench" + chdir: "{{ workdir }}/byte-unixbench-5.1.3/UnixBench" + creates: Run - name: run whetstone and dhrystone shell: "./Run -i {{ iterations }} -c {{ parallel_copies }} dhrystone whetstone" args: - chdir: "{{ cwd }}/byte-unixbench-5.1.3/UnixBench" + chdir: "{{ workdir }}/byte-unixbench-5.1.3/UnixBench" - name: synchronize test results to local synchronize: mode: pull - src: "{{ cwd }}/byte-unixbench-5.1.3/UnixBench/results/" + src: "{{ workdir }}/byte-unixbench-5.1.3/UnixBench/results/" dest: "{{ qtip_results }}/unixbench" use_ssh_args: yes diff --git a/resources/ansible_roles/unixbench/vars/main.yml b/resources/ansible_roles/unixbench/vars/main.yml new file mode 100644 index 00000000..8fc1e0d2 --- /dev/null +++ b/resources/ansible_roles/unixbench/vars/main.yml @@ -0,0 +1,12 @@ +############################################################################# +# 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 +############################################################################# + +workdir: "{{ qtip_workdir }}/unixbench" +iterations: 1 +parallel_copies: 1 -- cgit 1.2.3-korg