From: Peter Mikus Date: Tue, 6 Jun 2017 05:15:29 +0000 (+0200) Subject: CSIT-651 Add keywords and template for memif X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=commitdiff_plain;h=d166ae0881c29dfd05ed61b9a12156f17981bb6d CSIT-651 Add keywords and template for memif Add keywords and template for memif Change-Id: I8bd5cfe345260750a74930c8ef55690be5f2dd5e Signed-off-by: Peter Mikus --- diff --git a/docs/tag_documentation.rst b/docs/tag_documentation.rst index 7c6cc47c3b..3e2d44df73 100644 --- a/docs/tag_documentation.rst +++ b/docs/tag_documentation.rst @@ -344,6 +344,9 @@ Interface tags All test cases which uses Netmap. +.. topic:: MEMIF + + All test cases which uses Memif. Feature tags ------------ diff --git a/resources/libraries/python/Memif.py b/resources/libraries/python/Memif.py new file mode 100644 index 0000000000..09fa2a8c3e --- /dev/null +++ b/resources/libraries/python/Memif.py @@ -0,0 +1,80 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# 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. + +"""Memif interface library.""" + +from resources.libraries.python.ssh import SSH +from resources.libraries.python.VatExecutor import VatExecutor, VatTerminal + + +class Memif(object): + """Memif interface class.""" + + def __init__(self): + pass + + @staticmethod + def create_memif_interface(node, socket, mid, role="master"): + """Create Memif interface on the given node. + + :param node: Given node to create Memif interface on. + :param socket: Memif interface socket path. + :param mid: Memif interface ID. + :param role: Memif interface role [master|slave]. Default is master. + :type node: dict + :type socket: str + :type mid: str + :type role: str + :returns: SW interface index. + :rtype: int + :raises ValueError: If command 'create memif' fails. + """ + + with VatTerminal(node, json_param=False) as vat: + vat.vat_terminal_exec_cmd_from_template( + 'memif_create.vat', + socket=socket, id=mid, role=role) + if 'sw_if_index' in vat.vat_stdout: + try: + return int(vat.vat_stdout.split()[4]) + except KeyError: + raise ValueError('Create Memif interface failed on node ' + '{}"'.format(node['host'])) + else: + raise ValueError('Create Memif interface failed on node ' + '{}"'.format(node['host'])) + + @staticmethod + def show_memif(node): + """Show Memif data for the given node. + + :param node: Given node to show Memif data on. + :type node: dict + """ + vat = VatExecutor() + vat.execute_script("memif_dump.vat", node, json_out=False) + + @staticmethod + def clear_memif_socks(node, *socks): + """Clear Memif sockets for the given node. + + :param node: Given node to clear Memif sockets on. + :param socks: Memif sockets. + :type node: dict + :type socks: list + """ + ssh = SSH() + ssh.connect(node) + + for sock in socks: + ssh.exec_command_sudo('rm -f {}'.format(sock)) diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py index bfb7fce4e4..a3f12bf46f 100644 --- a/resources/libraries/python/VatExecutor.py +++ b/resources/libraries/python/VatExecutor.py @@ -245,6 +245,7 @@ class VatTerminal(object): 'sudo -S {}{}'.format(Constants.VAT_BIN_NAME, json_text), self.__VAT_PROMPT) self._exec_failure = False + self.vat_stdout = None def __enter__(self): return self @@ -265,6 +266,7 @@ class VatTerminal(object): try: out = self._ssh.interactive_terminal_exec_command(self._tty, cmd, self.__VAT_PROMPT) + self.vat_stdout = out except: self._exec_failure = True raise diff --git a/resources/libraries/robot/performance/performance_configuration.robot b/resources/libraries/robot/performance/performance_configuration.robot index 17b8c68545..f905f0cf3e 100644 --- a/resources/libraries/robot/performance/performance_configuration.robot +++ b/resources/libraries/robot/performance/performance_configuration.robot @@ -1595,3 +1595,48 @@ | | ... | ${dut1} | ${dut1_if1} | ${dut1_if2} | | Configure deterministic mode for SNAT | | ... | ${dut1} | 20.0.0.0 | 18 | 200.0.0.0 | 30 + +| Initialize L2 xconnect for '${nr}' memif pairs in 3-node circular topology +| | [Documentation] +| | ... | Create pairs of Memif interfaces on all defined VPP nodes. Cross +| | ... | connect each Memif interface with one physical interface or virtual +| | ... | interface to create a chain accross DUT node. +| | ... +| | ... | *Arguments:* +| | ... | _None_ +| | ... +| | ... | *Note:* +| | ... | Socket paths for Memif are defined in following format: +| | ... | - /tmp/memif-${number}-1 +| | ... | - /tmp/memif-${number}-2 +| | ... +| | ... | *Example:* +| | ... +| | ... | \| Initialize L2 xconnect for 1 Memif in 3-node circular topology \| +| | ... +| | Set Interface State | ${dut1} | ${dut1_if1} | up +| | Set Interface State | ${dut1} | ${dut1_if2} | up +| | Set Interface State | ${dut2} | ${dut2_if1} | up +| | Set Interface State | ${dut2} | ${dut2_if2} | up +| | :FOR | ${number} | IN RANGE | 1 | ${nr}+1 +| | | ${sock1}= | Set Variable | /tmp/memif-${number}-1 +| | | ${sock2}= | Set Variable | /tmp/memif-${number}-2 +| | | ${prev_index}= | Evaluate | ${number}-1 +| | | Set up memif interfaces on DUT node | ${dut1} +| | | ... | ${sock1} | ${sock2} | ${number} | dut1-memif-${number}-if1 +| | | ... | dut1-memif-${number}-if2 +| | | ${dut1_xconnect_if1}= | Set Variable If | ${number}==1 | ${dut1_if1} +| | | ... | ${dut1-memif-${prev_index}-if2} +| | | Configure L2XC | ${dut1} | ${dut1_xconnect_if1} +| | | ... | ${dut1-memif-${number}-if1} +| | | Set up memif interfaces on DUT node | ${dut2} +| | | ... | ${sock1} | ${sock2} | ${number} | dut2-memif-${number}-if1 +| | | ... | dut2-memif-${number}-if2 +| | | ${dut2_xconnect_if1}= | Set Variable If | ${number}==1 | ${dut2_if1} +| | | ... | ${dut2-memif-${prev_index}-if2} +| | | Configure L2XC | ${dut2} | ${dut2_xconnect_if1} +| | | ... | ${dut2-memif-${number}-if1} +| | | Run Keyword If | ${number}==${nr} | Configure L2XC +| | | ... | ${dut1} | ${dut1-memif-${number}-if2} | ${dut1_if2} +| | | Run Keyword If | ${number}==${nr} | Configure L2XC +| | | ... | ${dut2} | ${dut2-memif-${number}-if2} | ${dut2_if2} diff --git a/resources/libraries/robot/performance/performance_setup.robot b/resources/libraries/robot/performance/performance_setup.robot index a2aaa52bc8..de50fd3254 100644 --- a/resources/libraries/robot/performance/performance_setup.robot +++ b/resources/libraries/robot/performance/performance_setup.robot @@ -378,12 +378,26 @@ | | ... | | Teardown traffic generator | ${tg} +| Tear down 3-node performance topology with LXC +| | [Documentation] +| | ... | Suite teardown phase with traffic generator teardown and LXC destroy. +| | ... +| | Teardown traffic generator | ${tg} +| | Destroy '${lxc_count}' LXC containers on all DUT nodes + | Tear down 2-node performance topology | | [Documentation] | | ... | Suite teardown phase with traffic generator teardown. | | ... | | Teardown traffic generator | ${tg} +| Tear down 2-node performance topology with LXC +| | [Documentation] +| | ... | Suite teardown phase with traffic generator teardown and LXC destroy. +| | ... +| | Teardown traffic generator | ${tg} +| | Destroy '${lxc_count}' LXC containers on all DUT nodes + # Tests setups | Set up performance test diff --git a/resources/libraries/robot/performance/performance_utils.robot b/resources/libraries/robot/performance/performance_utils.robot index 544aaeb343..6c9f3a5930 100644 --- a/resources/libraries/robot/performance/performance_utils.robot +++ b/resources/libraries/robot/performance/performance_utils.robot @@ -23,6 +23,8 @@ | Resource | resources/libraries/robot/shared/default.robot | Resource | resources/libraries/robot/shared/interfaces.robot | Resource | resources/libraries/robot/shared/counters.robot +| Resource | resources/libraries/robot/shared/lxc.robot +| Resource | resources/libraries/robot/shared/memif.robot | Resource | resources/libraries/robot/l2/l2_bridge_domain.robot | Resource | resources/libraries/robot/l2/l2_xconnect.robot | Resource | resources/libraries/robot/ip/ip4.robot diff --git a/resources/libraries/robot/shared/lxc.robot b/resources/libraries/robot/shared/lxc.robot index 83bd5c1837..52d81dd3e4 100644 --- a/resources/libraries/robot/shared/lxc.robot +++ b/resources/libraries/robot/shared/lxc.robot @@ -227,7 +227,6 @@ | | Run keyword | ${lxc_name}_conf.Add unix exec | "/tmp/running.exec" | | Run keyword | ${lxc_name}_conf.Add CPU main core | "0" | | Run keyword | ${lxc_name}_conf.Add CPU corelist workers | ${lxc_cpus} -| | Run keyword | ${lxc_name}_conf.Add plugin disable | "dpdk_plugin.so" | | Run Keyword | ${lxc_name}_conf.Apply config LXC | ${lxc_name} | Create startup configuration of VPP on '${nr}' LXC containers on '${dut}' node diff --git a/resources/libraries/robot/shared/memif.robot b/resources/libraries/robot/shared/memif.robot new file mode 100644 index 0000000000..2ce2ea2e8c --- /dev/null +++ b/resources/libraries/robot/shared/memif.robot @@ -0,0 +1,79 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# 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. + +*** Settings *** +| Library | resources.libraries.python.Memif +| Documentation | Memif interface keyword library. + +*** Keywords *** +| Set up memif interfaces on DUT node +| | [Documentation] | Create two Memif interfaces on given VPP node. +| | ... +| | ... | *Arguments:* +| | ... | - ${dut_node} - DUT node. Type: dictionary +| | ... | - ${sock1} - Socket path for first Memif interface. Type: string +| | ... | - ${sock2} - Socket path for second Memif interface. Type: string +| | ... | - ${number} - Memif interface key. Type: integer +| | ... | - ${memif_if1} - Name of the first Memif interface (Optional). +| | ... | Type: string +| | ... | - ${memif_if2} - Name of the second Memif interface (Optional). +| | ... | Type: string +| | ... +| | ... | _NOTE:_ This KW sets following test case variable: +| | ... | - ${${memif_if1}} - First Memif interface. +| | ... | - ${${memif_if2}} - Second Memif interface. +| | ... +| | ... | *Example:* +| | ... +| | ... | \| Set up memif interfaces on DUT node \ +| | ... | \| ${nodes['DUT1']} \| /tmp/sock1 \| /tmp/sock2 \| 1 \| +| | ... | \| Set up memif interfaces on DUT node \ +| | ... | \| ${nodes['DUT2']} \| /tmp/sock1 \| /tmp/sock2 \| 1 \ +| | ... | \| dut2_memif_if1 \| dut2_memif_if2 \| +| | ... +| | [Arguments] | ${dut_node} | ${sock1} | ${sock2} | ${number}=${1} +| | ... | ${memif_if2}=memif_if1 | ${memif_if1}=memif_if2 +| | ${key_1}= | Evaluate | (${number}*2)-1 +| | ${key_2}= | Evaluate | (${number}*2) +| | ${memif_1}= | Create memif interface | ${dut_node} | ${sock1} | ${key_1} +| | ${memif_2}= | Create memif interface | ${dut_node} | ${sock2} | ${key_2} +| | Set Interface State | ${dut_node} | ${memif_1} | up +| | Set Interface State | ${dut_node} | ${memif_2} | up +| | Set Test Variable | ${${memif_if1}} | ${memif_1} +| | Set Test Variable | ${${memif_if2}} | ${memif_2} + +| Create memif VPP configuration on '${nr}' LXC containers on '${dut}' node +| | [Documentation] | Create memif configuration of VPP on multiple LXC +| | ... | container on DUT node. +| | ... +| | ... | *Example:* +| | ... +| | ... | \| Create memif VPP configuration on 1 LXC containers on DUT1 node \| +| | ... +| | :FOR | ${number} | IN RANGE | 1 | ${nr}+1 +| | | Run Keyword | ${dut}_${lxc_base_name}_${number}.Create VPP cfg in container +| | | ... | memif_create_lxc.vat | socket1=memif-${number}-1 +| | | ... | socket2=memif-${number}-2 + +| Create memif VPP configuration on '${nr}' LXC containers on all DUT nodes +| | [Documentation] | Create memif configuration of VPP on multiple LXC +| | ... | container on all DUT nodes. +| | ... +| | ... | *Example:* +| | ... +| | ... | \| Create memif VPP configuration on 1 LXC containers on all \ +| | ... | DUT nodes \| +| | ... +| | ${duts}= | Get Matches | ${nodes} | DUT* +| | :FOR | ${dut} | IN | @{duts} +| | | Create memif VPP configuration on '${nr}' LXC containers on '${dut}' node diff --git a/resources/templates/vat/memif_create.vat b/resources/templates/vat/memif_create.vat new file mode 100644 index 0000000000..228c824c25 --- /dev/null +++ b/resources/templates/vat/memif_create.vat @@ -0,0 +1 @@ +memif_create id {id} socket {socket} {role} diff --git a/resources/templates/vat/memif_create_lxc.vat b/resources/templates/vat/memif_create_lxc.vat new file mode 100644 index 0000000000..873cb0b68f --- /dev/null +++ b/resources/templates/vat/memif_create_lxc.vat @@ -0,0 +1,8 @@ +create memif id 1 socket /mnt/host/{socket1} slave +set int state memif0 up + +create memif id 2 socket /mnt/host/{socket2} slave +set int state memif1 up + +set interface l2 xconnect memif1 memif0 +set interface l2 xconnect memif0 memif1 diff --git a/resources/templates/vat/memif_dump.vat b/resources/templates/vat/memif_dump.vat new file mode 100644 index 0000000000..355f8f6efd --- /dev/null +++ b/resources/templates/vat/memif_dump.vat @@ -0,0 +1 @@ +memif_dump