aboutsummaryrefslogtreecommitdiffstats
path: root/tests/driver_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/driver_test.py')
-rw-r--r--tests/driver_test.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/driver_test.py b/tests/driver_test.py
index 9162ca16..bc705dad 100644
--- a/tests/driver_test.py
+++ b/tests/driver_test.py
@@ -35,13 +35,13 @@ class TestClass:
[('1-server', ['10.20.0.13']), ('2-host', ['10.20.0.15'])],
"iperf_vm.yaml",
[('duration', 20), ('protocol', 'tcp'), ('bandwidthGbps', 0)],
- [("10.20.0.13", [None]), ("10.20.0.15", [None])],
+ [('1-server', '10.10.17.4'), ('2-host', '10.10.17.5')],
{}],
[{'Dest_dir': 'results',
'ip1': '10.20.0.13',
'ip2': '',
'installer': 'joid',
- 'privateip1': 'NONE',
+ 'privateip1': '10.10.17.4',
'workingdir': '/home',
'fname': 'iperf_vm.yaml',
'username': 'ubuntu',
@@ -53,7 +53,7 @@ class TestClass:
'ip1': '10.20.0.13',
'ip2': '',
'installer': 'joid',
- 'privateip1': 'NONE',
+ 'privateip1': '10.10.17.4',
'workingdir': '/home',
'fname': 'iperf_vm.yaml',
'username': 'ubuntu',
@@ -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