Integrate Shaker as a new testcase 01/58501/15
authorCédric Ollivier <cedric.ollivier@orange.com>
Wed, 13 Jun 2018 12:57:56 +0000 (14:57 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Thu, 21 Jun 2018 03:40:51 +0000 (05:40 +0200)
Shaker wraps around popular system network testing tools like iperf,
iperf3 and netperf (with help of flent).

Change-Id: Idd82ffd9642c90335ad156e899c0330473260f15
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
docker/smoke/testcases.yaml
functest/ci/download_images.sh
functest/ci/testcases.yaml
functest/opnfv_tests/openstack/shaker/__init__.py [new file with mode: 0644]
functest/opnfv_tests/openstack/shaker/shaker.py [new file with mode: 0644]

index 35695ed..d5fe5fa 100644 (file)
@@ -126,6 +126,24 @@ tiers:
                         exclude:
                             - 'test_networks_multiprovider_rbac'
 
+            -
+                case_name: shaker
+                project_name: functest
+                criteria: 100
+                blocking: false
+                description: >-
+                    Shaker wraps around popular system network testing tools
+                    like iperf, iperf3 and netperf (with help of flent). Shaker
+                    is able to deploy OpenStack instances and networks in
+                    different topologies.
+                dependencies:
+                    installer: ''
+                    scenario: ''
+                run:
+                    module:
+                        'functest.opnfv_tests.openstack.shaker.shaker'
+                    class: 'Shaker'
+
             -
                 case_name: odl
                 project_name: functest
index d3dcee2..5057f05 100644 (file)
@@ -15,6 +15,7 @@ http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-aarch64-disk.img
 https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-arm64-uefi1.img
 http://cloud.centos.org/altarch/7/images/aarch64/CentOS-7-aarch64-GenericCloud.qcow2.xz
 https://sourceforge.net/projects/ool-opnfv/files/vyos-1.1.7.img
+http://testresults.opnfv.org/functest/shaker-image.qcow2
 EOF
 
 xz --decompress --force --keep \
index f203634..caf8ca3 100644 (file)
@@ -253,6 +253,24 @@ tiers:
                         exclude:
                             - 'test_networks_multiprovider_rbac'
 
+            -
+                case_name: shaker
+                project_name: functest
+                criteria: 100
+                blocking: false
+                description: >-
+                    Shaker wraps around popular system network testing tools
+                    like iperf, iperf3 and netperf (with help of flent). Shaker
+                    is able to deploy OpenStack instances and networks in
+                    different topologies.
+                dependencies:
+                    installer: ''
+                    scenario: ''
+                run:
+                    module:
+                        'functest.opnfv_tests.openstack.shaker.shaker'
+                    class: 'Shaker'
+
             -
                 case_name: odl
                 project_name: functest
diff --git a/functest/opnfv_tests/openstack/shaker/__init__.py b/functest/opnfv_tests/openstack/shaker/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/functest/opnfv_tests/openstack/shaker/shaker.py b/functest/opnfv_tests/openstack/shaker/shaker.py
new file mode 100644 (file)
index 0000000..88cbe35
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2018 Orange 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
+
+"""
+Shaker_ wraps around popular system network testing tools like iperf, iperf3
+and netperf (with help of flent). Shaker is able to deploy OpenStack instances
+and networks in different topologies. Shaker scenario specifies the deployment
+and list of tests to execute.
+
+.. _Shaker: http://pyshaker.readthedocs.io/en/latest/
+"""
+
+import logging
+import os
+
+import scp
+
+from functest.core import singlevm
+
+
+class Shaker(singlevm.SingleVm2):
+    # pylint: disable=too-many-instance-attributes
+
+    __logger = logging.getLogger(__name__)
+
+    filename = '/home/opnfv/functest/images/shaker-image.qcow2'
+    flavor_ram = 512
+    flavor_vcpus = 1
+    flavor_disk = 3
+    username = 'ubuntu'
+    port = 9000
+
+    def create_sg_rules(self):
+        """
+        It adds one security group rule allowing ingress 9000/tcp
+
+        Raises: Exception on error.
+        """
+        assert self.orig_cloud
+        super(Shaker, self).create_sg_rules()
+        self.orig_cloud.create_security_group_rule(
+            self.sec.id, port_range_min=self.port, port_range_max=self.port,
+            protocol='tcp', direction='ingress')
+
+    def execute(self):
+        """
+        Returns:
+            - 0 if success
+            - 1 on operation error
+        """
+        assert self.ssh
+        scpc = scp.SCPClient(self.ssh.get_transport())
+        scpc.put('/home/opnfv/functest/conf/env_file', '~/')
+        (_, stdout, stderr) = self.ssh.exec_command(
+            'source ~/env_file && export OS_INTERFACE=public &&'
+            'shaker --server-endpoint {}:9000 --scenario '
+            'openstack/full_l2,openstack/full_l3_east_west,'
+            'openstack/full_l3_north_south,openstack/perf_l2,'
+            'openstack/perf_l3_east_west,openstack/perf_l3_north_south '
+            '--report report.html --output report.json ; echo $?'.format(
+                self.sshvm.public_v4))
+        self.__logger.info("output:\n%s", stdout.read())
+        self.__logger.info("error:\n%s", stderr.read())
+        if not os.path.exists(self.res_dir):
+            os.makedirs(self.res_dir)
+        try:
+            scpc.get('report.json', self.res_dir)
+            scpc.get('report.html', self.res_dir)
+        except scp.SCPException:
+            self.__logger.exception("cannot get report files")
+            return 1
+        return stdout.channel.recv_exit_status()