summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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', [