Save logs before collecting 77/33677/2
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Sun, 23 Apr 2017 11:37:16 +0000 (19:37 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Mon, 24 Apr 2017 00:53:40 +0000 (08:53 +0800)
Change-Id: I0e39103ef917fa7ea86d5c47de0cc71c37fca74c
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
qtip/ansible_library/plugins/action/collect.py
resources/ansible_roles/inxi/tasks/main.yml
resources/ansible_roles/nDPI/tasks/main.yml
resources/ansible_roles/openssl/tasks/main.yml
resources/ansible_roles/ramspeed/tasks/main.yml

index f6ae7a5..88ad0e3 100644 (file)
@@ -10,7 +10,6 @@
 ##############################################################################
 
 from collections import defaultdict
-import os
 import re
 
 from ansible.plugins.action import ActionBase
@@ -27,12 +26,6 @@ class ActionModule(ActionBase):
         string = self._task.args.get('string')
         patterns = self._task.args.get('patterns')
 
-        dump = self._task.args.get('dump')
-        if dump is not None:
-            root = task_vars.get('qtip_results', 'results')
-            base = task_vars.get('dump_base', 'dump')
-            dump_facts([{'name': dump, 'content': string}], root, base)
-
         return collect(patterns, string)
 
 
@@ -50,11 +43,3 @@ def collect(patterns, string):
                 captured[key].append(value)
 
     return captured
-
-
-def dump_facts(facts, root, base):
-    dest = os.path.join(root, base)
-    if not os.path.exists(dest):
-        os.makedirs(dest)
-    return [{'name': fact['name'], 'result': open(os.path.join(dest, fact['name']), 'w+').write(fact['content'])}
-            for fact in facts]
index 0267b68..6d041e3 100644 (file)
   command: inxi -b -c0 -n
   register: inxi_out
 
+- name: generating log filename
+  set_fact:
+    logfile: "{{ qtip_results }}/inxi.log"
+
+- name: saving output to log
+  copy:
+    content: "{{ inxi_out.stdout }}"
+    dest: "{{ logfile }}"
+  delegate_to: localhost
+
 # TODO(yujunz) normalize system information, test condition and performance metrics for future data mining
 # e.g. convert "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz" to
 # ---
@@ -31,7 +41,7 @@
 #   cache_mb: None
 - name: collect system information from inxi
   collect:
-    string: "{{ inxi_out.stdout }}"
+    string: "{{ lookup('file', logfile) }}"
     patterns:
       - '.+\s+Host:\s+(?P<hostname>.+)\sKernel'
       - '.+\sMemory:\s+(?P<memory>.+MB)\s'
@@ -42,6 +52,7 @@
       - '.+\sproduct:\s+(?P<product>.+)\sv'
     dump: 'inix.log'
   register: system_info
+  delegate_to: localhost
 
 - name: create system information report
   template:
index e8d359e..230ee2e 100644 (file)
     checksum: "sha256:ac5d1501d91a6d8a8d3bfcef6f74a87bf660cd2c2ab11b9791535aa5193e4f71"
     validate_certs: no  # required when using proxy for https
 
-- name:
+- name: measuring dpi performance
   command: "./ndpiReader -i {{ sample_pcap }}"
   args:
     chdir: "{{ workdir }}/nDPI-1.6/example/"
   register: ndpi_out
 
-- name: collect DPI metrics from nDPI
+- name: generating log filename
+  set_fact:
+    logfile: "{{ qtip_results }}/nDPI.log"
+
+- name: saving output to log
+  copy:
+    content: "{{ ndpi_out.stdout }}"
+    dest: "{{ logfile }}"
+  delegate_to: localhost
+
+- name: collecting DPI metrics
   collect:
-    string: "{{ ndpi_out.stdout }}"
+    string: "{{ lookup('file', logfile) }}"
     patterns:
       #        nDPI throughput:       1.46 M pps / 13.69 Gb/sec
       # TODO(yujunz) convert "M pps" and "K pps" to number
       - 'nDPI throughput:\s+?(?P<dpi_pps>\d+.\d+.*) \/ (?P<dpi_bps>\d+.\d+.*)$'
-    dump: 'nDPI.log'
   register: dpi_metrics
+  delegate_to: localhost
 
 - name: create dpi report
   template:
     src: dpi-metrics.j2
     dest: "{{ qtip_results }}/dpi-metrics"
   delegate_to: localhost
-  tags: [report]
index 864d094..9829de2 100644 (file)
 
 - name: RSA signatures speed measurement
   command: openssl speed rsa
-  register: openssl_rsa_log
+  register: openssl_rsa_out
 
 - name: AES speed measurement
   command: openssl speed -evp aes-128-cbc
-  register: openssl_aes_log
+  register: openssl_aes_out
+
+
+- name: generating log filename
+  set_fact:
+    rsa_logfile: "{{ qtip_results }}/openssl_rsa.log"
+    aes_logfile: "{{ qtip_results }}/openssl_aes.log"
+
+# TODO(yujunz) `delegate_to` not working under `with_items`
+- name: saving rsa output to log
+  copy:
+    content: "{{ openssl_rsa_out.stdout }}"
+    dest: "{{ rsa_logfile }}"
+  delegate_to: localhost
+
+- name: saving aes output to log
+  copy:
+    content: "{{ openssl_aes_out.stdout }}"
+    dest: "{{ aes_logfile }}"
+  delegate_to: localhost
 
 - name: collect ssl rsa metrics
   collect:
-    string: "{{ openssl_rsa_log.stdout }}"
+    string: "{{ lookup('file', rsa_logfile) }}"
     patterns:
       - |-
           ^rsa\s+512\sbits\s.+\s+
           ^rsa\s+4096\sbits\s.+\s+
           ?(?P<rsa_sign_4096>\d+\.\d)\s+
           ?(?P<rsa_verify_4096>\d+\.\d)$
-    dump: openssl_rsa.log
   register: ssl_rsa_metrics
 
 - name: collect ssl aes metrics
   collect:
-    string: "{{ openssl_aes_log.stdout }}"
+    string: "{{ lookup('file', aes_logfile) }}"
     patterns:
       - |-
           ^aes-128-cbc\s+
index 2ecf427..bdb23b6 100644 (file)
   file:
     path: "{{ workdir }}"
     state: directory
-  tags: [setup]
 
 - 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/)
   args:
     chdir: "{{ workdir }}/ramsmp-3.5.0"
     creates: ramsmp
