1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # Unittest for yardstick.benchmark.scenarios.lib.check_connectivity.CheckConnectivity
12 from __future__ import absolute_import
17 from yardstick.benchmark.scenarios.lib import check_connectivity
20 class CheckConnectivityTestCase(unittest.TestCase):
27 'key_filename': 'mykey.key',
31 'ipaddr': '172.16.0.138'
35 @mock.patch('yardstick.benchmark.scenarios.lib.check_connectivity.ssh')
36 def test_check_connectivity(self, mock_ssh):
39 'options': {'src_ip_addr': '192.168.23.2',
40 'dest_ip_addr': '192.168.23.10',
45 'ping_parameter': "-s 2048"
47 'sla': {'status': 'True',
51 # TODO(elfoley): Properly check the outputs
52 result = {} # pylint: disable=unused-variable
54 obj = check_connectivity.CheckConnectivity(args, {})
56 mock_ssh.SSH.execute.return_value = (0, '100', '')
58 @mock.patch('yardstick.benchmark.scenarios.lib.check_connectivity.ssh')
59 def test_check_connectivity_key(self, mock_ssh):
62 'options': {'ssh_user': 'root',
63 'ssh_key': '/root/.ssh/id_rsa',
66 'ping_parameter': "-s 2048"
68 'sla': {'status': 'True',
72 # TODO(elfoley): Properly check the outputs
73 result = {} # pylint: disable=unused-variable
75 obj = check_connectivity.CheckConnectivity(args, self.ctx)
78 mock_ssh.SSH.execute.return_value = (0, '100', '')
85 if __name__ == '__main__':