CSIT-651 Add keywords and template for memif 13/7013/33
authorPeter Mikus <pmikus@cisco.com>
Tue, 6 Jun 2017 05:15:29 +0000 (07:15 +0200)
committerPeter Mikus <pmikus@cisco.com>
Tue, 4 Jul 2017 04:54:16 +0000 (04:54 +0000)
Add keywords and template for memif

Change-Id: I8bd5cfe345260750a74930c8ef55690be5f2dd5e
Signed-off-by: Peter Mikus <pmikus@cisco.com>
docs/tag_documentation.rst
resources/libraries/python/Memif.py [new file with mode: 0644]
resources/libraries/python/VatExecutor.py
resources/libraries/robot/performance/performance_configuration.robot
resources/libraries/robot/performance/performance_setup.robot
resources/libraries/robot/performance/performance_utils.robot
resources/libraries/robot/shared/lxc.robot
resources/libraries/robot/shared/memif.robot [new file with mode: 0644]
resources/templates/vat/memif_create.vat [new file with mode: 0644]
resources/templates/vat/memif_create_lxc.vat [new file with mode: 0644]
resources/templates/vat/memif_dump.vat [new file with mode: 0644]

index 7c6cc47..3e2d44d 100644 (file)
@@ -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 (file)
index 0000000..09fa2a8
--- /dev/null
@@ -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))
index bfb7fce..a3f12bf 100644 (file)
@@ -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
index 17b8c68..f905f0c 100644 (file)
 | | ... | ${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}
index a2aaa52..de50fd3 100644 (file)
 | | ...
 | | 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
index 544aaeb..6c9f3a5 100644 (file)
@@ -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
index 83bd5c1..52d81dd 100644 (file)
 | | 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 (file)
index 0000000..2ce2ea2
--- /dev/null
@@ -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 (file)
index 0000000..228c824
--- /dev/null
@@ -0,0 +1 @@
+memif_create id {id} socket {socket} {role}\r
diff --git a/resources/templates/vat/memif_create_lxc.vat b/resources/templates/vat/memif_create_lxc.vat
new file mode 100644 (file)
index 0000000..873cb0b
--- /dev/null
@@ -0,0 +1,8 @@
+create memif id 1 socket /mnt/host/{socket1} slave\r
+set int state memif0 up\r
+\r
+create memif id 2 socket /mnt/host/{socket2} slave\r
+set int state memif1 up\r
+\r
+set interface l2 xconnect memif1 memif0\r
+set interface l2 xconnect memif0 memif1\r
diff --git a/resources/templates/vat/memif_dump.vat b/resources/templates/vat/memif_dump.vat
new file mode 100644 (file)
index 0000000..355f8f6
--- /dev/null
@@ -0,0 +1 @@
+memif_dump

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.