diff options
author | zhihui wu <wu.zhihui1@zte.com.cn> | 2017-06-02 01:26:19 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-06-02 01:26:19 +0000 |
commit | aa27f390c9ad6817d2682c4f59594f43c69d614f (patch) | |
tree | 3f484c0efcc28880b387d6ca305925bc0430c796 /tests | |
parent | 10e89733d84e6bdcd8427c34ce4452aa69cf5df0 (diff) | |
parent | 70d8b5c5dbe78d0adb9cdb80afc93e7eb9ac4ca1 (diff) |
Merge "metrics baseline in compute-baseline.json"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/ansible_library/plugins/action/calculate_test.py | 57 |
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', [ |