aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/robot/shared
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2019-06-21 12:15:56 +0000
committerPeter Mikus <pmikus@cisco.com>2019-06-25 06:02:52 +0000
commit1577123a3c27541181097cb4186aa8855f20b1cc (patch)
tree8db2e4a954e97f7734988fd3d10b69504f370998 /resources/libraries/robot/shared
parentcac8f76ce1f9085e9eede19b250f4a4cb9b199e0 (diff)
Align suite/test teardown/setup
+ Phase II - aligning FUNC/PERF setup. + 2n/3n compatibility of suite setup. + Same structure of testcase for DEV/PERF. + DEVICE tests are now running VPP startup config in same way as PERF. + DEVICE is using COREKEEPER! - DEVICE tests are running topology compute twice for backward compatibility. TODO to remove. - Still phase III needed to align TAGS, LIBRARIES and remove OLD setup phase. Change-Id: Ib6e1b0ebf4abebf3cbe73b4fda5cac953c2a7270 Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries/robot/shared')
-rw-r--r--resources/libraries/robot/shared/container.robot73
-rw-r--r--resources/libraries/robot/shared/default.robot168
-rw-r--r--resources/libraries/robot/shared/suite_setup.robot246
-rw-r--r--resources/libraries/robot/shared/suite_teardown.robot2
-rw-r--r--resources/libraries/robot/shared/test_setup.robot57
-rw-r--r--resources/libraries/robot/shared/test_teardown.robot27
6 files changed, 455 insertions, 118 deletions
diff --git a/resources/libraries/robot/shared/container.robot b/resources/libraries/robot/shared/container.robot
index c1ab1af18d..0b2fcd489b 100644
--- a/resources/libraries/robot/shared/container.robot
+++ b/resources/libraries/robot/shared/container.robot
@@ -181,3 +181,76 @@
| | ... | all DUT nodes.
| | ...
| | Run Keyword | ${group}.Destroy all containers
+
+| Start containers for performance test
+| | [Documentation]
+| | ... | Start containers for performance test.
+| | ...
+| | ... | *Arguments:*
+| | ... | - nf_chains: Total number of chains. Type: integer
+| | ... | - nf_nodes: Total number of nodes per chain. Type: integer
+| | ... | - auto_scale - If True, use same amount of Dataplane threads for
+| | ... | network function as DUT, otherwise use single physical core for
+| | ... | every network function. Type: boolean
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Set up performance test with containers \| 1 \| 1 \|
+| | ...
+| | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${auto_scale}=${True}
+| | ...
+| | Set Test Variable | @{container_groups} | @{EMPTY}
+| | Set Test Variable | ${container_group} | CNF
+| | Set Test Variable | ${nf_nodes}
+| | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
+| | ... | engine=${container_engine} | WITH NAME | ${container_group}
+| | Construct chains of containers on all DUTs | ${nf_chains} | ${nf_nodes}
+| | ... | auto_scale=${auto_scale}
+| | Acquire all '${container_group}' containers
+| | Create all '${container_group}' containers
+| | Configure VPP in all '${container_group}' containers
+| | Stop VPP service on all DUTs | ${nodes}
+| | Start VPP in all '${container_group}' containers
+| | Restart VPP service on all DUTs | ${nodes}
+| | Verify VPP on all DUTs | ${nodes}
+| | Save VPP PIDs
+| | Append To List | ${container_groups} | ${container_group}
+
+| Start containers for device test
+| | [Documentation]
+| | ... | Start containers for device test.
+| | ...
+| | ... | *Arguments:*
+| | ... | - nf_chains: Total number of chains (Optional). Type: integer, default
+| | ... | value: ${1}
+| | ... | - nf_nodes: Total number of nodes per chain (Optional). Type: integer,
+| | ... | default value: ${1}
+| | ...
+| | ... | _NOTE:_ This KW sets following test case variables:
+| | ... | - dcr_uuid - Parent container UUID.
+| | ... | - dcr_root - Parent container overlay.
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Set up functional test with containers \| 1 \| 1 \|
+| | ...
+| | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1}
+| | ...
+| | Set Test Variable | @{container_groups} | @{EMPTY}
+| | Set Test Variable | ${container_group} | CNF
+| | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
+| | ... | engine=${container_engine} | WITH NAME | ${container_group}
+| | ...
+| | ${dcr_uuid}= | Get Environment Variable | CSIT_DUT1_UUID
+| | ${dcr_root}= | Run Keyword | Get Docker Mergeddir | ${nodes['DUT1']}
+| | ... | ${dcr_uuid}
+| | Set Test Variable | ${dcr_uuid}
+| | Set Test Variable | ${dcr_root}
+| | ...
+| | Construct chains of containers on all DUTs | ${nf_chains} | ${nf_nodes}
+| | ... | nested=${True}
+| | Acquire all '${container_group}' containers
+| | Create all '${container_group}' containers
+| | Configure VPP in all '${container_group}' containers
+| | Start VPP in all '${container_group}' containers
+| | Append To List | ${container_groups} | ${container_group}
diff --git a/resources/libraries/robot/shared/default.robot b/resources/libraries/robot/shared/default.robot
index b7e4a75773..31c4ae3e0a 100644
--- a/resources/libraries/robot/shared/default.robot
+++ b/resources/libraries/robot/shared/default.robot
@@ -33,18 +33,18 @@
| Library | resources.libraries.python.Trace
| Library | resources.libraries.python.topology.Topology
| ...
+| Resource | resources/libraries/robot/crypto/ipsec.robot
+| Resource | resources/libraries/robot/performance/performance_configuration.robot
+| Resource | resources/libraries/robot/performance/performance_limits.robot
+| Resource | resources/libraries/robot/performance/performance_utils.robot
| Resource | resources/libraries/robot/shared/container.robot
| Resource | resources/libraries/robot/shared/qemu.robot
| Resource | resources/libraries/robot/shared/suite_teardown.robot
+| Resource | resources/libraries/robot/shared/suite_setup.robot
| Resource | resources/libraries/robot/shared/test_teardown.robot
-
+| Resource | resources/libraries/robot/shared/test_setup.robot
*** Keywords ***
-| Configure all TGs for traffic script
-| | [Documentation] | Prepare all TGs before traffic scripts execution.
-| | ...
-| | All TGs Set Interface Default Driver | ${nodes}
-
| Show Vpp Errors On All DUTs
| | [Documentation] | Show VPP errors verbose on all DUTs.
| | ...
@@ -59,14 +59,6 @@
| | :FOR | ${dut} | IN | @{duts}
| | | Vpp Get Bridge Domain Data | ${nodes['${dut}']}
-| Setup Scheduler Policy for Vpp On All DUTs
-| | [Documentation] | Set realtime scheduling policy (SCHED_RR) with priority 1
-| | ... | on all VPP worker threads on all DUTs.
-| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
-| | :FOR | ${dut} | IN | @{duts}
-| | | Set VPP Scheduling rr | ${nodes['${dut}']}
-
| Configure crypto device on all DUTs
| | [Documentation] | Verify if Crypto QAT device virtual functions are
| | ... | initialized on all DUTs. If parameter force_init is set to True, then
@@ -85,37 +77,10 @@
| | ...
| | [Arguments] | ${crypto_type} | ${numvfs} | ${force_init}=${False}
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Crypto Device Verify | ${nodes['${dut}']} | ${crypto_type}
| | | ... | ${numvfs} | force_init=${force_init}
-| Configure AVF interfaces on all DUTs
-| | [Documentation] | Configure virtual functions for AVF interfaces on PCI
-| | ... | interface on all DUTs.
-| | ...
-| | ... | *Arguments:*
-| | ... | - numvfs - Number of VFs to initialize, 0 - disable the VFs
-| | ... | (Optional). Type: integer, default value: ${1}
-| | ... | - osi_layer - OSI Layer type to initialize TG with.
-| | ... | (Optional). Type: string, default value: L2
-| | ...
-| | ... | *Example:*
-| | ...
-| | ... | \| Configure AVF device on all DUTs \| ${1} \| L2 \|
-| | ...
-| | [Arguments] | ${numvfs}=${1} | ${osi_layer}=L2
-| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
-| | :FOR | ${dut} | IN | @{duts}
-| | | ${if1_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if1}
-| | | ... | numvfs=${numvfs} | osi_layer=${osi_layer}
-| | | ${if2_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if2}
-| | | ... | numvfs=${numvfs} | osi_layer=${osi_layer}
-# Currently only one AVF is supported.
-| | | Set Suite Variable | ${${dut}_if1_vf0} | ${if1_avf_arr[0]}
-| | | Set Suite Variable | ${${dut}_if2_vf0} | ${if2_avf_arr[0]}
-
| Configure kernel module on all DUTs
| | [Documentation] | Verify if specific kernel module is loaded on all DUTs.
| | ... | If parameter force_load is set to True, then try to load.
@@ -136,7 +101,6 @@
| Create base startup configuration of VPP on all DUTs
| | [Documentation] | Create base startup configuration of VPP to all DUTs.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Import Library | resources.libraries.python.VppConfigGenerator
| | | ... | WITH NAME | ${dut}
@@ -176,7 +140,6 @@
| | ...
| | ${cpu_count_int} | Convert to Integer | ${phy_cores}
| | ${thr_count_int} | Convert to Integer | ${phy_cores}
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
| | | ... | Variable Should Exist | ${${dut}_if1}
@@ -241,7 +204,6 @@
| | ...
| | ${cpu_count_int} | Convert to Integer | ${phy_cores}
| | ${thr_count_int} | Convert to Integer | ${phy_cores}
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | ${numa}= | Get interfaces numa node | ${nodes['${dut}']}
| | | ... | ${${dut}_if1} | ${${dut}_if2}
@@ -289,17 +251,68 @@
| | ... | cpu_skip=${cpu_skip} | filename=/tmp/vnf${i}.conf
| | ... | i=${i_int}
+| Add PCI devices to all DUTs
+| | [Documentation]
+| | ... | Add PCI devices to VPP configuration file.
+| | ...
+| | :FOR | ${dut} | IN | @{duts}
+| | | ${if1_status} | ${value}= | Run Keyword And Ignore Error
+| | | ... | Variable Should Exist | ${${dut}_if1}
+| | | ${if1_pci}= | Run Keyword If | '${if1_status}' == 'PASS'
+| | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if1}
+| | | ${if1_1_pci}= | Run Keyword Unless | '${if1_status}' == 'PASS'
+| | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if1_1}
+| | | ${if1_2_pci}= | Run Keyword Unless | '${if1_status}' == 'PASS'
+| | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if1_2}
+| | | ${if2_status} | ${value}= | Run Keyword And Ignore Error
+| | | ... | Variable Should Exist | ${${dut}_if2}
+| | | ${if2_pci}= | Run Keyword If | '${if2_status}' == 'PASS'
+| | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if2}
+| | | ${if2_1_pci}= | Run Keyword Unless | '${if2_status}' == 'PASS'
+| | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if2_1}
+| | | ${if2_2_pci}= | Run Keyword Unless | '${if2_status}' == 'PASS'
+| | | ... | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if2_2}
+| | | @{pci_devs}= | Run Keyword If | '${if1_status}' == 'PASS'
+| | | ... | Create List | ${if1_pci}
+| | | ... | ELSE
+| | | ... | Create List | ${if1_1_pci} | ${if1_2_pci}
+| | | Run Keyword If | '${if2_status}' == 'PASS'
+| | | ... | Append To List | ${pci_devs} | ${if2_pci}
+| | | ... | ELSE
+| | | ... | Append To List | ${pci_devs} | ${if2_1_pci} | ${if2_2_pci}
+| | | Run keyword | ${dut}.Add DPDK Dev | @{pci_devs}
+| | | Run Keyword If | '${if1_status}' == 'PASS'
+| | | ... | Set Test Variable | ${${dut}_if1_pci} | ${if1_pci}
+| | | Run Keyword Unless | '${if1_status}' == 'PASS'
+| | | ... | Set Test Variable | ${${dut}_if1_1_pci} | ${if1_1_pci}
+| | | Run Keyword Unless | '${if1_status}' == 'PASS'
+| | | ... | Set Test Variable | ${${dut}_if1_2_pci} | ${if1_2_pci}
+| | | Run Keyword If | '${if2_status}' == 'PASS'
+| | | ... | Set Test Variable | ${${dut}_if2_pci} | ${if2_pci}
+| | | Run Keyword Unless | '${if2_status}' == 'PASS'
+| | | ... | Set Test Variable | ${${dut}_if2_1_pci} | ${if2_1_pci}
+| | | Run Keyword Unless | '${if2_status}' == 'PASS'
+| | | ... | Set Test Variable | ${${dut}_if2_2_pci} | ${if2_2_pci}
+
+| Add single PCI device to all DUTs
+| | [Documentation]
+| | ... | Add single (first) PCI device on DUT1 and single (last) PCI device on
+| | ... | DUT2 to VPP configuration file.
+| | ...
+| | :FOR | ${dut} | IN | @{duts}
+| | | ${if1_pci}= | Get Interface PCI Addr | ${nodes['${dut}']} | ${${dut}_if1}
+| | | Run keyword | ${dut}.Add DPDK Dev | ${if1_pci}
+| | | Set Test Variable | ${${dut}_if1_pci} | ${if1_pci}
+
| Add no multi seg to all DUTs
| | [Documentation] | Add No Multi Seg to VPP startup configuration to all DUTs.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Add DPDK No Multi Seg
| Add DPDK no PCI to all DUTs
| | [Documentation] | Add DPDK no-pci to VPP startup configuration to all DUTs.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Add DPDK no PCI
@@ -316,7 +329,6 @@
| | ...
| | [Arguments] | ${rxd}
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Add DPDK Dev Default RXD | ${rxd}
@@ -333,7 +345,6 @@
| | ...
| | [Arguments] | ${txd}
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Add DPDK Dev Default TXD | ${txd}
@@ -350,14 +361,12 @@
| | ...
| | [Arguments] | ${uio_driver}
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Add DPDK Uio Driver | ${uio_driver}
| Add NAT to all DUTs
| | [Documentation] | Add NAT configuration to all DUTs.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Add NAT
@@ -372,7 +381,7 @@
| | ... | \| Add cryptodev to all DUTs \| ${4} \|
| | ...
| | [Arguments] | ${count}
-| | ${duts}= | Get Matches | ${nodes} | DUT*
+| | ...
| | :FOR | ${dut} | IN | @{duts}
| | | ${smt_used}= | Is SMT enabled | ${nodes['${dut}']['cpuinfo']}
| | | ${thr_count_int}= | Run keyword if | ${smt_used}
@@ -413,7 +422,6 @@
| Write startup configuration on all VPP DUTs
| | [Documentation] | Write VPP startup configuration on all DUTs.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Write Config
@@ -421,7 +429,6 @@
| | [Documentation] | Write VPP startup configuration and restart VPP on all
| | ... | DUTs.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Run keyword | ${dut}.Apply Config
| | Save VPP PIDs
@@ -435,6 +442,7 @@
| | ...
| | ${setup_vpp_pids}= | Get VPP PIDs | ${nodes}
| | ${keys}= | Get Dictionary Keys | ${setup_vpp_pids}
+| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${key} | IN | @{keys}
| | | ${pid}= | Get From Dictionary | ${setup_vpp_pids} | ${key}
| | | Run Keyword If | $pid is None | FAIL | No VPP PID found on node ${key}
@@ -462,7 +470,7 @@
| | Verify Vpp On All Duts | ${nodes}
| | VPP Enable Traces On All Duts | ${nodes}
| | Save VPP PIDs
-| | Configure all TGs for traffic script
+| | All TGs Set Interface Default Driver | ${nodes}
| | Update All Interface Data On All Nodes | ${nodes}
| | Reset PAPI History On All DUTs | ${nodes}
@@ -475,19 +483,6 @@
| | Vpp Show Errors On All DUTs | ${nodes}
| | Verify VPP PID in Teardown
-| Set up VPP device test
-# TODO: Generalize this KW if it will not diverge from Functional derivate too
-# much
-| | [Documentation] | Common test setup for vpp-device tests.
-| | ...
-| | Restart Vpp Service On All Duts | ${nodes}
-| | Verify Vpp On All Duts | ${nodes}
-| | VPP Enable Traces On All Duts | ${nodes}
-| | Save VPP PIDs
-| | Configure all TGs for traffic script
-| | Update All Interface Data On All Nodes | ${nodes} | skip_tg_udev=${True}
-| | Reset PAPI History On All DUTs | ${nodes}
-
| Tear down LISP functional test
| | [Documentation] | Common test teardown for functional tests with LISP.
| | ...
@@ -499,45 +494,6 @@
| | Vpp Show Errors On All DUTs | ${nodes}
| | Verify VPP PID in Teardown
-| Set up functional test with containers
-| | [Documentation]
-| | ... | Common test setup for functional tests with containers.
-| | ...
-| | ... | *Arguments:*
-| | ... | - chains: Total number of chains (Optional). Type: integer, default
-| | ... | value: ${1}
-| | ... | - nodeness: Total number of nodes per chain (Optional). Type: integer,
-| | ... | default value: ${1}
-| | ...
-| | ... | _NOTE:_ This KW sets following test case variables:
-| | ... | - dcr_uuid - Parent container UUID.
-| | ... | - dcr_root - Parent container overlay.
-| | ...
-| | ... | *Example:*
-| | ...
-| | ... | \| Set up functional test with containers \| 1 \| 1 \|
-| | ...
-| | [Arguments] | ${chains}=${1} | ${nodeness}=${1}
-| | ...
-| | Set Test Variable | @{container_groups} | @{EMPTY}
-| | Set Test Variable | ${container_group} | CNF
-| | Import Library | resources.libraries.python.ContainerUtils.ContainerManager
-| | ... | engine=${container_engine} | WITH NAME | ${container_group}
-| | ...
-| | ${dcr_uuid}= | Get Environment Variable | CSIT_DUT1_UUID
-| | ${dcr_root}= | Run Keyword | Get Docker Mergeddir | ${nodes['DUT1']}
-| | ... | ${dcr_uuid}
-| | Set Test Variable | ${dcr_uuid}
-| | Set Test Variable | ${dcr_root}
-| | ...
-| | Construct chains of containers on all DUTs | ${chains} | ${nodeness}
-| | ... | nested=${True}
-| | Acquire all '${container_group}' containers
-| | Create all '${container_group}' containers
-| | Configure VPP in all '${container_group}' containers
-| | Start VPP in all '${container_group}' containers
-| | Append To List | ${container_groups} | ${container_group}
-
| Stop VPP Service on DUT
| | [Documentation] | Stop the VPP service on the specified node.
| | ...
diff --git a/resources/libraries/robot/shared/suite_setup.robot b/resources/libraries/robot/shared/suite_setup.robot
new file mode 100644
index 0000000000..30fb5ac206
--- /dev/null
+++ b/resources/libraries/robot/shared/suite_setup.robot
@@ -0,0 +1,246 @@
+# Copyright (c) 2019 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.
+
+"""Keywords used in suite setups."""
+
+*** Settings ***
+| Library | resources.libraries.python.DPDK.DPDKTools
+| Library | resources.libraries.python.InterfaceUtil
+| Library | resources.libraries.python.NodePath
+| Library | resources.libraries.python.topology.Topology
+| Library | resources.libraries.python.TrafficGenerator
+| Library | resources.tools.wrk.wrk
+| ...
+| Documentation | Suite setup keywords.
+
+*** Keywords ***
+| Setup suite single link
+| | [Documentation]
+| | ... | Common suite setup for single link tests.
+| | ... |
+| | ... | Compute path for testing on two given nodes in circular topology
+| | ... | based on interface model provided as an argument and set
+| | ... | corresponding suite variables.
+| | ...
+| | ... | _NOTE:_ This KW sets following suite variables:
+| | ... | - duts - List of DUT nodes
+| | ... | - duts_count - Number of DUT nodes.
+| | ... | - tg - TG node
+| | ... | - tg_if1 - 1st TG interface towards DUT.
+| | ... | - tg_if1_mac - 1st TG interface MAC address.
+| | ... | - tg_if2 - 2nd TG interface towards DUT.
+| | ... | - tg_if2_mac - 2nd TG interface MAC address.
+| | ... | - dut{n} - DUTx node
+| | ... | - dut{n}_if1 - 1st DUT interface.
+| | ... | - dut{n}_if1_mac - 1st DUT interface MAC address.
+| | ... | - dut{n}_if2 - 2nd DUT interface.
+| | ... | - dut{n}_if2_mac - 2nd DUT interface MAC address.
+| | ...
+| | ... | *Arguments:*
+| | ... | - ${actions} - Additional setup action. Type: list
+| | ...
+| | [Arguments] | @{actions}
+| | ...
+| | ${nic_model_list}= | Create list | ${nic_name}
+| | Append Node | ${nodes['TG']}
+| | ${duts}= | Get Matches | ${nodes} | DUT*
+| | :FOR | ${dut} | IN | @{duts}
+| | | Append Node | ${nodes['${dut}']} | filter_list=${nic_model_list}
+| | Append Node | ${nodes['TG']}
+| | Compute Path | always_same_link=${FALSE}
+| | ${tg_if1} | ${tg}= | Next Interface
+| | :FOR | ${dut} | IN | @{duts}
+| | | ${dutx_if1} | ${dutx}= | Next Interface
+| | | ${dutx_if2} | ${dutx}= | Next Interface
+| | | ${dutx_if1_mac}= | Get Interface MAC | ${dutx} | ${dutx_if1}
+| | | ${dutx_if2_mac}= | Get Interface MAC | ${dutx} | ${dutx_if2}
+| | | ${dut_str}= | Convert To Lowercase | ${dut}
+| | | Set Suite Variable | ${${dut_str}} | ${dutx}
+| | | Set Suite Variable | ${${dut_str}_if1} | ${dutx_if1}
+| | | Set Suite Variable | ${${dut_str}_if2} | ${dutx_if2}
+| | | Set Suite Variable | ${${dut_str}_if1_mac} | ${dutx_if1_mac}
+| | | Set Suite Variable | ${${dut_str}_if2_mac} | ${dutx_if2_mac}
+| | ${tg_if2} | ${tg}= | Next Interface
+| | ${tg_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1}
+| | ${tg_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2}
+| | ${duts_count}= | Get Length | ${duts}
+| | Set Suite Variable | ${duts}
+| | Set Suite Variable | ${duts_count}
+| | Set Suite Variable | ${tg}
+| | Set Suite Variable | ${tg_if1}
+| | Set Suite Variable | ${tg_if1_mac}
+| | Set Suite Variable | ${tg_if2}
+| | Set Suite Variable | ${tg_if2_mac}
+| | :FOR | ${action} | IN | @{actions}
+| | | Run Keyword | Additional Suite setup Action For ${action}
+
+| Setup suite double link
+| | [Documentation]
+| | ... | Common suite setup for double link tests.
+| | ... |
+| | ... | Compute path for testing on three given nodes in circular topology
+| | ... | with double link between DUTs based on interface model provided as an
+| | ... | argument and set corresponding suite variables.
+| | ...
+| | ... | *Arguments:*
+| | ... | - ${actions} - Additional setup action. Type: list
+| | ...
+| | ... | _NOTE:_ This KW sets following suite variables:
+| | ... | - duts - List of DUT nodes
+| | ... | - duts_count - Number of DUT nodes.
+| | ... | - tg - TG node
+| | ... | - tg_if1 - 1st TG interface towards DUT.
+| | ... | - tg_if1 - 1st TG interface MAC address.
+| | ... | - tg_if2 - 2nd TG interface towards DUT.
+| | ... | - tg_if2 - 2nd TG interface MAC address.
+| | ... | - dut1 - DUT1 node
+| | ... | - dut1_if1 - DUT1 interface towards TG.
+| | ... | - dut1_if2_1 - DUT1 interface 1 towards DUT2.
+| | ... | - dut1_if2_2 - DUT1 interface 2 towards DUT2.
+| | ... | - dut2 - DUT2 node
+| | ... | - dut2_if1_1 - DUT2 interface 1 towards DUT1.
+| | ... | - dut2_if1_2 - DUT2 interface 2 towards DUT1.
+| | ... | - dut2_if2 - DUT2 interface towards TG.
+| | ...
+| | [Arguments] | @{actions}
+| | ...
+| | ${nic_model_list}= | Create list | ${nic_name}
+| | # Compute path TG - DUT1 with single link in between
+| | Append Node | ${nodes['TG']}
+| | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
+| | Append Node | ${nodes['TG']}
+| | Compute Path
+| | ${tg_if1} | ${tg}= | Next Interface
+| | ${dut1_if1} | ${dut1}= | Next Interface
+| | # Compute path TG - DUT2 with single link in between
+| | Clear Path
+| | Append Node | ${nodes['TG']}
+| | Append Node | ${nodes['DUT2']} | filter_list=${nic_model_list}
+| | Append Node | ${nodes['TG']}
+| | Compute Path
+| | ${tg_if2} | ${tg}= | Next Interface
+| | ${dut2_if2} | ${dut2}= | Next Interface
+| | # Compute path DUT1 - DUT2 with double link in between
+| | Clear Path
+| | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
+| | Append Node | ${nodes['DUT2']} | filter_list=${nic_model_list}
+| | Append Node | ${nodes['DUT1']} | filter_list=${nic_model_list}
+| | Compute Path | always_same_link=${FALSE}
+| | ${dut1_if2_1} | ${dut1}= | First Interface
+| | ${dut1_if2_2} | ${dut1}= | Last Interface
+| | ${dut2_if1_1} | ${dut2}= | First Ingress Interface
+| | ${dut2_if1_2} | ${dut2}= | Last Egress Interface
+| | ${tg_if1_mac}= | Get Interface MAC | ${tg} | ${tg_if1}
+| | ${tg_if2_mac}= | Get Interface MAC | ${tg} | ${tg_if2}
+| | ${duts_count}= | Set Variable | 2
+| | ${duts}= | Get Matches | ${nodes} | DUT*
+| | # Set suite variables
+| | Set Suite Variable | ${duts}
+| | Set Suite Variable | ${duts_count}
+| | Set Suite Variable | ${tg}
+| | Set Suite Variable | ${tg_if1}
+| | Set Suite Variable | ${tg_if1_mac}
+| | Set Suite Variable | ${tg_if2}
+| | Set Suite Variable | ${tg_if2_mac}
+| | Set Suite Variable | ${dut1}
+| | Set Suite Variable | ${dut1_if1}
+| | Set Suite Variable | ${dut1_if2_1}
+| | Set Suite Variable | ${dut1_if2_2}
+| | Set Suite Variable | ${dut2}
+| | Set Suite Variable | ${dut2_if1_1}
+| | Set Suite Variable | ${dut2_if1_2}
+| | Set Suite Variable | ${dut2_if2}
+| | :FOR | ${action} | IN | @{actions}
+| | | Run Keyword | Additional Suite setup Action For ${action}
+
+| Additional Suite Setup Action For performance
+| | [Documentation]
+| | ... | Additional Setup for suites which uses performance measurement.
+| | ...
+| | Run Keyword If | ${duts_count} == 1
+| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
+| | ... | ${dut1} | ${dut1_if1} | ${dut1} | ${dut1_if2} | ${osi_layer}
+| | Run Keyword If | ${duts_count} == 2
+| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
+| | ... | ${dut1} | ${dut1_if1} | ${dut2} | ${dut2_if2} | ${osi_layer}
+
+| Additional Suite Setup Action For dpdk
+| | [Documentation]
+| | ... | Additional Setup for suites which uses dpdk.
+| | ...
+| | :FOR | ${dut} | IN | @{duts}
+| | | ${dut_str}= | Convert To Lowercase | ${dut}
+| | | Initialize DPDK Environment | ${nodes['${dut}']}
+| | | ... | ${${dut_str}_if1} | ${${dut_str}_if2}
+
+| Additional Suite Setup Action For performance_avf
+| | [Documentation]
+| | ... | Additional Setup for suites which uses performance measurement over
+| | ... | SRIOV AVF.
+| | ...
+| | :FOR | ${dut} | IN | @{duts}
+| | | ${if1_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if1}
+| | | ... | numvfs=${1} | osi_layer=${osi_layer}
+| | | ${if2_avf_arr}= | Init AVF interface | ${nodes['${dut}']} | ${${dut}_if2}
+| | | ... | numvfs=${1} | osi_layer=${osi_layer}
+# Currently only one AVF is supported.
+| | | Set Suite Variable | ${${dut}_if1_vf0} | ${if1_avf_arr[0]}
+| | | Set Suite Variable | ${${dut}_if2_vf0} | ${if2_avf_arr[0]}
+| | Run Keyword If | ${duts_count} == 1
+| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
+| | ... | ${dut1} | ${dut1_if1_vf0} | ${dut1} | ${dut1_if2_vf0} | ${osi_layer}
+| | Run Keyword If | ${duts_count} == 2
+| | ... | Initialize traffic generator | ${tg} | ${tg_if1} | ${tg_if2}
+| | ... | ${dut1} | ${dut1_if1_vf0} | ${dut2} | ${dut2_if2_vf0} | ${osi_layer}
+
+| Additional Suite Setup Action For ipsechw
+| | [Documentation]
+| | ... | Additional Setup for suites which uses QAT HW.
+| | ...
+| | ${numvfs}= | Set Variable If
+| | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
+| | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
+| | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
+| | ... | force_init=${True}
+| | Configure kernel module on all DUTs | vfio_pci | force_load=${True}
+
+| Additional Suite Setup Action For wrk
+| | [Documentation]
+| | ... | Additional Setup for suites which uses WRK TG.
+| | ...
+| | Iface update numa node | ${tg}
+# Make sure TRex is stopped
+| | ${running}= | Is TRex running | ${tg}
+| | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
+| | ${curr_driver}= | Get PCI dev driver | ${tg}
+| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
+| | Run keyword if | '${curr_driver}'!='${None}'
+| | ... | PCI Driver Unbind | ${tg} |
+| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
+# Bind tg_if1 to driver specified in the topology
+| | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
+| | PCI Driver Bind | ${tg}
+| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
+# Set IP on tg_if1
+| | ${intf_name}= | Get Linux interface name | ${tg}
+| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.10.1 | 24
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.20.1 | 24
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.30.1 | 24
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.40.1 | 24
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.50.1 | 24
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.60.1 | 24
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.70.1 | 24
+| | Set Linux interface IP | ${tg} | ${intf_name} | 192.168.80.1 | 24
+| | Set Linux interface up | ${tg} | ${intf_name}
+| | Install wrk | ${tg}
diff --git a/resources/libraries/robot/shared/suite_teardown.robot b/resources/libraries/robot/shared/suite_teardown.robot
index 1b738eaeef..e5db4f05d8 100644
--- a/resources/libraries/robot/shared/suite_teardown.robot
+++ b/resources/libraries/robot/shared/suite_teardown.robot
@@ -15,6 +15,7 @@
*** Settings ***
| Library | resources.libraries.python.DPDK.DPDKTools
+| Library | resources.libraries.python.TrafficGenerator
| ...
| Documentation | Suite teardown keywords.
@@ -41,7 +42,6 @@
| | [Documentation]
| | ... | Additional teardown for suites which uses dpdk.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Cleanup DPDK Environment
| | | ... | ${nodes['${dut}']} | ${${dut}_if1} | ${${dut}_if2}
diff --git a/resources/libraries/robot/shared/test_setup.robot b/resources/libraries/robot/shared/test_setup.robot
new file mode 100644
index 0000000000..17e9e6c459
--- /dev/null
+++ b/resources/libraries/robot/shared/test_setup.robot
@@ -0,0 +1,57 @@
+# Copyright (c) 2019 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.
+
+"""Keywords used in test setups."""
+
+*** Settings ***
+| Library | resources.libraries.python.PapiHistory
+| ...
+| Documentation | Test Setup keywords.
+
+*** Keywords ***
+| Setup test
+| | [Documentation]
+| | ... | Common test setup for tests.
+| | ...
+| | ... | *Arguments:*
+| | ... | - ${actions} - Additional setup action. Type: list
+| | ...
+| | [Arguments] | @{actions}
+| | ...
+| | Reset PAPI History On All DUTs | ${nodes}
+| | Create base startup configuration of VPP on all DUTs
+| | :FOR | ${action} | IN | @{actions}
+| | | Run Keyword | Additional Test Setup Action For ${action}
+
+| Additional Test Setup Action For namespace
+| | [Documentation]
+| | ... | Additional Setup for tests which uses namespace.
+| | ...
+| | :FOR | ${dut} | IN | @{duts}
+| | | Clean Up Namespaces | ${nodes['${dut}']}
+
+| Additional Test Setup Action For ligato
+| | [Documentation]
+| | ... | Additional Setup for tests which uses Ligato Kubernetes.
+| | ...
+| | Apply Kubernetes resource on all duts | ${nodes} | namespaces/csit.yaml
+| | Apply Kubernetes resource on all duts | ${nodes} | pods/kafka.yaml
+| | Apply Kubernetes resource on all duts | ${nodes} | pods/etcdv3.yaml
+| | Apply Kubernetes resource on all duts | ${nodes}
+| | ... | configmaps/vswitch-agent-cfg.yaml
+| | Apply Kubernetes resource on all duts | ${nodes}
+| | ... | configmaps/vnf-agent-cfg.yaml
+| | Apply Kubernetes resource on all duts | ${nodes}
+| | ... | pods/contiv-sfc-controller.yaml
+| | Apply Kubernetes resource on all duts | ${nodes}
+| | ... | pods/contiv-vswitch.yaml
diff --git a/resources/libraries/robot/shared/test_teardown.robot b/resources/libraries/robot/shared/test_teardown.robot
index e30aa9f41e..f95e369b65 100644
--- a/resources/libraries/robot/shared/test_teardown.robot
+++ b/resources/libraries/robot/shared/test_teardown.robot
@@ -14,6 +14,11 @@
"""Keywords used in test teardowns."""
*** Settings ***
+| Resource | resources/libraries/robot/shared/container.robot
+| Resource | resources/libraries/robot/shared/qemu.robot
+| Library | resources.libraries.python.PapiHistory
+| Library | resources.libraries.python.topology.Topology
+| ...
| Documentation | Test teardown keywords.
*** Keywords ***
@@ -28,8 +33,10 @@
| | ...
| | Remove All Added Ports On All DUTs From Topology | ${nodes}
| | Show PAPI History On All DUTs | ${nodes}
-| | Get Core Files on All Nodes | ${nodes}
-| | Verify VPP PID in Teardown
+| | Run Keyword If Test Failed
+| | ... | Get Core Files on All Nodes | ${nodes}
+| | Run Keyword If Test Failed
+| | ... | Verify VPP PID in Teardown
| | :FOR | ${action} | IN | @{actions}
| | | Run Keyword | Additional Test Tear Down Action For ${action}
@@ -59,7 +66,6 @@
| | [Documentation]
| | ... | Additional teardown for tests which uses vhost(s) and VM(s).
| | ...
-| | # TODO: Remove IF condition once devicetest is running KernelVM.
| | Show VPP vhost on all DUTs | ${nodes}
| | Run Keyword If | "PERFTEST" in @{TEST TAGS} | vnf_manager.Kill All VMs
| | Run Keyword If | "DEVICETEST" in @{TEST TAGS} | vm_node.Qemu Kill
@@ -68,15 +74,14 @@
| | [Documentation]
| | ... | Additional teardown for tests which uses NAT feature.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
-| | | Show NAT verbose | ${nodes['${dut}']}
+| | | Run Keyword If Test Failed
+| | | ... | Show NAT verbose | ${nodes['${dut}']}
| Additional Test Tear Down Action For namespace
| | [Documentation]
| | ... | Additional teardown for tests which uses namespace.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Clean Up Namespaces | ${nodes['${dut}']}
@@ -84,7 +89,6 @@
| | [Documentation]
| | ... | Additional teardown for tests which uses linux_bridge.
| | ...
-| | ${duts}= | Get Matches | ${nodes} | DUT*
| | :FOR | ${dut} | IN | @{duts}
| | | Linux Del Bridge | ${nodes['${dut}']} | ${bid_TAP}
@@ -94,16 +98,16 @@
| | ...
| | Run Keyword If Test Failed
| | ... | Vpp Log Plugin Acl Settings | ${dut1}
-| | Run Keyword If Test Failed | Run Keyword And Ignore Error
+| | Run Keyword If Test Failed
| | ... | Vpp Log Plugin Acl Interface Assignment | ${dut1}
| Additional Test Tear Down Action For macipacl
| | [Documentation]
| | ... | Additional teardown for tests which uses MACIP ACL feature.
| | ...
-| | Run Keyword If Test Failed | Run Keyword And Ignore Error
+| | Run Keyword If Test Failed
| | ... | Vpp Log Macip Acl Settings | ${dut1}
-| | Run Keyword And Ignore Error
+| | Run Keyword If Test Failed
| | ... | Vpp Log Macip Acl Interface Assignment | ${dut1}
| Additional Test Tear Down Action For srv6
@@ -114,7 +118,8 @@
| | ... | Show SR Policies on all DUTs | ${nodes}
| | Run Keyword If Test Failed
| | ... | Show SR Steering Policies on all DUTs | ${nodes}
-| | Run Keyword If Test Failed | Show SR LocalSIDs on all DUTs | ${nodes}
+| | Run Keyword If Test Failed
+| | ... | Show SR LocalSIDs on all DUTs | ${nodes}
| Additional Test Tear Down Action For ligato
| | [Documentation]
ss="n">ip4_header_t *) & tp->ip4; udp = (udp_header_t *) (ip + 1); ASSERT (f - first_field); /* Field count in this template */ t->id_count = ipfix_id_count (fr->template_id, f - first_field); /* set length in octets */ s->set_id_length = ipfix_set_id_length (2 /* set_id */ , (u8 *) f - (u8 *) s); /* message length in octets */ h->version_length = version_length ((u8 *) f - (u8 *) h); ip->length = clib_host_to_net_u16 ((u8 *) f - (u8 *) ip); ip->checksum = ip4_header_checksum (ip); return rewrite; } vlib_buffer_t * vnet_ipfix_exp_get_buffer (vlib_main_t *vm, ipfix_exporter_t *exp, flow_report_t *fr, u32 thread_index) { u32 bi0; vlib_buffer_t *b0; if (fr->per_thread_data[thread_index].buffer) return fr->per_thread_data[thread_index].buffer; if (vlib_buffer_alloc (vm, &bi0, 1) != 1) return NULL; /* Initialize the buffer */ b0 = fr->per_thread_data[thread_index].buffer = vlib_get_buffer (vm, bi0); b0->current_data = 0; b0->current_length = exp->all_headers_size; b0->flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_FLOW_REPORT); vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; vnet_buffer (b0)->sw_if_index[VLIB_TX] = exp->fib_index; fr->per_thread_data[thread_index].next_data_offset = b0->current_length; return b0; } /* * Send a buffer that is mostly populated. Has flow records but needs some * header fields updated. */ void vnet_ipfix_exp_send_buffer (vlib_main_t *vm, ipfix_exporter_t *exp, flow_report_t *fr, flow_report_stream_t *stream, u32 thread_index, vlib_buffer_t *b0) { flow_report_main_t *frm = &flow_report_main; vlib_frame_t *f; ip4_ipfix_template_packet_t *tp; ipfix_set_header_t *s; ipfix_message_header_t *h; ip4_header_t *ip; udp_header_t *udp; /* nothing to send */ if (fr->per_thread_data[thread_index].next_data_offset <= exp->all_headers_size) return; tp = vlib_buffer_get_current (b0); ip = (ip4_header_t *) &tp->ip4; udp = (udp_header_t *) (ip + 1); h = (ipfix_message_header_t *) (udp + 1); s = (ipfix_set_header_t *) (h + 1); ip->ip_version_and_header_length = 0x45; ip->ttl = 254; ip->protocol = IP_PROTOCOL_UDP; ip->flags_and_fragment_offset = 0; ip->src_address.as_u32 = exp->src_address.as_u32; ip->dst_address.as_u32 = exp->ipfix_collector.as_u32; udp->src_port = clib_host_to_net_u16 (stream->src_port); udp->dst_port = clib_host_to_net_u16 (exp->collector_port); udp->checksum = 0; /* FIXUP: message header export_time */ h->export_time = (u32) (((f64) frm->unix_time_0) + (vlib_time_now (vm) - frm->vlib_time_0)); h->export_time = clib_host_to_net_u32 (h->export_time); h->domain_id = clib_host_to_net_u32 (stream->domain_id); /* * RFC 7011: Section 3.2 * * Incremental sequence counter modulo 2^32 of all IPFIX Data Records * sent in the current stream from the current Observation Domain by * the Exporting Process */ h->sequence_number = clib_atomic_fetch_add (&stream->sequence_number, fr->per_thread_data[thread_index].n_data_records); h->sequence_number = clib_host_to_net_u32 (h->sequence_number); /* * For data records we use the template ID as the set ID. * RFC 7011: 3.4.3 */ s->set_id_length = ipfix_set_id_length ( fr->template_id, b0->current_length - (sizeof (*ip) + sizeof (*udp) + sizeof (*h))); h->version_length = version_length (b0->current_length - (sizeof (*ip) + sizeof (*udp))); ip->length = clib_host_to_net_u16 (b0->current_length); ip->checksum = ip4_header_checksum (ip); udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip)); if (exp->udp_checksum) { /* RFC 7011 section 10.3.2. */ udp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip); if (udp->checksum == 0) udp->checksum = 0xffff; } ASSERT (ip4_header_checksum_is_valid (ip)); /* Find or allocate a frame */ f = fr->per_thread_data[thread_index].frame; if (PREDICT_FALSE (f == 0)) { u32 *to_next; f = vlib_get_frame_to_node (vm, ip4_lookup_node.index); fr->per_thread_data[thread_index].frame = f; u32 bi0 = vlib_get_buffer_index (vm, b0); /* Enqueue the buffer */ to_next = vlib_frame_vector_args (f); to_next[0] = bi0; f->n_vectors = 1; } vlib_put_frame_to_node (vm, ip4_lookup_node.index, f); fr->per_thread_data[thread_index].frame = NULL; fr->per_thread_data[thread_index].buffer = NULL; fr->per_thread_data[thread_index].next_data_offset = 0; } static uword flow_report_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { flow_report_main_t *frm = &flow_report_main; flow_report_t *fr; u32 ip4_lookup_node_index; vlib_node_t *ip4_lookup_node; vlib_frame_t *nf = 0; u32 template_bi; u32 *to_next; int send_template; f64 now, wait_time; f64 def_wait_time = 5.0; int rv; uword event_type; uword *event_data = 0; /* Wait for Godot... */ vlib_process_wait_for_event_or_clock (vm, 1e9); event_type = vlib_process_get_events (vm, &event_data); if (event_type != 1) clib_warning ("bogus kickoff event received, %d", event_type); vec_reset_length (event_data); /* Enqueue pkts to ip4-lookup */ ip4_lookup_node = vlib_get_node_by_name (vm, (u8 *) "ip4-lookup"); ip4_lookup_node_index = ip4_lookup_node->index; wait_time = def_wait_time; while (1) { vlib_process_wait_for_event_or_clock (vm, wait_time); event_type = vlib_process_get_events (vm, &event_data); vec_reset_length (event_data); ipfix_exporter_t *exp; pool_foreach (exp, frm->exporters) { /* 5s delay by default, possibly reduced by template intervals */ wait_time = def_wait_time; vec_foreach (fr, exp->reports) { f64 next_template; now = vlib_time_now (vm); /* Need to send a template packet? */ send_template = now > (fr->last_template_sent + exp->template_interval); send_template += fr->last_template_sent == 0; template_bi = ~0; rv = 0; if (send_template) rv = send_template_packet (frm, exp, fr, &template_bi); if (rv < 0) continue; /* * decide if template should be sent sooner than current wait * time */ next_template = (fr->last_template_sent + exp->template_interval) - now; wait_time = clib_min (wait_time, next_template); nf = vlib_get_frame_to_node (vm, ip4_lookup_node_index); nf->n_vectors = 0; to_next = vlib_frame_vector_args (nf); if (template_bi != ~0) { to_next[0] = template_bi; to_next++; nf->n_vectors++; } nf = fr->flow_data_callback (frm, exp, fr, nf, to_next, ip4_lookup_node_index); if (nf) vlib_put_frame_to_node (vm, ip4_lookup_node_index, nf); } } } return 0; /* not so much */ } /* *INDENT-OFF* */ VLIB_REGISTER_NODE (flow_report_process_node) = { .function = flow_report_process, .type = VLIB_NODE_TYPE_PROCESS, .name = "flow-report-process", }; /* *INDENT-ON* */ int vnet_flow_report_add_del (ipfix_exporter_t *exp, vnet_flow_report_add_del_args_t *a, u16 *template_id) { int i; int found_index = ~0; flow_report_t *fr; flow_report_stream_t *stream; u32 si; vlib_thread_main_t *tm = &vlib_thread_main; flow_report_main_t *frm = &flow_report_main; vlib_main_t *vm = frm->vlib_main; int size; si = find_stream (exp, a->domain_id, a->src_port); if (si == -2) return VNET_API_ERROR_INVALID_VALUE; if (si == -1 && a->is_add == 0) return VNET_API_ERROR_NO_SUCH_ENTRY; for (i = 0; i < vec_len (exp->reports); i++) { fr = vec_elt_at_index (exp->reports, i); if (fr->opaque.as_uword == a->opaque.as_uword && fr->rewrite_callback == a->rewrite_callback && fr->flow_data_callback == a->flow_data_callback) { found_index = i; if (template_id) *template_id = fr->template_id; break; } } if (a->is_add == 0) { if (found_index != ~0) { for (int i = 0; i < vec_len (exp->reports[found_index].per_thread_data); i++) { u32 bi; if (exp->reports[found_index].per_thread_data[i].buffer) { bi = vlib_get_buffer_index ( vm, exp->reports[found_index].per_thread_data[i].buffer); vlib_buffer_free (vm, &bi, 1); } } vec_free (exp->reports[found_index].per_thread_data); vec_delete (exp->reports, 1, found_index); stream = &exp->streams[si]; stream->n_reports--; if (stream->n_reports == 0) delete_stream (exp, si); return 0; } return VNET_API_ERROR_NO_SUCH_ENTRY; } if (found_index != ~0) return VNET_API_ERROR_VALUE_EXIST; if (si == -1) { stream = add_stream (exp); stream->domain_id = a->domain_id; stream->src_port = a->src_port; stream->sequence_number = 0; stream->n_reports = 0; si = stream - exp->streams; } else stream = &exp->streams[si]; stream->n_reports++; vec_add2 (exp->reports, fr, 1); fr->stream_index = si; fr->template_id = 256 + stream->next_template_no; stream->next_template_no = (stream->next_template_no + 1) % (65536 - 256); fr->update_rewrite = 1; fr->opaque = a->opaque; fr->rewrite_callback = a->rewrite_callback; fr->flow_data_callback = a->flow_data_callback; fr->report_elements = a->report_elements; fr->n_report_elements = a->n_report_elements; fr->stream_indexp = a->stream_indexp; vec_validate (fr->per_thread_data, tm->n_threads); /* Store the flow_report index back in the args struct */ a->flow_report_index = fr - exp->reports; size = 0; for (int i = 0; i < fr->n_report_elements; i++) size += fr->report_elements[i].size; fr->data_record_size = size; if (template_id) *template_id = fr->template_id; return 0; } clib_error_t * flow_report_add_del_error_to_clib_error (int error) { switch (error) { case 0: return 0; case VNET_API_ERROR_NO_SUCH_ENTRY: return clib_error_return (0, "Flow report not found"); case VNET_API_ERROR_VALUE_EXIST: return clib_error_return (0, "Flow report already exists"); case VNET_API_ERROR_INVALID_VALUE: return clib_error_return (0, "Expecting either still unused values " "for both domain_id and src_port " "or already used values for both fields"); default: return clib_error_return (0, "vnet_flow_report_add_del returned %d", error); } } void vnet_flow_reports_reset (ipfix_exporter_t *exp) { flow_report_t *fr; u32 i; for (i = 0; i < vec_len (exp->streams); i++) if (stream_index_valid (exp, i)) exp->streams[i].sequence_number = 0; vec_foreach (fr, exp->reports) { fr->update_rewrite = 1; fr->last_template_sent = 0; } } void vnet_stream_reset (ipfix_exporter_t *exp, u32 stream_index) { flow_report_t *fr; exp->streams[stream_index].sequence_number = 0; vec_foreach (fr, exp->reports) if (exp->reports->stream_index == stream_index) { fr->update_rewrite = 1; fr->last_template_sent = 0; } } int vnet_stream_change (ipfix_exporter_t *exp, u32 old_domain_id, u16 old_src_port, u32 new_domain_id, u16 new_src_port) { i32 stream_index = find_stream (exp, old_domain_id, old_src_port); if (stream_index < 0) return 1; flow_report_stream_t *stream = &exp->streams[stream_index]; stream->domain_id = new_domain_id; stream->src_port = new_src_port; if (old_domain_id != new_domain_id || old_src_port != new_src_port) vnet_stream_reset (exp, stream_index); return 0; } static clib_error_t * set_ipfix_exporter_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { flow_report_main_t *frm = &flow_report_main; ip4_address_t collector, src; u16 collector_port = UDP_DST_PORT_ipfix; u32 fib_id; u32 fib_index = ~0; collector.as_u32 = 0; src.as_u32 = 0; u32 path_mtu = 512; // RFC 7011 section 10.3.3. u32 template_interval = 20; u8 udp_checksum = 0; ipfix_exporter_t *exp = pool_elt_at_index (frm->exporters, 0); while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "collector %U", unformat_ip4_address, &collector)) ; else if (unformat (input, "port %U", unformat_udp_port, &collector_port)) ; else if (unformat (input, "src %U", unformat_ip4_address, &src)) ; else if (unformat (input, "fib-id %u", &fib_id)) { ip4_main_t *im = &ip4_main; uword *p = hash_get (im->fib_index_by_table_id, fib_id); if (!p) return clib_error_return (0, "fib ID %d doesn't exist\n", fib_id); fib_index = p[0]; } else if (unformat (input, "path-mtu %u", &path_mtu)) ; else if (unformat (input, "template-interval %u", &template_interval)) ; else if (unformat (input, "udp-checksum")) udp_checksum = 1; else break; } if (collector.as_u32 != 0 && src.as_u32 == 0) return clib_error_return (0, "src address required"); if (path_mtu > 1450 /* vpp does not support fragmentation */ ) return clib_error_return (0, "too big path-mtu value, maximum is 1450"); if (path_mtu < 68) return clib_error_return (0, "too small path-mtu value, minimum is 68"); /* Calculate how much header data we need. */ exp->all_headers_size = sizeof (ip4_header_t) + sizeof (udp_header_t) + sizeof (ipfix_message_header_t) + sizeof (ipfix_set_header_t); /* Reset report streams if we are reconfiguring IP addresses */ if (exp->ipfix_collector.as_u32 != collector.as_u32 || exp->src_address.as_u32 != src.as_u32 || exp->collector_port != collector_port) vnet_flow_reports_reset (exp); exp->ipfix_collector.as_u32 = collector.as_u32; exp->collector_port = collector_port; exp->src_address.as_u32 = src.as_u32; exp->fib_index = fib_index; exp->path_mtu = path_mtu; exp->template_interval = template_interval; exp->udp_checksum = udp_checksum; if (collector.as_u32) vlib_cli_output (vm, "Collector %U, src address %U, " "fib index %d, path MTU %u, " "template resend interval %us, " "udp checksum %s", format_ip4_address, exp->ipfix_collector, format_ip4_address, exp->src_address, fib_index, path_mtu, template_interval, udp_checksum ? "enabled" : "disabled"); else vlib_cli_output (vm, "IPFIX Collector is disabled"); /* Turn on the flow reporting process */ vlib_process_signal_event (vm, flow_report_process_node.index, 1, 0); return 0; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (set_ipfix_exporter_command, static) = { .path = "set ipfix exporter", .short_help = "set ipfix exporter " "collector <ip4-address> [port <port>] " "src <ip4-address> [fib-id <fib-id>] " "[path-mtu <path-mtu>] " "[template-interval <template-interval>] " "[udp-checksum]", .function = set_ipfix_exporter_command_fn, }; /* *INDENT-ON* */ static clib_error_t * ipfix_flush_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { /* poke the flow reporting process */ vlib_process_signal_event (vm, flow_report_process_node.index, 1, 0); return 0; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (ipfix_flush_command, static) = { .path = "ipfix flush", .short_help = "flush the current ipfix data [for make test]", .function = ipfix_flush_command_fn, }; /* *INDENT-ON* */ static clib_error_t * flow_report_init (vlib_main_t * vm) { flow_report_main_t *frm = &flow_report_main; ipfix_exporter_t *exp; frm->vlib_main = vm; frm->vnet_main = vnet_get_main (); frm->unix_time_0 = time (0); frm->vlib_time_0 = vlib_time_now (frm->vlib_main); /* * Make sure that we can always access the first exporter for * backwards compatibility reasons. */ pool_alloc (frm->exporters, IPFIX_EXPORTERS_MAX); pool_get (frm->exporters, exp); /* Verify that this is at index 0 */ ASSERT (frm->exporters == exp); exp->fib_index = ~0; return 0; } VLIB_INIT_FUNCTION (flow_report_init); /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */