aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/ansible.cfg2
-rw-r--r--tests/integration/group_vars/all1
-rw-r--r--tests/integration/run.yaml11
-rw-r--r--tests/unit/cli/options_test.py3
-rw-r--r--tests/unit/reporter/test_testapi.py116
5 files changed, 132 insertions, 1 deletions
diff --git a/tests/integration/ansible.cfg b/tests/integration/ansible.cfg
index 40e28bcf..30e28480 100644
--- a/tests/integration/ansible.cfg
+++ b/tests/integration/ansible.cfg
@@ -26,3 +26,5 @@ filter_plugins = ../../qtip/ansible_library/plugins/filter
#test_plugins = /usr/share/ansible/plugins/test
#terminal_plugins = /usr/share/ansible/plugins/terminal
#strategy_plugins = /usr/share/ansible/plugins/strategy
+
+callback_whitelist = profile_tasks
diff --git a/tests/integration/group_vars/all b/tests/integration/group_vars/all
index 16a93f46..a84ab51f 100644
--- a/tests/integration/group_vars/all
+++ b/tests/integration/group_vars/all
@@ -1,3 +1,4 @@
qtip_resources: ../../resources
qtip_reports: ./reports
qtip_fixtures: ./fixtures
+qtip_dump: ./dump
diff --git a/tests/integration/run.yaml b/tests/integration/run.yaml
index 10428ac3..e715863f 100644
--- a/tests/integration/run.yaml
+++ b/tests/integration/run.yaml
@@ -21,6 +21,12 @@
- name: ssl metrics
include: "{{ qtip_resources }}/metric/openssl.yaml"
tags: [ssl]
+ - name: DPI metrics
+ include: "{{ qtip_resources }}/metric/nDPI.yaml"
+ vars:
+ nDPI_cwd: "{{ ansible_env.HOME }}/qtip/nDPI"
+ nDPI_file: "dpi.pcap"
+ tags: [dpi]
- hosts: compute
tasks:
@@ -57,6 +63,11 @@
src: "{{ qtip_resources }}/template/qpi-report.j2"
dest: "{{ qtip_reports }}/qpi-report"
tags: [report]
+ - name: create dpi metrics report
+ template:
+ src: "{{ qtip_resources }}/template/dpi-metrics.j2"
+ dest: "{{ qtip_reports }}/dpi-metrics"
+ tags: [report, dpi]
- name: push result to testapi
uri:
url: "{{ testapi_url }}/results"
diff --git a/tests/unit/cli/options_test.py b/tests/unit/cli/options_test.py
index 9dbbe6f3..d7c0f700 100644
--- a/tests/unit/cli/options_test.py
+++ b/tests/unit/cli/options_test.py
@@ -8,6 +8,7 @@
##############################################################################
import pytest
+import re
import sys
from click.testing import CliRunner
@@ -26,7 +27,7 @@ class TestClass(object):
def test_version(self, runner):
result = runner.invoke(cli, ['--version'])
- assert 'dev' in result.output
+ assert re.search(r'\d+\.\d+\.\d+', result.output)
def test_debug(self, runner):
runner.invoke(cli, ['-d'])
diff --git a/tests/unit/reporter/test_testapi.py b/tests/unit/reporter/test_testapi.py
new file mode 100644
index 00000000..85655274
--- /dev/null
+++ b/tests/unit/reporter/test_testapi.py
@@ -0,0 +1,116 @@
+##############################################################################
+# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+import mock
+import pytest
+
+from qtip.reporter import testapi
+
+
+@pytest.mark.parametrize("testapi_url, payload", [
+ ("http://testresults.opnfv.org/test/api/v1", {'project_name': 'qtip',
+ 'case_name': 'fake-case',
+ 'pod_name': 'fake_pod',
+ 'installer': 'fake_installer',
+ 'version': '1',
+ 'scenario': 'fake_scenario',
+ 'criteria': 'fake_criteria',
+ 'build_tag': 'fake_tag',
+ 'start_date': 'fake_date',
+ 'stop_date': 'fake_date',
+ 'details': 'fake:details'}),
+])
+@mock.patch('qtip.reporter.testapi.requests')
+def test_testapi_unavailable(mock_request, testapi_url, payload):
+ mock_request.post.return_value.status_code = testapi.requests.codes.unavailable
+ mock_request.post.return_value.reason = 'Service unavailable'
+ testapi.push_results(testapi_url, payload)
+ mock_request.post.assert_called_with(testapi_url + '/results', json=payload)
+ mock_request.post.return_value.raise_for_status.assert_called()
+
+
+@pytest.mark.parametrize("testapi_url, payload", [
+ ("http://testresults.opnfv.org/test/api/v1", {'project_name': 'qtip',
+ 'case_name': 'fake-case',
+ 'pod_name': 'fake_pod',
+ 'installer': 'fake_installer',
+ 'version': '1',
+ 'scenario': 'fake_scenario',
+ 'criteria': 'fake_criteria',
+ 'build_tag': 'fake_tag',
+ 'start_date': 'fake_date',
+ 'stop_date': 'fake_date',
+ 'details': 'fake:details'}),
+])
+@mock.patch('qtip.reporter.testapi.requests')
+def test_push_results_success(mock_request, testapi_url, payload):
+ mock_request.post.return_value.status_code = testapi.requests.codes.ok
+ mock_request.post.return_value.json.return_value = {'href': 'mock_url'}
+ push_response = testapi.push_results(testapi_url, payload)
+ mock_request.post.assert_called_with(testapi_url + '/results', json=payload)
+ assert push_response['href'] == 'mock_url'
+
+
+@pytest.mark.parametrize("testapi_url, payload", [
+ ("http://testresults.opnfv.org/test/api/v1", {'project_name': 'qtip',
+ 'case_name': 'fake-case',
+ 'pod_name': 'fake_pod',
+ 'installer': 'fake_installer',
+ 'version': '1',
+ 'scenario': 'fake_scenario',
+ 'criteria': 'fake_criteria',
+ 'build_tag': 'fake_tag',
+ 'start_date': 'fake_date',
+ 'stop_date': 'fake_date',
+ 'details': 'fake:details'}),
+])
+@mock.patch('qtip.reporter.testapi.requests')
+def test_push_results_not_found(mock_request, testapi_url, payload):
+ mock_request.post.return_value.status_code = testapi.requests.codes.not_found
+ mock_request.post.return_value.reason = 'Not found'
+ testapi.push_results(testapi_url, payload)
+ mock_request.post.assert_called_with(testapi_url + '/results', json=payload)
+ mock_request.post.return_value.raise_for_status.assert_called()
+
+
+@pytest.mark.parametrize("testapi_url, payload", [
+ ("http://testresults.opnfv.org/test/api/v1", {'project_name': 'qtip',
+ 'case_name': 'fake-case',
+ 'pod_name': 'fake_pod',
+ 'installer': 'fake_installer',
+ 'version': '',
+ 'scenario': None,
+ 'criteria': 'fake_criteria',
+ 'build_tag': 'fake_tag',
+ 'start_date': 'fake_date',
+ 'stop_date': 'fake_date',
+ 'details': 'fake:details'}),
+])
+def test_push_results_invalid_params(testapi_url, payload):
+ with pytest.raises(testapi.InvalidParamsError) as error_invalid:
+ testapi.push_results(testapi_url, payload)
+ assert set(error_invalid.value.params) == {'version', 'scenario'}
+
+
+@pytest.mark.parametrize("testapi_url, payload", [
+ ("http://testresults.opnfv.org/test/api/v1", {'project_name': 'qtip',
+ 'case_name': 'fake-case',
+ 'pod_name': 'fake_pod',
+ 'installer': 'fake_installer',
+ 'criteria': 'fake_criteria',
+ 'build_tag': 'fake_tag',
+ 'start_date': 'fake_date',
+ 'stop_date': 'fake_date',
+ 'details': 'fake:details'}),
+])
+def test_push_results_missing_params(testapi_url, payload):
+ with pytest.raises(testapi.MissingParamsError) as error_missing:
+ testapi.push_results(testapi_url, payload)
+ assert set(error_missing.value.params) == {'version', 'scenario'}