3 # Copyright (c) 2018 Orange and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
11 Shaker_ wraps around popular system network testing tools like iperf, iperf3
12 and netperf (with help of flent). Shaker is able to deploy OpenStack instances
13 and networks in different topologies. Shaker scenario specifies the deployment
14 and list of tests to execute.
16 .. _Shaker: http://pyshaker.readthedocs.io/en/latest/
24 from functest.core import singlevm
27 class Shaker(singlevm.SingleVm2):
28 """Run shaker full+perf l2 and l3"""
29 # pylint: disable=too-many-instance-attributes
31 __logger = logging.getLogger(__name__)
33 filename = '/home/opnfv/functest/images/shaker-image.qcow2'
41 super(Shaker, self).prepare()
42 self.cloud.create_security_group_rule(
43 self.sec.id, port_range_min=self.port, port_range_max=self.port,
44 protocol='tcp', direction='ingress')
50 - 1 on operation error
53 scpc = scp.SCPClient(self.ssh.get_transport())
54 scpc.put('/home/opnfv/functest/conf/env_file', '~/env_file')
55 (_, stdout, stderr) = self.ssh.exec_command(
56 'source ~/env_file && export OS_INTERFACE=public &&'
57 'shaker --server-endpoint {}:9000 --scenario '
58 'openstack/full_l2,openstack/full_l3_east_west,'
59 'openstack/full_l3_north_south,openstack/perf_l2,'
60 'openstack/perf_l3_east_west,openstack/perf_l3_north_south '
61 '--report report.html --output report.json'.format(
62 self.sshvm.public_v4))
63 self.__logger.info("output:\n%s", stdout.read())
64 self.__logger.info("error:\n%s", stderr.read())
65 if not os.path.exists(self.res_dir):
66 os.makedirs(self.res_dir)
68 scpc.get('report.json', self.res_dir)
69 scpc.get('report.html', self.res_dir)
70 except scp.SCPException:
71 self.__logger.exception("cannot get report files")
73 return stdout.channel.recv_exit_status()