summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-24 14:01:46 +0800
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-28 23:59:53 +0800
commit0d3fb3fb9aee914b425f3f8ed9c843d6052f7ada (patch)
tree54e488461673327a657cdea54c4a674f2c383db5 /tests
parentc4292f93f53f88a48cc3693b464dcdff6a9a0850 (diff)
Start restful server auto in docker
modification: Add start restful server in dockerfile Add result and detail_result in server job status Add job result assert in unit test JIRA:QTIP-99 Change-Id: I27108eb930eba1bb72c04216f468a81202179ee0 Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/driver_test.py23
-rw-r--r--tests/qtip_server_test.py21
2 files changed, 39 insertions, 5 deletions
diff --git a/tests/driver_test.py b/tests/driver_test.py
index 9162ca16..5ea5dac4 100644
--- a/tests/driver_test.py
+++ b/tests/driver_test.py
@@ -63,13 +63,30 @@ class TestClass:
"role": "2-host"}])
])
@mock.patch('func.driver.AnsibleApi.execute_playbook')
- def test_driver_success(self, mock_ansible, test_input, expected):
+ @mock.patch('func.driver.AnsibleApi.get_detail_playbook_stats')
+ def test_driver_success(self, mock_stats, mock_ansible, test_input, expected):
mock_ansible.return_value = True
+ mock_stats.return_value = [(u'10.20.6.14', {'unreachable': 0,
+ 'skipped': 13,
+ 'ok': 27,
+ 'changed': 26,
+ 'failures': 0}),
+ ('localhost', {'unreachable': 0,
+ 'skipped': 0,
+ 'ok': 6,
+ 'changed': 6,
+ 'failures': 0}),
+ (u'10.20.6.13', {'unreachable': 0,
+ 'skipped': 13,
+ 'ok': 27,
+ 'changed': 26,
+ 'failures': 0})]
dri = Driver()
- dri.drive_bench(test_input[0], test_input[1], test_input[2], test_input[3],
- test_input[4], test_input[5], test_input[6], test_input[7])
+ result = dri.drive_bench(test_input[0], test_input[1], test_input[2], test_input[3],
+ test_input[4], test_input[5], test_input[6], test_input[7])
call_list = mock_ansible.call_args_list
for call in call_list:
call_args, call_kwargs = call
real_call = call_args[3]
assert real_call == expected[call_list.index(call)]
+ assert result['result'] == 0
diff --git a/tests/qtip_server_test.py b/tests/qtip_server_test.py
index 3f70a1f6..511d209a 100644
--- a/tests/qtip_server_test.py
+++ b/tests/qtip_server_test.py
@@ -41,7 +41,7 @@ class TestClass:
{'state': 'finished', 'benchmark': 'ramspeed_bm.yaml'},
{'state': 'finished', 'benchmark': 'dpi_bm.yaml'},
{'state': 'finished', 'benchmark': 'ssl_bm.yaml'}],
- 'result': []}),
+ 'result': 0}),
({'installer_type': 'fuel',
'installer_ip': '10.20.0.2',
'pod_name': 'zte-pod1',
@@ -61,10 +61,27 @@ class TestClass:
{u'state': u'finished', u'benchmark': u'ramspeed_vm.yaml'},
{u'state': u'finished', u'benchmark': u'dpi_vm.yaml'},
{u'state': u'finished', u'benchmark': u'ssl_vm.yaml'}],
- 'result': []})
+ 'result': 0})
])
@mock.patch('restful_server.qtip_server.args_handler.prepare_and_run_benchmark')
def test_post_get_delete_job_successful(self, mock_args_handler, app_client, body, expected):
+ mock_args_handler.return_value = {'result': 0,
+ 'detail': {'host': [(u'10.20.6.14', {'unreachable': 0,
+ 'skipped': 13,
+ 'ok': 27,
+ 'changed': 26,
+ 'failures': 0}),
+ ('localhost', {'unreachable': 0,
+ 'skipped': 0,
+ 'ok': 6,
+ 'changed': 6,
+ 'failures': 0}),
+ (u'10.20.6.13', {'unreachable': 0,
+ 'skipped': 13,
+ 'ok': 27,
+ 'changed': 26,
+ 'failures': 0})]}}
+
reply = app_client.post("/api/v1.0/jobs", data=body)
print(reply.data)
id = json.loads(reply.data)['job_id']