aboutsummaryrefslogtreecommitdiffstats
path: root/tests/driver_test.py
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2016-08-21 00:01:28 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-08-21 00:01:28 +0000
commite0482d626cedfb1f30712e82df288454af65c76c (patch)
tree4a6ac9c4f84b3d75336e673db866464423e365c1 /tests/driver_test.py
parentc804c4ea8a8289bdc954653f961f6243a0e4885f (diff)
parent27b463c5a9e50c610692c359e6ccdb982a6d1975 (diff)
Merge "Code refactoring driver so that it can call ansible playbook by api."
Diffstat (limited to 'tests/driver_test.py')
-rw-r--r--tests/driver_test.py75
1 files changed, 44 insertions, 31 deletions
diff --git a/tests/driver_test.py b/tests/driver_test.py
index 39adc939..a5b13588 100644
--- a/tests/driver_test.py
+++ b/tests/driver_test.py
@@ -16,20 +16,20 @@ class TestClass:
'https_proxy': 'http://10.20.0.1:8118',
'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*'},
'fuel'],
- {'Dest_dir': 'results',
- 'ip1': '',
- 'ip2': '',
- 'installer': 'fuel',
- 'workingdir': '/home',
- 'fname': 'iperf_bm.yaml',
- 'username': 'root',
- 'http_proxy': 'http://10.20.0.1:8118',
- 'https_proxy': 'http://10.20.0.1:8118',
- 'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*',
- 'duration': 20,
- 'protocol': 'tcp',
- 'bandwidthGbps': 0,
- "role": "host"}),
+ [{'Dest_dir': 'results',
+ 'ip1': '',
+ 'ip2': '',
+ 'installer': 'fuel',
+ 'workingdir': '/home',
+ 'fname': 'iperf_bm.yaml',
+ 'username': 'root',
+ 'http_proxy': 'http://10.20.0.1:8118',
+ 'https_proxy': 'http://10.20.0.1:8118',
+ 'no_proxy': 'localhost,127.0.0.1,10.20.*,192.168.*',
+ 'duration': 20,
+ 'protocol': 'tcp',
+ 'bandwidthGbps': 0,
+ "role": "host"}]),
(["iperf",
[('1-server', ['10.20.0.13']), ('2-host', ['10.20.0.15'])],
"iperf_vm.yaml",
@@ -37,18 +37,29 @@ class TestClass:
[("10.20.0.13", [None]), ("10.20.0.15", [None])],
{},
'joid'],
- {'Dest_dir': 'results',
- 'ip1': '10.20.0.13',
- 'ip2': '',
- 'installer': 'joid',
- "privateip1": "NONE",
- 'workingdir': '/home',
- 'fname': 'iperf_vm.yaml',
- 'username': 'ubuntu',
- 'duration': 20,
- 'protocol': 'tcp',
- 'bandwidthGbps': 0,
- "role": "2-host"})
+ [{'Dest_dir': 'results',
+ 'ip1': '10.20.0.13',
+ 'ip2': '',
+ 'installer': 'joid',
+ "privateip1": "NONE",
+ 'workingdir': '/home',
+ 'fname': 'iperf_vm.yaml',
+ 'username': 'ubuntu',
+ 'duration': 20,
+ 'protocol': 'tcp',
+ 'bandwidthGbps': 0,
+ "role": "1-server"},
+ {'Dest_dir': 'results',
+ 'ip1': '',
+ 'ip2': '',
+ 'installer': 'joid',
+ 'workingdir': '/home',
+ 'fname': 'iperf_vm.yaml',
+ 'username': 'ubuntu',
+ 'duration': 20,
+ 'protocol': 'tcp',
+ 'bandwidthGbps': 0,
+ "role": "2-host"}])
])
@mock.patch('func.driver.os.system')
def test_driver_success(self, mock_system, test_input, expected):
@@ -57,9 +68,11 @@ class TestClass:
k.start()
dri = Driver()
dri.drive_bench(test_input[0], test_input[1], test_input[2], test_input[3], test_input[4], test_input[5])
- call = mock_system.call_args
+ call_list = mock_system.call_args_list
k.stop()
- call_args, call_kwargs = call
- real_call = call_args[0].split('extra-vars \'')[1]
- real_call = real_call[0: len(real_call) - 1]
- assert json.loads(real_call) == json.loads(json.dumps(expected))
+ print call_list
+ for call in call_list:
+ call_args, call_kwargs = call
+ real_call = call_args[0].split('extra-vars \'')[1]
+ real_call = real_call[0: len(real_call) - 1]
+ assert json.loads(real_call) == json.loads(json.dumps(expected[call_list.index(call)]))