add system_info and condition to qpi report 05/35705/4
authorzhihui wu <wu.zhihui1@zte.com.cn>
Fri, 2 Jun 2017 08:07:24 +0000 (16:07 +0800)
committerzhihui wu <wu.zhihui1@zte.com.cn>
Tue, 6 Jun 2017 08:05:36 +0000 (16:05 +0800)
According to the part "system_info" and "condition" in spec, gather
these data and add them to qpi report.

Change-Id: I5efc996c2bfb34452e9aa323d8288c1dd2d8d276
Signed-off-by: zhihui wu <wu.zhihui1@zte.com.cn>
qtip/ansible_library/plugins/action/calculate.py
resources/QPI/compute-baseline.json
resources/QPI/compute.yaml
resources/ansible_roles/qtip/tasks/calculate.yml
tests/unit/ansible_library/plugins/action/calculate_test.py

index 383be58..0c3ab7d 100644 (file)
@@ -43,21 +43,26 @@ class ActionModule(ActionBase):
         for metric, filename in metrics_files.items():
             with open(filename) as f:
                 metrics[metric] = json.load(f)
+
+        with open(self._task.args.get('sysinfo')) as f:
+            data = json.load(f)
+            sysinfo = dict([(k['name'], data[k['name']][0]) for k in spec['system_info']])
+
         dest = self._task.args.get('dest')
 
         baseline_file = self._task.args.get('baseline')
         if baseline_file is not None:
             with open(baseline_file) as f:
                 baseline = json.load(f)
-                return calc_qpi(spec, metrics, baseline, dest=dest)
+                return calc_qpi(spec, metrics, baseline, sysinfo, dest=dest)
         else:
-            return save_as_baseline(spec, metrics, dest=dest)
+            return save_as_baseline(spec, metrics, sysinfo, dest=dest)
 
 
 # TODO(wuzhihui): It is more reasonable to put this function into collect.py.
 # For now metrics data is not easy to be collected from collect.py.
 @export_to_file
-def save_as_baseline(qpi_spec, metrics):
+def save_as_baseline(qpi_spec, metrics, sysinfo):
     display.vv("save {} metrics as baseline".format(qpi_spec['name']))
     display.vvv("spec: {}".format(qpi_spec))
     display.vvv("metrics: {}".format(metrics))
@@ -66,6 +71,7 @@ def save_as_baseline(qpi_spec, metrics):
         'name': qpi_spec['name'],
         'score': 2048,
         'description': qpi_spec['description'],
+        'system_info': sysinfo,
         'details': {
             'metrics': metrics,
             'spec': "https://git.opnfv.org/qtip/tree/resources/QPI/compute.yaml",
@@ -75,7 +81,7 @@ def save_as_baseline(qpi_spec, metrics):
 
 
 @export_to_file
-def calc_qpi(qpi_spec, metrics, qpi_baseline):
+def calc_qpi(qpi_spec, metrics, qpi_baseline, sysinfo):
     display.vv("calculate QPI {}".format(qpi_spec['name']))
     display.vvv("spec: {}".format(qpi_spec))
     display.vvv("metrics: {}".format(metrics))
@@ -95,6 +101,7 @@ def calc_qpi(qpi_spec, metrics, qpi_baseline):
         'score': qpi_score,
         'name': qpi_spec['name'],
         'description': qpi_spec['description'],
+        'system_info': sysinfo,
         'children': section_results,
         'details': {
             'metrics': metrics,
@@ -146,6 +153,7 @@ def calc_metric(metric_spec, metrics, metric_basline):
         })
 
     metric_score = mean([r['score'] for r in workload_results])
+
     return {
         'score': metric_score,
         'name': metric_spec['name'],
index 25378d1..33f711d 100644 (file)
@@ -8,12 +8,12 @@
     "product": "EC600G3",
     "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-)",
     "os": "Ubuntu 16.04 xenial",
-    "kernel": "4.4.0-72-generic x86_64 (64 bit)"
-  },
-  "condition": {
+    "kernel": "4.4.0-72-generic x86_64 (64 bit)",
     "cpu_speed": "1200/3000 MHz",
     "memory": "4062.3/128524.1MB",
-    "disk": "1200.3GB (0.9% used)",
+    "disk": "1200.3GB (0.9% used)"
+  },
+  "condition": {
     "installer": "Fuel",
     "scenario": "os-nosdn-nofeature-ha"
   },
index d27d769..0562026 100644 (file)
@@ -8,6 +8,19 @@
 ##############################################################################
 name: compute
 description: QTIP Performance Index of compute
+system_info:
+  - name: product
+    description: production commercial name
+  - name: cpu
+    description: cpu brand
+  - name: os
+    description: operating system version
+  - name: kernel
+    description: the core of a computer's operating system
+  - name: memory
+    description: memory usage
+  - name: disk
+    description: disk usage
 formula: weighted arithmetic mean
 sections: # split based on different application
   - name: SSL
index 61e96fa..c472ee3 100644 (file)
@@ -18,6 +18,7 @@
       intmem: "{{ qtip_results }}/memory/integer-metrics.json"
       floatmem: "{{ qtip_results }}/memory/float-metrics.json"
       arithmetic: "{{ qtip_results }}/arithmetic/metrics.json"
+    sysinfo: "{{ qtip_results }}/sysinfo/condition.json"
     spec:   "{{ qtip_resources }}/QPI/compute.yaml"
     baseline: "{{ qtip_resources }}/QPI/compute-baseline.json"
     dest: "{{ qtip_results }}/compute.json"
index 80a0720..a83e128 100644 (file)
@@ -105,10 +105,25 @@ def section_result(metric_result):
 
 
 @pytest.fixture()
-def qpi_result(section_result, metrics):
+def info():
+    return {
+        "system_info": {
+            "kernel": "4.4.0-72-generic x86_64 (64 bit)",
+            "product": "EC600G3",
+            "os": "Ubuntu 16.04 xenial",
+            "cpu": "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-)",
+            "disk": "1200.3GB (25.1% used)",
+            "memory": "30769.7/128524.1MB"
+        }
+    }
+
+
+@pytest.fixture()
+def qpi_result(section_result, metrics, info):
     return {'score': 2048,
             'name': 'compute',
             'description': 'QTIP Performance Index of compute',
+            'system_info': info,
             'children': [section_result],
             'details': {
                 'spec': "https://git.opnfv.org/qtip/tree/resources/QPI/compute.yaml",
@@ -128,10 +143,10 @@ def test_calc_section(section_spec, metrics, section_baseline, section_result):
                                   section_baseline) == section_result
 
 
-def test_calc_qpi(qpi_spec, metrics, qpi_baseline, qpi_result):
+def test_calc_qpi(qpi_spec, metrics, qpi_baseline, info, qpi_result):
     assert calculate.calc_qpi(qpi_spec,
                               metrics,
-                              qpi_baseline) == qpi_result
+                              qpi_baseline, info) == qpi_result
 
 
 @pytest.mark.parametrize('metrics, baseline, expected', [