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
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
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
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()
@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})
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})
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)
__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
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)
'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"))
'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"
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',
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)
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")
##############################################################################
# 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}'"
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+#!/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
# 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
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
# 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
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
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