summaryrefslogtreecommitdiffstats
path: root/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml')
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml176
1 files changed, 176 insertions, 0 deletions
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml
new file mode 100644
index 000000000..2804f25a2
--- /dev/null
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc023.yaml
@@ -0,0 +1,176 @@
+##############################################################################
+# Copyright (c) 2017 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
+##############################################################################
+---
+
+schema: "yardstick:task:0.1"
+
+{% set file = file or "etc/yardstick/nodes/compass_sclab_virtual/pod.yaml" %}
+{% set cpu_set = cpu_set or "0,1,2,3" %}
+{% set memory_load = memory_load or 0 %}
+
+{% set flavor = flavor or "yardstick-migrate-flavor" %}
+{% set ram = ram or "2048" %}
+{% set vcpus = vcpus or "2" %}
+{% set disk = disk or "3" %}
+
+scenarios:
+-
+ type: GetServer
+
+ output: status server
+
+ host: server.migrate
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: GetNumaInfo
+
+ options:
+ server: $server
+ file: {{ file }}
+
+ output: origin_numa_info
+
+ host: server.migrate
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: GetMigrateTargetHost
+
+ options:
+ server: $server
+ output: target_host
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: GetServerIp
+
+ options:
+ server: $server
+
+ output: server_ip
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: AddMemoryLoad
+
+ options:
+ memory_load: {{ memory_load }}
+
+ host: server.migrate
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: Migrate
+
+ options:
+ server: $server
+ host: $target_host
+ server_ip: $server_ip
+
+ output: status migrate_time1 downtime1
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: CheckValue
+
+ options:
+ value1: $status
+ value2: 0
+ operator: eq
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: GetServer
+
+ output: status server
+
+ host: server.migrate
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: GetNumaInfo
+
+ options:
+ server: $server
+ file: {{ file }}
+
+ output: new_numa_info
+
+ host: server.migrate
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: CheckNumaInfo
+
+ options:
+ info1: $origin_numa_info
+ info2: $new_numa_info
+ cpu_set: {{ cpu_set }}
+
+ output: status
+
+ runner:
+ type: Iteration
+ iteration: 1
+-
+ type: CheckValue
+
+ options:
+ value1: $status
+ value2: true
+ operator: eq
+
+ runner:
+ type: Iteration
+ iteration: 1
+
+
+contexts:
+-
+ type: Node
+ name: env-prepare
+ file: {{ file }}
+
+ env:
+ type: ansible
+ setup: migrate_pinning_setup.yaml -e "flavor={{ flavor }} ram={{ ram }} vcpus={{ vcpus }} disk={{ disk }} cpu_set={{ cpu_set }}"
+ teardown: migrate_pinning_teardown.yaml -e "flavor={{ flavor }}"
+
+-
+ name: migrate
+ image: yardstick-image
+ flavor: {{ flavor }}
+ user: ubuntu
+
+ servers:
+ server:
+ floating_ip: true
+
+ networks:
+ test:
+ cidr: '10.0.1.0/24'
{ font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #75715e } /* Generic.Subheading */ .highlight .kc { color: #66d9ef } /* Keyword.Constant */ .highlight .kd { color: #66d9ef } /* Keyword.Declaration */ .highlight .kn { color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python

# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from __future__ import absolute_import

import unittest
import mock
from multiprocessing import Queue
import multiprocessing

from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from tests.unit import STL_MOCKS

SSH_HELPER = "yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper"

STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
stl_patch.start()

if stl_patch:
    from yardstick.network_services.vnf_generic.vnf.tg_ping import PingParser
    from yardstick.network_services.vnf_generic.vnf.tg_ping import PingTrafficGen
    from yardstick.network_services.vnf_generic.vnf.tg_ping import PingResourceHelper
    from yardstick.network_services.vnf_generic.vnf.tg_ping import PingSetupEnvHelper
    from yardstick.network_services.vnf_generic.vnf.sample_vnf import VnfSshHelper


class TestPingResourceHelper(unittest.TestCase):
    def test___init__(self):
        setup_helper = mock.Mock()
        helper = PingResourceHelper(setup_helper)

        self.assertIsInstance(helper._queue, multiprocessing.queues.Queue)
        self.assertIsInstance(helper._parser, PingParser)

    def test_run_traffic(self):
        setup_helper = mock.Mock()
        traffic_profile = mock.Mock()
        traffic_profile.params = {
            'traffic_profile': {
                'frame_size': 64,
            },
        }

        helper = PingResourceHelper(setup_helper)
        helper.cmd_kwargs = {'target_ip': '10.0.0.2',
                             'local_ip': '10.0.0.1',
                             'local_if_name': 'eth0',
                             }
        helper.ssh_helper = mock.Mock()
        helper.run_traffic(traffic_profile)
        helper.ssh_helper.run.called_with('ping-s 64 10.0.0.2')


class TestPingParser(unittest.TestCase):
    def test___init__(self):
        q_out = Queue()
        ping_parser = PingParser(q_out)
        self.assertIsNotNone(ping_parser.queue)

    def test_clear(self):
        sample_out = """
64 bytes from 10.102.22.93: icmp_seq=3 ttl=64 time=0.296 ms
         """
        q_out = Queue()
        ping_parser = PingParser(q_out)
        ping_parser.write(sample_out)
        ping_parser.clear()
        self.assertEqual(True, q_out.empty())

    def test_close(self):
        q_out = Queue()
        ping_parser = PingParser(q_out)
        self.assertIsNone(ping_parser.close())

    def test_write(self):
        sample_out = """
64 bytes from 10.102.22.93: icmp_seq=3 ttl=64 time=0.296 ms
         """
        q_out = Queue()
        ping_parser = PingParser(q_out)
        ping_parser.write(sample_out)

        self.assertEqual({"packets_received": 3.0, "rtt": 0.296}, q_out.get())


class TestPingTrafficGen(unittest.TestCase):
    VNFD_0_EXT_IF_0 = {
        'virtual-interface': {
            'dst_mac': '00:00:00:00:00:04',
            'vpci': '0000:05:00.0',
            'local_ip': u'152.16.100.19',
            'type': 'PCI-PASSTHROUGH',
            'netmask': '255.255.255.0',
            'bandwidth': '10 Gbps',
            'driver': "i40e",
            'dst_ip': u'152.16.100.20',
            'local_iface_name': 'xe0',
            'local_mac': '00:00:00:00:00:02',
        },
        'vnfd-connection-point-ref': 'xe0',
        'name': 'xe0',
    }

    VNFD_0_EXT_IF_1 = {
        'virtual-interface': {
            'dst_mac': '00:00:00:00:00:03',
            'vpci': '0000:05:00.1',
            'local_ip': u'152.16.40.19',
            'type': 'PCI-PASSTHROUGH',
            'driver': "i40e",
            'netmask': '255.255.255.0',
            'bandwidth': '10 Gbps',
            'dst_ip': u'152.16.40.20',
            'local_iface_name': 'xe1',
            'local_mac': '00:00:00:00:00:01',
        },
        'vnfd-connection-point-ref': 'xe1',
        'name': 'xe1',
    }

    VNFD_0_EXT_IF_LIST = [
        VNFD_0_EXT_IF_0,
        VNFD_0_EXT_IF_1,
    ]

    VNFD_0 = {
        'short-name': 'VpeVnf',
        'vdu': [
            {
                'routing_table': [
                    {
                        'network': u'152.16.100.20',
                        'netmask': u'255.255.255.0',
                        'gateway': u'152.16.100.20',
                        'if': 'xe0',
                    },
                    {
                        'network': u'152.16.40.20',
                        'netmask': u'255.255.255.0',
                        'gateway': u'152.16.40.20',
                        'if': 'xe1',
                    },
                ],
                'description': 'VPE approximation using DPDK',
                'name': 'vpevnf-baremetal',
                'nd_route_tbl': [
                    {
                        'network': '0064:ff9b:0:0:0:0:9810:6414',
                        'netmask': '112',
                        'gateway': '0064:ff9b:0:0:0:0:9810:6414',
                        'if': 'xe0',
                    },
                    {
                        'network': '0064:ff9b:0:0:0:0:9810:2814',
                        'netmask': '112',
                        'gateway': '0064:ff9b:0:0:0:0:9810:2814',
                        'if': 'xe1',
                    },
                ],
                'id': 'vpevnf-baremetal',
                'external-interface': VNFD_0_EXT_IF_LIST,
            },
        ],
        'description': 'Vpe approximation using DPDK',
        'mgmt-interface': {
            'vdu-id': 'vpevnf-baremetal',
            'host': '1.1.1.1',
            'password': 'r00t',
            'user': 'root',
            'ip': '1.1.1.1',
        },
        'benchmark': {
            'kpi': [
                'packets_in',
                'packets_fwd',
                'packets_dropped',
            ],
        },
        'connection-point': [
            {
                'type': 'VPORT',
                'name': 'xe0',
            },
            {
                'type': 'VPORT',
                'name': 'xe1',
            },
        ],
        'id': 'VpeApproxVnf',
        'name': 'VPEVnfSsh',
    }

    VNFD = {
        'vnfd:vnfd-catalog': {
            'vnfd': [
                VNFD_0,
            ],
        },
    }

    TRAFFIC_PROFILE = {
        "schema": "isb:traffic_profile:0.1",
        "name": "fixed",
        "description": "Fixed traffic profile to run UDP traffic",
        "traffic_profile": {
            "traffic_type": "FixedTraffic",
            "frame_rate": 100,  # pps
            "flow_number": 10,
            "frame_size": 64,
        },
    }

    CMD_KWARGS = {
        'target_ip': u'152.16.100.20',
        'local_ip': u'152.16.100.19',
        'local_if_name': u'xe0_fake',
    }

    @mock.patch("yardstick.ssh.SSH")
    def test___init__(self, ssh):
        ssh.from_node.return_value.execute.return_value = 0, "success", ""
        ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)

        self.assertIsInstance(ping_traffic_gen.setup_helper, PingSetupEnvHelper)
        self.assertIsInstance(ping_traffic_gen.resource_helper, PingResourceHelper)
        self.assertEquals(ping_traffic_gen._result, {})

    @mock.patch("yardstick.ssh.SSH")
    def test__bind_device_kernel_with_failure(self, ssh):
        mock_ssh(ssh)

        execute_result_data = [
            (1, 'bad stdout messages', 'error messages'),
            (0, '', ''),
            (0, 'if_name_1', ''),
            (0, 'if_name_2', ''),
        ]
        ssh.from_node.return_value.execute.side_effect = iter(execute_result_data)
        ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
        ext_ifs = ping_traffic_gen.vnfd_helper.interfaces
        self.assertNotEqual(ext_ifs[0]['virtual-interface']['local_iface_name'], 'if_name_1')
        self.assertNotEqual(ext_ifs[1]['virtual-interface']['local_iface_name'], 'if_name_2')

    @mock.patch("yardstick.ssh.SSH")
    def test_collect_kpi(self, ssh):
        mock_ssh(ssh, exec_result=(0, "success", ""))
        ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
        ping_traffic_gen._queue = Queue()
        ping_traffic_gen._queue.put({})
        ping_traffic_gen.collect_kpi()
        self.assertEqual(ping_traffic_gen._result, {})

    @mock.patch(SSH_HELPER)
    def test_instantiate(self, ssh):
        mock_ssh(ssh, spec=VnfSshHelper, exec_result=(0, "success", ""))
        ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
        ping_traffic_gen.setup_helper.ssh_helper = mock.MagicMock(
            **{"execute.return_value": (0, "xe0_fake", "")})
        self.assertIsInstance(ping_traffic_gen.ssh_helper, mock.Mock)
        self.assertEqual(ping_traffic_gen._result, {})

        self.assertIsNone(ping_traffic_gen.instantiate({}, {}))

        self.assertEqual(
            ping_traffic_gen.vnfd_helper.interfaces[0]['virtual-interface']['local_iface_name'],
            'xe0_fake')
        self.assertEqual(self.CMD_KWARGS, ping_traffic_gen.resource_helper.cmd_kwargs)
        self.assertIsNotNone(ping_traffic_gen._result)

    def test_listen_traffic(self):
        ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
        self.assertIsNone(ping_traffic_gen.listen_traffic({}))

    @mock.patch("yardstick.ssh.SSH")
    def test_terminate(self, ssh):
        ssh.from_node.return_value.execute.return_value = 0, "success", ""
        ssh.from_node.return_value.run.return_value = 0, "success", ""

        ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
        self.assertIsNone(ping_traffic_gen.terminate())