diff options
author | Kubi <jean.gaoliang@huawei.com> | 2016-11-14 10:02:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2016-11-14 10:02:33 +0000 |
commit | 293a8ed0c22d7944c8fc671792683d45d3fa8d48 (patch) | |
tree | a6e56fd46fc5bce18fc865010bb2ed4848dc4d26 | |
parent | eb527820ddb21081399b27deaacc8a651ea5f06a (diff) | |
parent | 5e49e33552c581610b1abaa2628cdf90a4ba14ac (diff) |
Merge "bugfix: ipv6 should log in controller node to setup"
-rw-r--r-- | tests/unit/benchmark/scenarios/networking/test_ping6.py | 17 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6.py | 18 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6_setup.bash | 7 |
3 files changed, 37 insertions, 5 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/tests/unit/benchmark/scenarios/networking/test_ping6.py index 995113e28..0b8fba268 100644 --- a/tests/unit/benchmark/scenarios/networking/test_ping6.py +++ b/tests/unit/benchmark/scenarios/networking/test_ping6.py @@ -25,12 +25,29 @@ class PingTestCase(unittest.TestCase): 'host1': { 'ip': '172.16.0.137', 'user': 'cirros', + 'role': "Controller", 'key_filename': "mykey.key", 'password': "root" }, + 'host2': { + "ip": "172.16.0.138", + "key_filename": "/root/.ssh/id_rsa", + "role": "Compute", + "name": "node3.IPV6", + "user": "root" + }, } } + def test_get_controller_node(self): + args = { + 'options': {'host': 'host1','packetsize': 200, 'ping_count': 5}, + 'sla': {'max_rtt': 50} + } + p = ping6.Ping6(args, self.ctx) + controller_node = p._get_controller_node(['host1','host2']) + self.assertEqual(controller_node, 'host1') + @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_successful_setup(self, mock_ssh): args = { diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py index c6ec33e3e..9aa94c40c 100644 --- a/yardstick/benchmark/scenarios/networking/ping6.py +++ b/yardstick/benchmark/scenarios/networking/ping6.py @@ -55,7 +55,6 @@ class Ping6(base.Scenario): # pragma: no cover ip = node.get('ip', None) pwd = node.get('password', None) key_fname = node.get('key_filename', '/root/.ssh/id_rsa') - if pwd is not None: LOG.debug("Log in via pw, user:%s, host:%s, password:%s", user, ip, pwd) @@ -75,6 +74,14 @@ class Ping6(base.Scenario): # pragma: no cover status, stdout, stderr = self.client.execute( "sudo bash pre_setup.sh") + def _get_controller_node(self, host_list): + for host_name in host_list: + node = self.nodes.get(host_name, None) + node_role = node.get('role', None) + if node_role == 'Controller': + return host_name + return None + def setup(self): '''scenario setup''' self.setup_script = pkg_resources.resource_filename( @@ -104,9 +111,12 @@ class Ping6(base.Scenario): # pragma: no cover if pre_setup: self._pre_setup() - # ssh host1 - self._ssh_host(self.host_list[0]) - + # log in a contronller node to setup + controller_node_name = self._get_controller_node(self.host_list) + LOG.debug("The Controller Node is: %s", controller_node_name) + if controller_node_name is None: + LOG.exception("Can't find controller node in the context!!!") + self._ssh_host(controller_node_name) self.client.run("cat > ~/metadata.txt", stdin=open(self.ping6_metadata_script, "rb")) diff --git a/yardstick/benchmark/scenarios/networking/ping6_setup.bash b/yardstick/benchmark/scenarios/networking/ping6_setup.bash index fb6da4fdb..592ced3df 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_setup.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_setup.bash @@ -15,8 +15,13 @@ openrc=$1 external_network=$2 echo "openrc=$openrc" echo "external_network=$external_network" +echo "nameserver 8.8.4.4" >> /etc/resolv.conf source $openrc -wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2 >/dev/null 2>&1 + +fedora_img="Fedora-Cloud-Base-22-20150521.x86_64.qcow2" +if [ ! -f "$fedora_img" ]; then + wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/${fedora_img} >/dev/null 2>&1 +fi glance image-create --name 'Fedora22' --disk-format qcow2 \ --container-format bare --file ./Fedora-Cloud-Base-22-20150521.x86_64.qcow2 |