diff options
author | kubi <jean.gaoliang@huawei.com> | 2016-01-15 19:40:28 +0800 |
---|---|---|
committer | kubi <jean.gaoliang@huawei.com> | 2016-01-15 21:44:45 +0800 |
commit | 2ed0a4e85f710c24aae778634e9d48920d004f09 (patch) | |
tree | 1a2e7df61d75382374255bafa4ac611e46d359df | |
parent | bb82fb8c9198d6e792b8558bf6eaf4f53710c7fe (diff) |
fix some bug in ipv6 to make it run in ci
JIRA:YARDSTICK-187
Change-Id: Ia15d17afdef145f7b230a8a4d25a61eed5cdfd76
Signed-off-by: kubi <jean.gaoliang@huawei.com>
-rw-r--r-- | samples/ping6.yaml | 9 | ||||
-rw-r--r-- | tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml | 13 | ||||
-rw-r--r-- | tests/unit/benchmark/scenarios/networking/test_ping6.py | 37 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6.py | 84 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6_benchmark.bash | 24 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6_find_host.bash | 15 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash | 26 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash | 28 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6_setup.bash | 10 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6_teardown.bash | 11 | ||||
-rw-r--r--[-rwxr-xr-x] | yardstick/cmd/commands/task.py | 0 |
11 files changed, 207 insertions, 50 deletions
diff --git a/samples/ping6.yaml b/samples/ping6.yaml index 22b8bb9cc..773d1be69 100644 --- a/samples/ping6.yaml +++ b/samples/ping6.yaml @@ -8,8 +8,13 @@ scenarios: type: Ping6 options: packetsize: 200 - host: node1.IPV6 - + host: host1,host2,host3,host4,host5 + nodes: + host1: node1.IPV6 + host2: node2.IPV6 + host3: node3.IPV6 + host4: node4.IPV6 + host5: node5.IPV6 runner: type: Iteration iterations: 1 diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml index 9b5e86509..6710621fb 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml @@ -7,8 +7,15 @@ schema: "yardstick:task:0.1" scenarios: - type: Ping6 - host: node1.IPV6 - + options: + packetsize: 200 + host: host1,host2,host3,host4,host5 + nodes: + host1: node1.IPV6 + host2: node2.IPV6 + host3: node3.IPV6 + host4: node4.IPV6 + host5: node5.IPV6 runner: type: Iteration iterations: 1 @@ -22,6 +29,6 @@ scenarios: context: type: Node name: IPV6 - file: /root/yardstick/etc/yardstick/nodes/compass_sclab_physical/pod.yaml + file: /home/opnfv/repos/yardstick/etc/yardstick/nodes/compass_sclab_physical/pod.yaml diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/tests/unit/benchmark/scenarios/networking/test_ping6.py index 662b85c30..b600e4103 100644 --- a/tests/unit/benchmark/scenarios/networking/test_ping6.py +++ b/tests/unit/benchmark/scenarios/networking/test_ping6.py @@ -21,18 +21,23 @@ class PingTestCase(unittest.TestCase): def setUp(self): self.ctx = { - 'host': { + 'nodes':{ + 'host1': { 'ip': '172.16.0.137', 'user': 'cirros', 'key_filename': "mykey.key", 'password': "root" - }, + }, + } } @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') - def test_pktgen_successful_setup(self, mock_ssh): - - p = ping6.Ping6({}, self.ctx) + def test_ping_successful_setup(self, mock_ssh): + args = { + 'options': {'host': 'host1','packetsize': 200}, + 'sla': {'max_rtt': 50} + } + p = ping6.Ping6(args, self.ctx) mock_ssh.SSH().execute.return_value = (0, '0', '') p.setup() @@ -40,12 +45,15 @@ class PingTestCase(unittest.TestCase): @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_successful_no_sla(self, mock_ssh): + args = { + 'options': {'host': 'host1','packetsize': 200}, + } result = {} - p = ping6.Ping6({}, self.ctx) + p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (0, '100', '') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(0, 100, '')] p.run(result) self.assertEqual(result, {'rtt': 100.0}) @@ -53,13 +61,14 @@ class PingTestCase(unittest.TestCase): def test_ping_successful_sla(self, mock_ssh): args = { + 'options': {'host': 'host1','packetsize': 200}, 'sla': {'max_rtt': 150} - } + } result = {} p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (0, '100', '') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(0, 100, '')] p.run(result) self.assertEqual(result, {'rtt': 100.0}) @@ -67,28 +76,28 @@ class PingTestCase(unittest.TestCase): def test_ping_unsuccessful_sla(self, mock_ssh): args = { - 'options': {'packetsize': 200}, + 'options': {'host': 'host1','packetsize': 200}, 'sla': {'max_rtt': 50} } result = {} p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (0, '100', '') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(0, 100, '')] self.assertRaises(AssertionError, p.run, result) @mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh') def test_ping_unsuccessful_script_error(self, mock_ssh): args = { - 'options': {'packetsize': 200}, - 'sla': {'max_rtt': 50} + 'options': {'host': 'host1','packetsize': 200}, + 'sla': {'max_rtt': 150} } result = {} p = ping6.Ping6(args, self.ctx) p.client = mock_ssh.SSH() - mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR') + mock_ssh.SSH().execute.side_effect = [(0, 'host1', ''),(1, '', 'FOOBAR')] self.assertRaises(RuntimeError, p.run, result) diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py index 5d878eb8f..067b8893e 100644 --- a/yardstick/benchmark/scenarios/networking/ping6.py +++ b/yardstick/benchmark/scenarios/networking/ping6.py @@ -25,9 +25,12 @@ class Ping6(base.Scenario): # pragma: no cover __scenario_type__ = "Ping6" TARGET_SCRIPT = 'ping6_benchmark.bash' + PRE_SETUP_SCRIPT = 'ping6_pre_setup.bash' SETUP_SCRIPT = 'ping6_setup.bash' + FIND_HOST_SCRIPT = 'ping6_find_host.bash' TEARDOWN_SCRIPT = 'ping6_teardown.bash' METADATA_SCRIPT = 'ping6_metadata.txt' + POST_TEARDOWN_SCRIPT = 'ping6_post_teardown.bash' def __init__(self, scenario_cfg, context_cfg): self.scenario_cfg = scenario_cfg @@ -35,13 +38,23 @@ class Ping6(base.Scenario): # pragma: no cover self.setup_done = False self.run_done = False - def _ssh_host(self): - # ssh host1 - host = self.context_cfg['host'] - host_user = host.get('user', 'ubuntu') - host_ip = host.get('ip', None) - host_pwd = host.get('password', 'root') - LOG.info("user:%s, host:%s", host_user, host_ip) + def _pre_setup(self): + for node_name in self.host_list: + self._ssh_host(node_name) + self.client.run("cat > ~/pre_setup.sh", + stdin=open(self.pre_setup_script, "rb")) + status, stdout, stderr = self.client.execute( + "sudo bash pre_setup.sh") + + def _ssh_host(self, node_name): + # ssh host + print node_name + nodes = self.context_cfg['nodes'] + node = nodes.get(node_name, None) + host_user = node.get('user', 'ubuntu') + host_ip = node.get('ip', None) + host_pwd = node.get('password', 'root') + LOG.debug("user:%s, host:%s", host_user, host_ip) self.client = ssh.SSH(host_user, host_ip, password=host_pwd) self.client.wait(timeout=600) @@ -51,11 +64,24 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.SETUP_SCRIPT) + self.pre_setup_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.PRE_SETUP_SCRIPT) + self.ping6_metadata_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', Ping6.METADATA_SCRIPT) + + options = self.scenario_cfg['options'] + host_str = options.get("host", 'host1') + self.host_list = host_str.split(',') + self.host_list.sort() + pre_setup = options.get("pre_setup", True) + if pre_setup: + self._pre_setup() + # ssh host1 - self._ssh_host() + self._ssh_host(self.host_list[0]) # run script to setup ipv6 self.client.run("cat > ~/setup.sh", stdin=open(self.setup_script, "rb")) @@ -73,9 +99,24 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.TARGET_SCRIPT) - if not self.setup_done: - self._ssh_host() + self.ping6_find_host_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.FIND_HOST_SCRIPT) + if not self.setup_done: + options = self.scenario_cfg['options'] + host_str = options.get("host", 'host1') + self.host_list = host_str.split(',') + self.host_list.sort() + self._ssh_host(self.host_list[0]) + self.client.run("cat > ~/find_host.sh", + stdin=open(self.ping6_find_host_script, "rb")) + cmd = "sudo bash find_host.sh" + LOG.debug("Executing command: %s", cmd) + status, stdout, stderr = self.client.execute(cmd) + host_name = stdout.strip() + print host_name + self._ssh_host(host_name) self.client.run("cat > ~/ping6.sh", stdin=open(self.ping6_script, "rb")) cmd = "sudo bash ping6.sh" @@ -99,8 +140,17 @@ class Ping6(base.Scenario): # pragma: no cover def teardown(self): """teardown the benchmark""" + self.post_teardown_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.POST_TEARDOWN_SCRIPT) + + options = self.scenario_cfg['options'] + host_str = options.get("host", 'node1') + self.host_list = host_str.split(',') + self.host_list.sort() + if not self.run_done: - self._ssh_host() + self._ssh_host(self.host_list[0]) self.teardown_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', @@ -110,6 +160,10 @@ class Ping6(base.Scenario): # pragma: no cover cmd = "sudo bash teardown.sh" status, stdout, stderr = self.client.execute(cmd) + post_teardown = options.get("post_teardown", True) + if post_teardown: + self._post_teardown() + if status: raise RuntimeError(stderr) @@ -117,3 +171,11 @@ class Ping6(base.Scenario): # pragma: no cover pass else: LOG.error("ping6 teardown failed") + + def _post_teardown(self): + for node_name in self.host_list: + self._ssh_host(node_name) + self.client.run("cat > ~/post_teardown.sh", + stdin=open(self.post_teardown_script, "rb")) + status, stdout, stderr = self.client.execute( + "sudo bash post_teardown.sh") diff --git a/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash b/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash index 6df354a1b..bd02be76e 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash @@ -10,11 +10,23 @@ ############################################################################## # Run a single ping6 command towards a ipv6 router - set -e - +source /opt/admin-openrc.sh +chmod 600 vRouterKey # TODO find host -sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') bash -# TODO find VM ip -ssh -i vRouterkey fedora@20.0.0.4 -ping6 -c 1 2001:db8:0:1::1 | grep ttl | awk -F [=\ ] '{printf $10}' +wait_vm_ok() { + retry=0 + until timeout 100s sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i vRouterKey fedora@20.0.0.4 "exit" >/dev/null 2>&1 + do + sleep 10 + let retry+=1 + if [ $retry -ge 40 ]; + then + echo "vm ssh start timeout !!!" + exit 0 + fi + done +} +wait_vm_ok +sleep 600 +sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i vRouterKey fedora@20.0.0.4 "ping6 -c 1 2001:db8:0:1::1 | grep ttl | awk -F [=\ ] '{printf \$10}'" diff --git a/yardstick/benchmark/scenarios/networking/ping6_find_host.bash b/yardstick/benchmark/scenarios/networking/ping6_find_host.bash new file mode 100644 index 000000000..a1d50d418 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/ping6_find_host.bash @@ -0,0 +1,15 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +source /opt/admin-openrc.sh +host_num=$(neutron dhcp-agent-list-hosting-net ipv4-int-network1 | grep True | awk -F [=\ ] '{printf $4}') > /tmp/ipv6.log +scp vRouterKey $host_num:~ +echo $host_num
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash b/yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash new file mode 100644 index 000000000..f40d47d64 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash @@ -0,0 +1,26 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +sed -i 's/enable_security_group= False/enable_security_group = True/g' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 3d /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 's/firewall_driver= neutron.agent.firewall.NoopFirewallDriver/firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver/g' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 's/security_group_api= nova/security_group_api = neutron/g' /etc/nova/nova.conf + +service neutron-l3-agent restart +service neutron-dhcp-agent restart +service neutron-metadata-agent restart +service neutron-server restart +service nova-api restart +service nova-cert restart +service nova-conductor restart +service nova-consoleauth restart +service nova-novncproxy restart +service nova-scheduler restart +service nova-compute restart
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash b/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash new file mode 100644 index 000000000..4a781d21e --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash @@ -0,0 +1,28 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +sed -i 's/enable_security_group = True/enable_security_group= False/g' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i '2a extension_drivers = port_security' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 's/firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver/firewall_driver= neutron.agent.firewall.NoopFirewallDriver/g' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 's/security_group_api = neutron/security_group_api= nova/g' /etc/nova/nova.conf + + +service neutron-l3-agent restart +service neutron-dhcp-agent restart +service neutron-metadata-agent restart +service neutron-server restart +service nova-api restart +service nova-cert restart +service nova-conductor restart +service nova-consoleauth restart +service nova-novncproxy restart +service nova-scheduler restart +service nova-compute restart diff --git a/yardstick/benchmark/scenarios/networking/ping6_setup.bash b/yardstick/benchmark/scenarios/networking/ping6_setup.bash index 2a54da2ba..ddb6c1cd9 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_setup.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_setup.bash @@ -9,17 +9,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## + # download and create image source /opt/admin-openrc.sh wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2 glance image-create --name 'Fedora22' --disk-format qcow2 \ --container-format bare --file ./Fedora-Cloud-Base-22-20150521.x86_64.qcow2 -# create external network -neutron net-create net04_ext --router:external --provider:physical_network physnet \ ---provider:network_type vlan --provider:segmentation_id 1411 -neutron subnet-create net04_ext 10.145.140.0/24 --name net04_ext__subnet \ ---allocation-pool start=10.145.140.13,end=10.145.140.20 --disable-dhcp --gateway 10.145.140.1 # create router neutron router-create ipv4-router @@ -36,8 +32,8 @@ neutron subnet-create --name ipv4-int-subnet1 \ neutron router-interface-add ipv4-router ipv4-int-subnet1 # Associate the net04_ext to the Neutron routers -neutron router-gateway-set ipv6-router net04_ext -neutron router-gateway-set ipv4-router net04_ext +neutron router-gateway-set ipv6-router ext-net +neutron router-gateway-set ipv4-router ext-net # Create two subnets, one IPv4 subnet ipv4-int-subnet2 and # one IPv6 subnet ipv6-int-subnet2 in ipv6-int-network2, and associate both subnets to ipv6-router diff --git a/yardstick/benchmark/scenarios/networking/ping6_teardown.bash b/yardstick/benchmark/scenarios/networking/ping6_teardown.bash index 7ab145523..33eff5ca7 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_teardown.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_teardown.bash @@ -8,6 +8,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +source /opt/admin-openrc.sh # delete VM nova delete VM1 nova delete VM2 @@ -35,8 +36,8 @@ neutron subnet-delete --name ipv6-int-subnet2 neutron subnet-delete --name ipv4-int-subnet2 #clear gateway -neutron router-gateway-clear ipv4-router net04_ext -neutron router-gateway-clear ipv6-router net04_ext +neutron router-gateway-clear ipv4-router ext-net +neutron router-gateway-clear ipv6-router ext-net #delete ipv4 router interface neutron router-interface-delete ipv4-router ipv4-int-subnet1 @@ -50,9 +51,5 @@ neutron net-delete ipv4-int-network1 neutron router-delete ipv4-router neutron router-delete ipv6-router -# delete ext net -neutron subnet-delete net04_ext__subnet -neutron net-delete net04_ext - # delete glance image -glance --os-image-api-version 1 image-delete Fedora22
\ No newline at end of file +glance --os-image-api-version 1 image-delete Fedora22 diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 17e8f4c42..17e8f4c42 100755..100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py |