diff options
-rw-r--r-- | benchmarks/playbooks/cachebench.yaml | 23 | ||||
-rw-r--r-- | benchmarks/playbooks/dhrystone.yaml | 28 | ||||
-rw-r--r-- | benchmarks/playbooks/dpi.yaml | 24 | ||||
-rw-r--r-- | benchmarks/playbooks/fio.yaml | 19 | ||||
-rw-r--r-- | benchmarks/playbooks/git_proxy_pbook.yaml | 1 | ||||
-rw-r--r-- | benchmarks/playbooks/iperf.yaml | 21 | ||||
-rw-r--r-- | benchmarks/playbooks/netperf.yaml | 30 | ||||
-rw-r--r-- | benchmarks/playbooks/pktgen.yaml | 15 | ||||
-rw-r--r-- | benchmarks/playbooks/ramspeed.yaml | 19 | ||||
-rw-r--r-- | benchmarks/playbooks/ssl.yaml | 27 | ||||
-rw-r--r-- | benchmarks/playbooks/sys_info_pbook.yaml | 5 | ||||
-rw-r--r-- | benchmarks/playbooks/whetstone.yaml | 17 | ||||
-rwxr-xr-x | data/qtip_creds.sh | 4 | ||||
-rw-r--r-- | docker/Dockerfile | 5 | ||||
-rw-r--r-- | docker/ansible.cfg.default | 2 | ||||
-rw-r--r-- | docker/packages.pip | 8 | ||||
-rw-r--r-- | func/args_handler.py | 11 | ||||
-rw-r--r-- | func/cli.py | 8 | ||||
-rw-r--r-- | func/driver.py | 29 | ||||
-rw-r--r-- | func/env_setup.py | 69 | ||||
-rw-r--r-- | tests/args_handler_test.py | 6 | ||||
-rw-r--r-- | tests/cli_test.py | 13 | ||||
-rw-r--r-- | tests/driver_test.py | 36 | ||||
-rw-r--r-- | tests/output/hosts | 2 | ||||
-rw-r--r-- | tests/schema/test_bm_schema.yaml | 1 |
25 files changed, 254 insertions, 169 deletions
diff --git a/benchmarks/playbooks/cachebench.yaml b/benchmarks/playbooks/cachebench.yaml index ebd0e172..ca9a709c 100644 --- a/benchmarks/playbooks/cachebench.yaml +++ b/benchmarks/playbooks/cachebench.yaml @@ -1,4 +1,3 @@ - - hosts: "{{ roles }}" tasks: @@ -7,32 +6,44 @@ shell: rm -rf /usr/share/doc/phoronix-test-suite/ shell: rm -rf /usr/share/phoronix-test-suite shell: rm -rf /root/photmp/ + - name: cleaning results file: path=/root/results state=absent + - name: make direc file: path=/root/photmp/ state=directory - - name: Fetch Phornonix + + - name: Fetch Phornonix shell: cd /root/photmp/ && wget https://www.dropbox.com/s/5kks513ozxy7vvs/phoronix-suite.tar.gz + - name: unarchive Phoronix shell: cd /root/photmp/ && tar -zxvf phoronix-suite.tar.gz + - name: Install Phornonix Dependencies shell: yum install php php-xml php-client php-process -y + - name: Install Phornonix - shell: cd /root/photmp/phoronix-test-suite-master/&&./install-sh + shell: cd /root/photmp/phoronix-test-suite-master/&&./install-sh + - name: batchSetup shell: phoronix-test-suite batch-setup + - name: install shell: phoronix-test-suite batch-install cachebench + - name: run - shell: phoronix-test-suite batch-run cachebench + shell: phoronix-test-suite batch-run cachebench + - name: making directory file: path=/root/results state=directory + - name: copying result to temp directory shell: cp -r /var/lib/phoronix-test-suite/test-results/* /root/results/ + - name: registering files shell: (cd /root/results/; find . -maxdepth 1 -type f) | cut -d'/' -f2 register: files_to_copy + - name: copy results fetch: src=/root/results/{{item}} dest={{workingdir}}/{{Dest_dir}}/cachebench - with_items: files_to_copy.stdout_lines - + with_items: "{{files_to_copy.stdout_lines}}" diff --git a/benchmarks/playbooks/dhrystone.yaml b/benchmarks/playbooks/dhrystone.yaml index 82b24dd1..d4fe07ea 100644 --- a/benchmarks/playbooks/dhrystone.yaml +++ b/benchmarks/playbooks/dhrystone.yaml @@ -1,23 +1,27 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: making dhrystone directory - file: path={{workingdir}}/{{Dest_dir}}/dhrystone/dhrystone_temp state=directory + file: path={{workingdir}}/{{Dest_dir}}/dhrystone state=directory + - name: making temporary dhrystone directory file: path={{workingdir}}/{{Dest_dir}}/dhrystone/dhrystone_temp state=directory - hosts: "{{role}}" become: yes remote_user: "{{username}}" + tasks: - - name: checking_home directory - shell: sudo echo $HOME + - name: checking home directory + shell: echo $HOME register: home_dir - name: cleaning tempT shell: sudo rm -rf $HOME/tempT - - name: cleaning_qtip_result + - name: cleaning qtip_result shell: sudo rm -rf $HOME/qtip_result - name: make directory @@ -40,7 +44,8 @@ - include: ./git_proxy_pbook.yaml - name: Clone unixbench - shell: git clone https://github.com/kdlucas/byte-unixbench.git $HOME/tempT + git: repo=https://github.com/kdlucas/byte-unixbench.git + dest=$HOME/tempT - name: make shell: sudo make --directory $HOME/tempT/UnixBench/ @@ -77,7 +82,7 @@ - name: copy results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/dhrystone/dhrystone_temp - with_items: files_to_copy.stdout_lines + with_items: "{{files_to_copy.stdout_lines}}" - name: registering log files shell: (cd $HOME/qtip_result/log/; find . -maxdepth 1 -name "*.log") | cut -d'/' -f2 @@ -85,7 +90,7 @@ - name: copying log results fetch: src={{home_dir.stdout}}/qtip_result/log/{{item}} dest={{workingdir}}/{{Dest_dir}}/dhrystone/dhrystone_temp - with_items: copy_log_results.stdout_lines + with_items: "{{copy_log_results.stdout_lines}}" - name: cleaning tempT shell: sudo rm -rf $HOME/tempT @@ -94,14 +99,19 @@ shell: sudo rm -rf $HOME/qtip_result - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/dhrystone/dhrystone_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/dhrystone/) + - name: making_logs_folder shell: mkdir -p {{workingdir}}/{{Dest_dir}}/dhrystone/logs + - name: extracting_log shell: ( find {{workingdir}}/{{Dest_dir}}/dhrystone/dhrystone_temp/ -name "*.log" | xargs cp -t {{workingdir}}/{{Dest_dir}}/dhrystone/logs) + - name: removing dhrystone_temp shell: rm -rf {{workingdir}}/{{Dest_dir}}/dhrystone/dhrystone_temp diff --git a/benchmarks/playbooks/dpi.yaml b/benchmarks/playbooks/dpi.yaml index f4e6de8d..6dae0869 100644 --- a/benchmarks/playbooks/dpi.yaml +++ b/benchmarks/playbooks/dpi.yaml @@ -1,19 +1,23 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: making dpi directory file: path={{workingdir}}/{{Dest_dir}}/dpi state=directory + - name: making temporary whetstone directory file: path={{workingdir}}/{{Dest_dir}}/dpi/dpi_temp state=directory - hosts: "{{role}}" become: yes remote_user: "{{username}}" + tasks: - name: echo shell: echo $USER - - name: checking_home directory + - name: checking home directory shell: echo $HOME register: home_dir @@ -46,7 +50,8 @@ - include: ./git_proxy_pbook.yaml - name: Clone nDPI - shell: cd $HOME/tempD && git clone https://github.com/ntop/nDPI.git + git: repo=https://github.com/ntop/nDPI.git + dest=$HOME/tempD - name: autogen shell: cd $HOME/tempD/nDPI && sudo ./autogen.sh @@ -55,7 +60,7 @@ shell: cd $HOME/tempD/nDPI && sudo ./configure - name: make - shell: cd $HOME/tempD/nDPI && sudo make + shell: cd $HOME/tempD/nDPI && sudo make - name: Fetching Test_pcap file shell: cd $HOME/tempD/nDPI/example && wget http://artifacts.opnfv.org/qtip/utilities/test.pcap @@ -87,7 +92,7 @@ - name: copy results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/dpi/dpi_temp - with_items: files_to_copy.stdout_lines + with_items: "{{files_to_copy.stdout_lines}}" - name: registering log files shell: (cd $HOME/qtip_result/; find . -maxdepth 1 -name "*.log") | cut -d'/' -f2 @@ -95,16 +100,21 @@ - name: copying log results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/dpi/dpi_temp - with_items: copy_log_results.stdout_lines + with_items: "{{copy_log_results.stdout_lines}}" - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/dpi/dpi_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/dpi/) + - name: making_logs_folder shell: mkdir -p {{workingdir}}/{{Dest_dir}}/dpi/logs + - name: extracting_log shell: ( find {{workingdir}}/{{Dest_dir}}/dpi/dpi_temp/ -name "*.log" | xargs cp -t {{workingdir}}/{{Dest_dir}}/dpi/logs) + - name: removing dpi_temp shell: rm -rf {{workingdir}}/{{Dest_dir}}/dpi/dpi_temp diff --git a/benchmarks/playbooks/fio.yaml b/benchmarks/playbooks/fio.yaml index 3de237f2..813dc411 100644 --- a/benchmarks/playbooks/fio.yaml +++ b/benchmarks/playbooks/fio.yaml @@ -1,8 +1,11 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: making fio directory file: path={{workingdir}}/{{Dest_dir}}/fio state=directory + - name: making temporary fio directory file: path={{workingdir}}/{{Dest_dir}}/fio/fio_temp state=directory @@ -10,8 +13,9 @@ - hosts: "{{role}}" become: yes remote_user: "{{username}}" + tasks: - - name: checking_home directory + - name: checking home directory shell: echo $HOME register: home_dir @@ -72,7 +76,7 @@ - name: copy results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/fio/fio_temp - with_items: files_to_copy.stdout_lines + with_items: "{{files_to_copy.stdout_lines}}" - name: registering log files shell: (cd $HOME/qtip_result/; find . -maxdepth 1 -name "*.log") | cut -d'/' -f2 @@ -80,17 +84,22 @@ - name: copying log results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/fio/fio_temp - with_items: copy_log_results.stdout_lines + with_items: "{{copy_log_results.stdout_lines}}" - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/fio/fio_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/fio/) + - name: making_logs_folder shell: mkdir -p {{workingdir}}/{{Dest_dir}}/fio/logs + - name: extracting_log shell: ( find {{workingdir}}/{{Dest_dir}}/fio/fio_temp/ -name "*.log" | xargs cp -t {{workingdir}}/{{Dest_dir}}/fio/logs) + - name: removing fio_log shell: rm -rf {{workingdir}}/{{Dest_dir}}/fio/fio_temp diff --git a/benchmarks/playbooks/git_proxy_pbook.yaml b/benchmarks/playbooks/git_proxy_pbook.yaml index 6d155a76..5cb6f450 100644 --- a/benchmarks/playbooks/git_proxy_pbook.yaml +++ b/benchmarks/playbooks/git_proxy_pbook.yaml @@ -1,4 +1,3 @@ - #git - name: set git proxy(http) shell: "git config --global http.proxy {{ http_proxy }}" diff --git a/benchmarks/playbooks/iperf.yaml b/benchmarks/playbooks/iperf.yaml index de1e5a4d..b6fd75c5 100644 --- a/benchmarks/playbooks/iperf.yaml +++ b/benchmarks/playbooks/iperf.yaml @@ -1,12 +1,15 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local - tasks: + gather_facts: no + tasks: - name: getting directory shell: sudo echo $PWD register: qtip_dir + - name: making Iperf directory file: path={{workingdir}}/{{Dest_dir}}/iperf state=directory + - name: making temporary iperf directory file: path={{workingdir}}/{{Dest_dir}}/iperf/iperf_temp state=directory @@ -14,6 +17,7 @@ - hosts: "{{role}}" become: yes remote_user: "{{username}}" + tasks: - name: Rolename set_fact: @@ -31,7 +35,7 @@ - name: echo shell: echo index_var - - name: checking_home directory + - name: checking home directory shell: echo $HOME register: home_dir @@ -44,7 +48,7 @@ - name: making Iperf temporary directory shell: sudo mkdir $HOME/iperf - - name: making results temporary directory + - name: making results temporary directory shell: sudo mkdir $HOME/qtip_result - include: ./sys_proxy_pbook.yaml @@ -128,23 +132,30 @@ when: rolename =="2-host" and "{{ip2}}" == '' - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: Rolename set_fact: rolename: "{{role}}" when: role is defined + - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/iperf/iperf_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/iperf/) when: rolename == "2-host" + - name: making_logs_folder shell: mkdir -p {{workingdir}}/{{Dest_dir}}/iperf/logs + - name: extracting_log shell: ( find {{workingdir}}/{{Dest_dir}}/iperf/iperf_temp/ -name "*.log" | xargs cp -t {{workingdir}}/{{Dest_dir}}/iperf/logs) when: rolename == "2-host" + - name: removing iperf_raw file shell: rm -rf {{workingdir}}/{{Dest_dir}}/iperf/iperf_raw.json when: rolename == "2-host" + - name: removing iperf_temp shell: rm -rf {{workingdir}}/{{Dest_dir}}/iperf/iperf_temp diff --git a/benchmarks/playbooks/netperf.yaml b/benchmarks/playbooks/netperf.yaml index 30f4b574..a07752cb 100644 --- a/benchmarks/playbooks/netperf.yaml +++ b/benchmarks/playbooks/netperf.yaml @@ -1,12 +1,15 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local - tasks: + gather_facts: no + tasks: - name: getting directory shell: echo $PWD register: qtip_dir + - name: making Netperf directory file: path={{workingdir}}/{{Dest_dir}}/netperf state=directory + - name: making temporary netperf directory file: path={{workingdir}}/{{Dest_dir}}/netperf/netperf_temp state=directory @@ -24,27 +27,36 @@ - name: Get Hostname shell: echo $HOSTNAME register: hostID - - name: checking_home directory + + - name: checking home directory shell: echo $HOME register: home_dir + - name: cleaning shell: rm -rf $HOME/netperf + - name: cleaning previous results shell: rm -rf $HOME/qtip_result + - name: making netperf temporary directory shell: mkdir $HOME/netperf + - name: making results temporary directory shell: mkdir $HOME/qtip_result - name: Fetching netperf shell: wget ftp://ftp.netperf.org/netperf/netperf-2.7.0.tar.gz when: ansible_os_family == "RedHat" + - name: Extracting Netperf shell: tar -xvf netperf-2.7.0.tar.gz + - name: configuring netperf shell: cd $HOME/netperf-2.7.0 && ./configure + - name: Making Netperf shell: cd $HOME/netperf-2.7.0 && make + - name: Installing Netperf shell: cd $HOME/netperf-2.7.0 && make install @@ -62,18 +74,24 @@ - name: Files to Copy shell: (cd $HOME/qtip_result/; find . -maxdepth 1 -name "*.json") | cut -d'/' -f2 register: files_to_copy + - name: copy results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/netperf/netperf_temp - with_items: files_to_copy.stdout_lines - - hosts: 127.0.0.1 + with_items: "{{files_to_copy.stdout_lines}}" + + - hosts: localhost connection: local + gather_facts: no + tasks: - name: Rolename set_fact: rolename: "{{role}}" when: role is defined + - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/netperf/netperf_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/netperf/) when: rolename == "2-host" + - name: removing netperf_temp - shell: rm -rf {{workingdir}}/{{Dest_dir}}/netperf/netperf_temp
\ No newline at end of file + shell: rm -rf {{workingdir}}/{{Dest_dir}}/netperf/netperf_temp diff --git a/benchmarks/playbooks/pktgen.yaml b/benchmarks/playbooks/pktgen.yaml index 466fb8e9..f466129b 100644 --- a/benchmarks/playbooks/pktgen.yaml +++ b/benchmarks/playbooks/pktgen.yaml @@ -1,17 +1,21 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local - tasks: + gather_facts: no + tasks: - name: getting directory shell: echo $PWD register: qtip_dir + - name: making pktgen directory file: path={{workingdir}}/{{Dest_dir}}/pktgen state=directory + - name: making temporary pktgen directory file: path={{workingdir}}/{{Dest_dir}}/pktgen/pktgen_temp state=directory - hosts: "{{role}}" + tasks: - name: Rolename set_fact: @@ -21,18 +25,23 @@ - name: IPTABLE Setup shell: iptables -F when: rolename == '1-server' + - name: iptables shell: sudo iptables -A INPUT -p udp --dport 1000 -j DROP when: rolename == '1-server' + - name: run pktgen shell: bash pktgen.sh {{privateip1}} 1 {{packetsize}} {{duration}} >> .json when: rolename == '2-host' + - hosts: "{{role}}" + tasks: - name: Rolename set_fact: rolename: "{{role}}" when: role is defined + - name: Get server packetsize shell: iptables -L -vnx >> pktgenServer{{privateip1}}.txt - when: rolename == '1-server'
\ No newline at end of file + when: rolename == '1-server' diff --git a/benchmarks/playbooks/ramspeed.yaml b/benchmarks/playbooks/ramspeed.yaml index 096c7320..3fb78cb5 100644 --- a/benchmarks/playbooks/ramspeed.yaml +++ b/benchmarks/playbooks/ramspeed.yaml @@ -1,8 +1,11 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: making ramspeed directory file: path={{workingdir}}/{{Dest_dir}}/ramspeed state=directory + - name: making temporary ramspeed directory file: path={{workingdir}}/{{Dest_dir}}/ramspeed/ramspeed_temp state=directory @@ -10,8 +13,9 @@ - hosts: "{{role}}" become: yes remote_user: "{{username}}" + tasks: - - name: checking_home directory + - name: checking home directory shell: echo $HOME register: home_dir @@ -77,7 +81,7 @@ - name: copy results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/ramspeed/ramspeed_temp - with_items: files_to_copy.stdout_lines + with_items: "{{files_to_copy.stdout_lines}}" - name: registering log files shell: (cd $HOME/qtip_result/; find . -maxdepth 1 -name "*.log") | cut -d'/' -f2 @@ -85,16 +89,21 @@ - name: copying log results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/ramspeed/ramspeed_temp - with_items: copy_log_results.stdout_lines + with_items: "{{copy_log_results.stdout_lines}}" - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/ramspeed/ramspeed_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/ramspeed/) + - name: making_logs_folder shell: mkdir -p {{workingdir}}/{{Dest_dir}}/ramspeed/logs + - name: extracting_log shell: ( find {{workingdir}}/{{Dest_dir}}/ramspeed/ramspeed_temp/ -name "*.log" | xargs cp -t {{workingdir}}/{{Dest_dir}}/ramspeed/logs) + - name: removing ramspeed_log shell: rm -rf {{workingdir}}/{{Dest_dir}}/ramspeed/ramspeed_temp diff --git a/benchmarks/playbooks/ssl.yaml b/benchmarks/playbooks/ssl.yaml index fcb7585c..55e0af9b 100644 --- a/benchmarks/playbooks/ssl.yaml +++ b/benchmarks/playbooks/ssl.yaml @@ -1,15 +1,20 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: making ssl directory file: path={{workingdir}}/{{Dest_dir}}/ssl state=directory + - name: making temporary ssl directory file: path={{workingdir}}/{{Dest_dir}}/ssl/ssl_temp state=directory + - hosts: "{{role}}" become: yes remote_user: "{{username}}" + tasks: - - name: checking_home directory + - name: checking home directory shell: sudo echo $HOME register: home_dir @@ -32,11 +37,11 @@ network: false - name: Installing OpenSSL dependencies when CentOS - shell: sudo yum install git wget gcc patch perl-Time-HiRes autofconf automake libpcap-devel libtool -y + shell: sudo yum install git wget gcc patch perl-Time-HiRes autofconf automake libpcap-devel libtool -y when: ansible_os_family == "RedHat" - name: Installing OpenSSL dependencies when Ubuntu - shell: sudo apt-get install git gcc wget perl autoconf automake libpcap-dev libtool -y + shell: sudo apt-get install git gcc wget perl autoconf automake libpcap-dev libtool -y when: ansible_os_family == "Debian" - name: Fetching OpenSSL @@ -59,7 +64,6 @@ - name: Benchmaring AES-128-cbc cipher encryption throughput shell: cd $HOME/Open_SSL/openssl-1.0.2f/apps && sudo ./openssl speed -evp aes-128-cbc >> $HOME/qtip_result/AES-128-CBC_dump - - name: Fetching result transformation script copy: src=./result_transform/ssl/ssl_transform.py dest={{home_dir.stdout}}/qtip_result @@ -78,7 +82,7 @@ - name: copy results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/ssl/ssl_temp - with_items: files_to_copy.stdout_lines + with_items: "{{files_to_copy.stdout_lines}}" - name: registering log files shell: (cd $HOME/qtip_result/; find . -maxdepth 1 -name "*.log") | cut -d'/' -f2 @@ -86,19 +90,24 @@ - name: copying log results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/ssl/ssl_temp - with_items: copy_log_results.stdout_lines - + with_items: "{{copy_log_results.stdout_lines}}" - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: echo shell: echo $PWD + - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/ssl/ssl_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/ssl/) + - name: making_logs_folder shell: mkdir -p {{workingdir}}/{{Dest_dir}}/ssl/logs + - name: extracting_log shell: ( find {{workingdir}}/{{Dest_dir}}/ssl/ssl_temp/ -name "*.log" | xargs cp -t {{workingdir}}/{{Dest_dir}}/ssl/logs) + - name: removing ssl_temp shell: rm -rf {{workingdir}}/{{Dest_dir}}/ssl/ssl_temp diff --git a/benchmarks/playbooks/sys_info_pbook.yaml b/benchmarks/playbooks/sys_info_pbook.yaml index bc47423f..cfcad119 100644 --- a/benchmarks/playbooks/sys_info_pbook.yaml +++ b/benchmarks/playbooks/sys_info_pbook.yaml @@ -40,8 +40,3 @@ - name: collecting system information for network test cases shell: cd $HOME/qtip_result && sudo python info_collect.py n when: network - - - - - diff --git a/benchmarks/playbooks/whetstone.yaml b/benchmarks/playbooks/whetstone.yaml index efe78cfd..98280e6a 100644 --- a/benchmarks/playbooks/whetstone.yaml +++ b/benchmarks/playbooks/whetstone.yaml @@ -1,5 +1,7 @@ - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: making whetstone directory file: path={{workingdir}}/{{Dest_dir}}/whetstone state=directory @@ -10,6 +12,7 @@ - hosts: "{{role}}" become: yes remote_user: "{{username}}" + tasks: - name: storing_home shell: echo $HOME @@ -41,7 +44,8 @@ - include: ./git_proxy_pbook.yaml - name: Clone unixbench - shell: git clone https://github.com/kdlucas/byte-unixbench.git $HOME/tempT + git: repo=https://github.com/kdlucas/byte-unixbench.git + dest=$HOME/tempT - name: make shell: sudo make --directory $HOME/tempT/UnixBench/ @@ -79,7 +83,7 @@ - name: copy results fetch: src={{home_dir.stdout}}/qtip_result/{{item}} dest={{workingdir}}/{{Dest_dir}}/whetstone/whetstone_temp - with_items: files_to_copy.stdout_lines + with_items: "{{files_to_copy.stdout_lines}}" - name: registering log files shell: (cd $HOME/qtip_result/log/; find . -maxdepth 1 -name "*.log") | cut -d'/' -f2 @@ -87,7 +91,7 @@ - name: copying log results fetch: src={{home_dir.stdout}}/qtip_result/log/{{item}} dest={{workingdir}}/{{Dest_dir}}/whetstone/whetstone_temp - with_items: copy_log_results.stdout_lines + with_items: "{{copy_log_results.stdout_lines}}" - name: cleaning tempT shell: sudo rm -rf $HOME/tempT @@ -95,9 +99,10 @@ - name: cleaning_qtip_result shell: sudo rm -rf $HOME/qtip_result - - - hosts: 127.0.0.1 + - hosts: localhost connection: local + gather_facts: no + tasks: - name: extracting_json shell: ( find {{workingdir}}/{{Dest_dir}}/whetstone/whetstone_temp/ -name "*.json" | xargs cp -t {{workingdir}}/{{Dest_dir}}/whetstone/) diff --git a/data/qtip_creds.sh b/data/qtip_creds.sh index 6f19305a..beb4659f 100755 --- a/data/qtip_creds.sh +++ b/data/qtip_creds.sh @@ -3,7 +3,7 @@ DEST_IP=$1 echo $INSTALLER_TYPE echo $INSTALLER_IP -sshoptions="-o StrictHostKeyChecking=no" +sshoptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" case "$INSTALLER_TYPE" in apex) scp $sshoptions -i $APEX_KEY ./data/QtipKey.pub stack@$INSTALLER_IP:/home/stack @@ -14,7 +14,7 @@ case "$INSTALLER_TYPE" in PSWD="r00tme" sshpass -p $PSWD scp $sshoptions ./data/QtipKey.pub root@$INSTALLER_IP:/root sshpass -p $PSWD scp $sshoptions ./data/QtipKey root@$INSTALLER_IP:/root - sshpass -p $PSWD ssh $sshoptions root@$INSTALLER_IP "grep -q '\-F /dev/null ' /usr/bin/ssh-copy-id || sed -i 's/\(ssh -i.*$\)/\1\n -F \/dev\/null \\\/g' `which ssh-copy-id`" + sshpass -p $PSWD ssh $sshoptions root@$INSTALLER_IP "grep -q '\-F /dev/null ' /usr/bin/ssh-copy-id || sed -i 's/\(ssh -i.*$\)/\1\n -F \/dev\/null \\\/g' `which ssh-copy-id`" sshpass -p $PSWD ssh $sshoptions root@$INSTALLER_IP "ssh-copy-id $sshoptions -i /root/QtipKey root@$DEST_IP && rm -rf /root/QtipKey && rm -rf /root/QtipKey.pub" ;; compass) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9ed0980e..2adeba6e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -45,12 +45,15 @@ RUN mkdir -p ${REPOS_DIR} RUN mkdir -p /root/.ssh RUN chmod 700 /root/.ssh +#Config ansible +COPY ansible.cfg.default /root/.ansible.cfg + #Cloning Repos RUN git config --global http.sslVerify false RUN git clone https://gerrit.opnfv.org/gerrit/qtip $REPOS_DIR/qtip RUN git clone https://gerrit.opnfv.org/gerrit/releng $REPOS_DIR/releng -RUN pip install -r $REPOS_DIR/qtip/docker/packages.pip +RUN pip install -r $REPOS_DIR/qtip/requirements.txt diff --git a/docker/ansible.cfg.default b/docker/ansible.cfg.default new file mode 100644 index 00000000..0451870a --- /dev/null +++ b/docker/ansible.cfg.default @@ -0,0 +1,2 @@ +[defaults] +callback_whitelist = profile_tasks diff --git a/docker/packages.pip b/docker/packages.pip deleted file mode 100644 index cc048389..00000000 --- a/docker/packages.pip +++ /dev/null @@ -1,8 +0,0 @@ -pyyaml==3.10 -python-neutronclient==2.6.0 -python-novaclient==2.28.1 -python-glanceclient==1.1.0 -python-cinderclient==1.4.0 -python-heatclient==0.6.0 -python-keystoneclient==1.6.0 -reportlab==3.0 diff --git a/func/args_handler.py b/func/args_handler.py index f2726eb8..57ecfcbd 100644 --- a/func/args_handler.py +++ b/func/args_handler.py @@ -48,12 +48,15 @@ def prepare_ansible_env(benchmark_test_case): return benchmark, benchmark_details, proxy_info, env_setup -def run_benchmark(benchmark, benchmark_details, proxy_info, env_setup, benchmark_test_case): +def run_benchmark(installer_type, pwd, benchmark, benchmark_details, + proxy_info, env_setup, benchmark_test_case): driver = Driver() - driver.drive_bench(benchmark, env_setup.roles_dict.items(), _get_f_name(benchmark_test_case), + driver.drive_bench(installer_type, pwd, benchmark, + env_setup.roles_dict.items(), _get_f_name(benchmark_test_case), benchmark_details, env_setup.ip_pw_dict.items(), proxy_info) -def prepare_and_run_benchmark(benchmark_test_case): +def prepare_and_run_benchmark(installer_type, pwd, benchmark_test_case): benchmark, benchmark_details, proxy_info, env_setup = prepare_ansible_env(benchmark_test_case) - run_benchmark(benchmark, benchmark_details, proxy_info, env_setup, benchmark_test_case) + run_benchmark(installer_type, pwd, benchmark, benchmark_details, + proxy_info, env_setup, benchmark_test_case) diff --git a/func/cli.py b/func/cli.py index 01694a9b..66ab2277 100644 --- a/func/cli.py +++ b/func/cli.py @@ -8,6 +8,7 @@ ############################################################################## import sys +import os import args_handler import argparse @@ -37,12 +38,12 @@ class cli: args = self._parse_args(args) if not args_handler.check_suit_in_test_list(args.file): - print '\n\n ERROR: Test File Does not exist in test_list/ please enter correct file \n\n' + print('\n\n ERROR: Test File Does not exist in test_list/ please enter correct file \n\n') sys.exit(0) if not args_handler.check_lab_name(args.lab): - print '\n\n You have specified a lab that is not present in test_cases/ please enter \ - correct file. If unsure how to proceed, use -l default.\n\n' + print('\n\n You have specified a lab that is not present in test_cases/ please enter \ + correct file. If unsure how to proceed, use -l default.\n\n') sys.exit(0) suite = args.file benchmarks = args_handler.get_files_in_test_list(suite) @@ -50,6 +51,7 @@ class cli: benchmarks_list = filter(lambda x: x in test_cases, benchmarks) map(lambda x: args_handler.prepare_and_run_benchmark( + os.environ['INSTALLER_TYPE'], os.environ['PWD'], args_handler.get_benchmark_path(args.lab.lower(), suite, x)), benchmarks_list) print('{0} is not a Template in the Directory Enter a Valid file name.' diff --git a/func/driver.py b/func/driver.py index f26f63db..859e7f34 100644 --- a/func/driver.py +++ b/func/driver.py @@ -6,9 +6,8 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import os -import json import logging +from func.ansible_api import AnsibleApi class Driver: @@ -30,14 +29,15 @@ class Driver: z.update(y) return z - def get_common_var_json(self, benchmark_fname, benchmark_detail, pip_dict, proxy_info): + def get_common_var_json(self, installer_type, pwd, benchmark_fname, + benchmark_detail, pip_dict, proxy_info): common_json = {'Dest_dir': 'results', 'ip1': '', 'ip2': '', - 'installer': str(os.environ['INSTALLER_TYPE']), - 'workingdir': str(os.environ['PWD']), + 'installer': str(installer_type), + 'workingdir': str(pwd), 'fname': str(benchmark_fname), - 'username': self.installer_username[str(os.environ['INSTALLER_TYPE'])]} + 'username': self.installer_username[str(installer_type)]} common_json.update(benchmark_detail) if benchmark_detail else None common_json.update(proxy_info) if proxy_info else None return common_json @@ -54,18 +54,19 @@ class Driver: return special_json def run_ansible_playbook(self, benchmark, extra_vars): - extra_vars_json = json.dumps(dict(extra_vars.items())) - logging.info(extra_vars_json) - run_play = 'ansible-playbook ./benchmarks/playbooks/{0}.yaml' \ - '--private-key=./data/QtipKey -i ./data/hosts --extra-vars \'{1}\'' \ - .format(benchmark, extra_vars_json) - os.system(run_play) + logging.info(extra_vars) + ansible_api = AnsibleApi() + ansible_api.execute_playbook('./data/hosts', + './benchmarks/playbooks/{0}.yaml'.format(benchmark), + './data/QtipKey', extra_vars) + return ansible_api.get_detail_playbook_stats() - def drive_bench(self, benchmark, roles, benchmark_fname, + def drive_bench(self, installer_type, pwd, benchmark, roles, benchmark_fname, benchmark_detail=None, pip_dict=None, proxy_info=None): roles = sorted(roles) pip_dict = sorted(pip_dict) - var_json = self.get_common_var_json(benchmark_fname, benchmark_detail, pip_dict, proxy_info) + var_json = self.get_common_var_json(installer_type, pwd, benchmark_fname, + benchmark_detail, pip_dict, proxy_info) map(lambda role: self.run_ansible_playbook (benchmark, self.merge_two_dicts(var_json, self.get_special_var_json(role, roles, diff --git a/func/env_setup.py b/func/env_setup.py index ea49337d..f6b1d43b 100644 --- a/func/env_setup.py +++ b/func/env_setup.py @@ -54,55 +54,36 @@ class Env_setup: num = len(role[k]) for x in range(num): f_name_2.write(role[k][x] + '\n') + f_name_2.write('[localhost]\n') + f_name_2.write('127.0.0.1\n') f_name_2.close() @staticmethod - def ssh_test(lister): - print 'list: ', lister - for k, v in lister: - ip_var = k - print '\nBeginning SSH Test!\n' - if v != '': - print ('\nSSH->>>>> {0} {1}\n'.format(k, v)) - time.sleep(2) - - ssh_c = 'ssh-keyscan {0} >> ~/.ssh/known_hosts'.format(k) - os.system(ssh_c) - ssh_cmd = './data/qtip_creds.sh {0}'.format(ip_var) - print ssh_cmd - os.system(ssh_cmd) - for infinity in range(100): - try: - ssh = paramiko.SSHClient() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(k, key_filename='./data/QtipKey') - stdin, stdout, stderr = ssh.exec_command('ls') + def ssh_test(hosts): + for ip, pw in hosts: + print '\nBeginning SSH Test: %s \n' % ip + os.system('ssh-keyscan %s >> ~/.ssh/known_hosts' % ip) + time.sleep(2) + + ssh_cmd = './data/qtip_creds.sh %s' % ip + print "run command: %s " % ssh_cmd + os.system(ssh_cmd) + + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(ip, key_filename='./data/QtipKey') + + for attempts in range(100): + try: + stdin, stdout, stderr = ssh.exec_command('uname') + if not stderr.readlines(): print('SSH successful') - for line in stdout: - print '... ' + line.strip('\n') break - except socket.error: - print 'Retrying aSSH %s' % infinity - time.sleep(1) - if v == '': - print ('SSH->>>>>', k) - ssh_c = 'ssh-keyscan {0} >> ~/.ssh/known_hosts'.format(k) - - time.sleep(3) - os.system(ssh_c) - - for infinity in range(10): - try: - ssh = paramiko.SSHClient() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(k, key_filename='./data/QtipKey') - stdin, stdout, stderr = ssh.exec_command('ls') - print('SSH successful') - for line in stdout: - print '... ' + line.strip('\n') - break - except socket.error: - print 'Retrying SSH %s' % infinity + except socket.error: + print 'SSH is still unavailable, retry!' + time.sleep(2) + if attempts == 99: + print "Try 99 times, SSH failed: %s" % ip @staticmethod def ping_test(lister, attempts=30): diff --git a/tests/args_handler_test.py b/tests/args_handler_test.py index 7f977f21..ebf500f3 100644 --- a/tests/args_handler_test.py +++ b/tests/args_handler_test.py @@ -13,8 +13,8 @@ import func.args_handler class TestClass: @pytest.mark.parametrize("test_input, expected", [ - ('./test_cases/zte-pod1/network/iperf_bm.yaml', - ["iperf", + (['fuel', '/home', './test_cases/zte-pod1/network/iperf_bm.yaml'], + ['fuel', '/home', "iperf", [('1-server', ['10.20.0.23']), ('2-host', ['10.20.0.24'])], "iperf_bm.yaml", [('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 10)], @@ -29,7 +29,7 @@ class TestClass: mock_env_setup_ssh, mock_update_ansible, test_input, expected): mock_ips = mock.Mock(return_value=["10.20.0.23", "10.20.0.24"]) func.args_handler.Env_setup.fetch_compute_ips = mock_ips - func.args_handler.prepare_and_run_benchmark(test_input) + func.args_handler.prepare_and_run_benchmark(test_input[0], test_input[1], test_input[2]) call = mock_driver.call_args call_args, call_kwargs = call assert sorted(map(sorted, call_args)) == sorted(map(sorted, expected)) diff --git a/tests/cli_test.py b/tests/cli_test.py index f9861dee..fe05327d 100644 --- a/tests/cli_test.py +++ b/tests/cli_test.py @@ -1,5 +1,6 @@ import pytest import mock +import os from func.cli import cli @@ -15,8 +16,11 @@ class TestClass: 'test'], "Test File Does not exist in test_list") ]) def test_cli_error(self, capfd, test_input, expected): + k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'}) with pytest.raises(SystemExit): + k.start() cli(test_input) + k.stop() resout, reserr = capfd.readouterr() assert expected in resout @@ -24,11 +28,14 @@ class TestClass: (['-l', 'zte-pod1', '-f', - 'storage'], [('./test_cases/zte-pod1/storage/fio_bm.yaml'), - ('./test_cases/zte-pod1/storage/fio_vm.yaml')]) + 'storage'], [('fuel', '/home', './test_cases/zte-pod1/storage/fio_bm.yaml'), + ('fuel', '/home', './test_cases/zte-pod1/storage/fio_vm.yaml')]) ]) @mock.patch('func.cli.args_handler.prepare_and_run_benchmark') def test_cli_successful(self, mock_args_handler, test_input, expected): + k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': 'fuel', 'PWD': '/home'}) + k.start() cli(test_input) - call_list = map(lambda x: mock_args_handler.call_args_list[x][0][0], range(len(expected))) + k.stop() + call_list = map(lambda x: mock_args_handler.call_args_list[x][0], range(len(expected))) assert sorted(call_list) == sorted(expected) diff --git a/tests/driver_test.py b/tests/driver_test.py index a5b13588..71f01b0e 100644 --- a/tests/driver_test.py +++ b/tests/driver_test.py @@ -1,21 +1,20 @@ import pytest import mock -import os -import json from func.driver import Driver class TestClass: @pytest.mark.parametrize("test_input, expected", [ - (["iperf", + (['fuel', + '/home', + "iperf", [('host', ['10.20.0.13', '10.20.0.15'])], "iperf_bm.yaml", [('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 0)], [("10.20.0.13", [None]), ("10.20.0.15", [None])], {'http_proxy': 'http://10.20.0.1:8118', 'https_proxy': 'http://10.20.0.1:8118', - 'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*'}, - 'fuel'], + 'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*'}], [{'Dest_dir': 'results', 'ip1': '', 'ip2': '', @@ -30,13 +29,14 @@ class TestClass: 'protocol': 'tcp', 'bandwidthGbps': 0, "role": "host"}]), - (["iperf", + (['joid', + '/home', + "iperf", [('1-server', ['10.20.0.13']), ('2-host', ['10.20.0.15'])], "iperf_vm.yaml", [('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 0)], [("10.20.0.13", [None]), ("10.20.0.15", [None])], - {}, - 'joid'], + {}], [{'Dest_dir': 'results', 'ip1': '10.20.0.13', 'ip2': '', @@ -61,18 +61,14 @@ class TestClass: 'bandwidthGbps': 0, "role": "2-host"}]) ]) - @mock.patch('func.driver.os.system') - def test_driver_success(self, mock_system, test_input, expected): - mock_system.return_value = True - k = mock.patch.dict(os.environ, {'INSTALLER_TYPE': test_input[6], 'PWD': '/home'}) - k.start() + @mock.patch('func.driver.AnsibleApi') + def test_driver_success(self, mock_ansible, test_input, expected): + mock_ansible.execute_playbook.return_value = True dri = Driver() - dri.drive_bench(test_input[0], test_input[1], test_input[2], test_input[3], test_input[4], test_input[5]) - call_list = mock_system.call_args_list - k.stop() - print call_list + dri.drive_bench(test_input[0], test_input[1], test_input[2], test_input[3], + test_input[4], test_input[5], test_input[6], test_input[7]) + call_list = mock_ansible.execute_playbook.call_args_list for call in call_list: call_args, call_kwargs = call - real_call = call_args[0].split('extra-vars \'')[1] - real_call = real_call[0: len(real_call) - 1] - assert json.loads(real_call) == json.loads(json.dumps(expected[call_list.index(call)])) + real_call = call_args[3] + assert real_call == expected[call_list.index(call)] diff --git a/tests/output/hosts b/tests/output/hosts index 9b47df0e..b380e475 100644 --- a/tests/output/hosts +++ b/tests/output/hosts @@ -1,3 +1,5 @@ [host] 10.20.0.29 10.20.0.28 +[localhost] +127.0.0.1 diff --git a/tests/schema/test_bm_schema.yaml b/tests/schema/test_bm_schema.yaml index 740725f5..a7c27e3f 100644 --- a/tests/schema/test_bm_schema.yaml +++ b/tests/schema/test_bm_schema.yaml @@ -45,6 +45,7 @@ mapping: type: str ip: type: str + allowempty: True pw: type: str allowempty: True |