push results to testapi 03/33403/3
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Mon, 17 Apr 2017 03:20:54 +0000 (11:20 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Mon, 17 Apr 2017 15:04:29 +0000 (23:04 +0800)
Change-Id: Ie6e231690f92971b776cd41af18b21acb43bb199
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
qtip/ansible_library/plugins/action/aggregate.py
qtip/ansible_library/plugins/action/calculate.py
tests/integration/run.yaml
tests/unit/ansible_library/plugins/action/calculate_test.py

index 907fa77..6e28041 100644 (file)
@@ -32,5 +32,5 @@ class ActionModule(ActionBase):
 def aggregate(group, task_vars):
     qpi_results = [task_vars['hostvars'][host]['qpi_result'] for host in task_vars['groups'][group]]
     return {
-        'score': mean([r['score'] for r in qpi_results])
+        'score': int(mean([r['score'] for r in qpi_results]))
     }
index ac7f10f..fade367 100644 (file)
@@ -45,8 +45,10 @@ def calc_qpi(qpi_spec, metrics):
 
     section_results = [{'name': s['name'], 'result': calc_section(s, metrics)}
                        for s in qpi_spec['sections']]
+
     # TODO(yujunz): use formula in spec
-    qpi_score = mean([r['result']['score'] for r in section_results])
+    standard_score = 2048
+    qpi_score = int(mean([r['result']['score'] for r in section_results]) * standard_score)
     return {
         'spec': qpi_spec,
         'score': qpi_score,
index eb1bab8..7545a65 100644 (file)
       src: "{{ qtip_resources }}/template/qpi-report.j2"
       dest: "{{ qtip_reports }}/qpi-report"
     tags: [report]
+  - name: push result to testapi
+    uri:
+      url: "{{ testapi_url }}/results"
+      body: "{{ item|to_json }}"
+      method: POST
+      body_format: json
+      status_code: 200
+    with_items:
+      -
+        project_name: "{{ project_name }}"
+        case_name: "{{ case_name }}"
+        pod_name: "{{ pod_name }}"
+        installer: "{{ installer }}"
+        version: "{{ version }}"
+        scenario: "{{ scenario }}"
+        start_date: "{{ ansible_date_time.date }}"
+        stop_date: "{{ ansible_date_time.date }}"
+        criteria: ""
+        details: " {{ pod_result }}"
+
+    tags: [testapi]
index ae16310..3b34d9f 100644 (file)
@@ -67,7 +67,7 @@ def section_result(metric_result):
 
 @pytest.fixture()
 def qpi_result(qpi_spec, section_result, metrics):
-    return {'score': 1.0,
+    return {'score': 2048,
             'spec': qpi_spec,
             'metrics': metrics,
             'section_results': [{'name': 'ssl', 'result': section_result}]}