-  tags: [setup]
 
 - name: intmem benchmarking
   command: ./ramsmp -b 3 -l 5 -p 1
   args:
     chdir: "{{ workdir }}/ramsmp-3.5.0"
-  register: ramsmp_intmem_out
-  tags: [run]
+  register: ramsmp_int_out
 
 - name: floatmem benchmarking
   command: ./ramsmp -b 6 -l 5 -p 1
   args:
     chdir: "{{ workdir }}/ramsmp-3.5.0"
-  register: ramsmp_floatmem_out
-  tags: [run]
+  register: ramsmp_float_out
+
+- name: generating log filename
+  set_fact:
+    int_logfile: "{{ qtip_results }}/ramsmp-int.log"
+    float_logfile: "{{ qtip_results }}/ramsmp-float.log"
+
+- name: saving integer output to log
+  copy:
+    content: "{{ ramsmp_int_out.stdout }}"
+    dest: "{{ int_logfile }}"
+  delegate_to: localhost
+
+- name: saving floating point output to log
+  copy:
+    content: "{{ ramsmp_float_out.stdout }}"
+    dest: "{{ float_logfile }}"
+  delegate_to: localhost
 
 - name: collect integer memory metrics from ramspeed
   collect:
-    string: "{{ ramsmp_intmem_out.stdout }}"
+    string: "{{ lookup('file', int_logfile) }}"
     patterns:
       - '^INTEGER\s+BatchRun\s+Copy:\s+?(?P<copy>\d+\.\d+)\sMB/s$'
       - '^INTEGER\s+BatchRun\s+Scale:\s+?(?P<scale>\d+\.\d+)\sMB/s$'
       - '^INTEGER\s+BatchRun\s+Add:\s+?(?P<add>\d+\.\d+)\sMB/s$'
       - '^INTEGER\s+BatchRun\s+Triad:\s+?(?P<triad>\d+\.\d+)\sMB/s$'
       - '^INTEGER\s+BatchRun\s+AVERAGE:\s+?(?P<average>\d+\.\d+)\sMB/s$'
-    dump: 'ramsmp-intmem.log'
   register: intmem_metrics
-  tags: [collect]
 
 - name: collect float memory metrics from ramspeed
   collect:
-    string: "{{ ramsmp_floatmem_out.stdout }}"
+    string: "{{ lookup('file', float_logfile) }}"
     patterns:
       - '^FL-POINT\s+BatchRun\s+Copy:\s+?(?P<copy>\d+\.\d+)\sMB/s$'
       - '^FL-POINT\s+BatchRun\s+Scale:\s+?(?P<scale>\d+\.\d+)\sMB/s$'
       - '^FL-POINT\s+BatchRun\s+Add:\s+?(?P<add>\d+\.\d+)\sMB/s$'
       - '^FL-POINT\s+BatchRun\s+Triad:\s+?(?P<triad>\d+\.\d+)\sMB/s$'
       - '^FL-POINT\s+BatchRun\s+AVERAGE:\s+?(?P<average>\d+\.\d+)\sMB/s$'
-    dump: 'ramsmp-floatmem.log'
   register: floatmem_metrics
-  tags: [collect]
 
 - name: create memory metrics report
   template:
     src: "memory-metrics.j2"
     dest: "{{ qtip_results }}/memory-metrics"
   delegate_to: localhost
-  tags: [report]