aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorzhihui wu <wu.zhihui1@zte.com.cn>2017-05-31 10:42:23 +0800
committerzhihui wu <wu.zhihui1@zte.com.cn>2017-06-01 09:44:57 +0800
commit70d8b5c5dbe78d0adb9cdb80afc93e7eb9ac4ca1 (patch)
tree8ca298cd6ed050eb74915caf9a08117c00e11111 /tests
parenta2fbfdbdea5ad9c2b36d195d0dbff43263304f5a (diff)
metrics baseline in compute-baseline.json
- Previously, metrics baseline are defined in the spec file. In this patch, move metrics baseline to compute-baseline.json. - you can get qpi based with baseline file given in calculate.yml - you can generate a customized baseline file when baseline file is not given in calculate.yml And baseline will be removed from the spec file. Change-Id: I123d28e28543cb153b60120b5076306fa2fa3873 Signed-off-by: zhihui wu <wu.zhihui1@zte.com.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/ansible_library/plugins/action/calculate_test.py57
1 files changed, 50 insertions, 7 deletions
diff --git a/tests/unit/ansible_library/plugins/action/calculate_test.py b/tests/unit/ansible_library/plugins/action/calculate_test.py
index fae59821..80a07206 100644
--- a/tests/unit/ansible_library/plugins/action/calculate_test.py
+++ b/tests/unit/ansible_library/plugins/action/calculate_test.py
@@ -42,7 +42,7 @@ def section_spec(metric_spec):
}
-@pytest.fixture
+@pytest.fixture()
def qpi_spec(section_spec):
return {
"name": "compute",
@@ -52,6 +52,42 @@ def qpi_spec(section_spec):
@pytest.fixture()
+def rsa_sign_baseline():
+ return {'name': 'rsa_sign', 'baseline': '500'}
+
+
+@pytest.fixture()
+def rsa_verify_baseline():
+ return {"name": "rsa_verify", "baseline": 600}
+
+
+@pytest.fixture()
+def metric_baseline(rsa_sign_baseline, rsa_verify_baseline):
+ return {
+ "name": "ssl_rsa",
+ "workloads": [rsa_sign_baseline, rsa_verify_baseline]
+ }
+
+
+@pytest.fixture()
+def section_baseline(metric_baseline):
+ return {
+ "name": "ssl",
+ "metrics": [metric_baseline]
+ }
+
+
+@pytest.fixture()
+def qpi_baseline(section_baseline):
+ return {
+ "name": "compute-baseline",
+ "description": "The baseline for compute QPI",
+ "score": 2048,
+ "sections": [section_baseline]
+ }
+
+
+@pytest.fixture()
def metric_result():
return {'score': 1.0,
'name': 'ssl_rsa',
@@ -76,19 +112,26 @@ def qpi_result(section_result, metrics):
'children': [section_result],
'details': {
'spec': "https://git.opnfv.org/qtip/tree/resources/QPI/compute.yaml",
+ 'baseline': "https://git.opnfv.org/qtip/tree/resources/QPI/compute-baseline.json",
'metrics': metrics}}
-def test_calc_metric(metric_spec, metrics, metric_result):
- assert calculate.calc_metric(metric_spec, metrics['ssl_rsa']) == metric_result
+def test_calc_metric(metric_spec, metrics, metric_baseline, metric_result):
+ assert calculate.calc_metric(metric_spec,
+ metrics['ssl_rsa'],
+ metric_baseline) == metric_result
-def test_calc_section(section_spec, metrics, section_result):
- assert calculate.calc_section(section_spec, metrics) == section_result
+def test_calc_section(section_spec, metrics, section_baseline, section_result):
+ assert calculate.calc_section(section_spec,
+ metrics,
+ section_baseline) == section_result
-def test_calc_qpi(qpi_spec, metrics, qpi_result):
- assert calculate.calc_qpi(qpi_spec, metrics) == qpi_result
+def test_calc_qpi(qpi_spec, metrics, qpi_baseline, qpi_result):
+ assert calculate.calc_qpi(qpi_spec,
+ metrics,
+ qpi_baseline) == qpi_result
@pytest.mark.parametrize('metrics, baseline, expected', [