From 70d8b5c5dbe78d0adb9cdb80afc93e7eb9ac4ca1 Mon Sep 17 00:00:00 2001 From: zhihui wu Date: Wed, 31 May 2017 10:42:23 +0800 Subject: 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 --- .../plugins/action/calculate_test.py | 57 +++++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) (limited to 'tests/unit/ansible_library/plugins/action') 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", @@ -51,6 +51,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, @@ -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', [ -- cgit 1.2.3-korg