aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries')
-rw-r--r--resources/libraries/python/LoadBalancerUtil.py33
-rw-r--r--resources/libraries/robot/lb/load_balancer.robot122
2 files changed, 141 insertions, 14 deletions
diff --git a/resources/libraries/python/LoadBalancerUtil.py b/resources/libraries/python/LoadBalancerUtil.py
index 26bf965c39..77f6412973 100644
--- a/resources/libraries/python/LoadBalancerUtil.py
+++ b/resources/libraries/python/LoadBalancerUtil.py
@@ -15,7 +15,7 @@
from socket import htonl
from ipaddress import ip_address
-from resources.libraries.python.topology import NodeType
+from resources.libraries.python.topology import NodeType, Topology
from resources.libraries.python.PapiExecutor import PapiSocketExecutor
class LoadBalancerUtil(object):
@@ -174,3 +174,34 @@ class LoadBalancerUtil(object):
else:
raise ValueError('Node {host} has unknown NodeType: "{type}"'
.format(host=node['host'], type=node['type']))
+
+ @staticmethod
+ def vpp_lb_add_del_intf_nat4(node, **kwargs):
+ """Enable/disable NAT4 feature on the interface.
+
+ :param node: Node where the interface is.
+ :param kwargs: Optional key-value arguments:
+
+ is_add: true if add, false if delete. (bool)
+ interface: software index of the interface. (int)
+
+ :type node: dict
+ :type kwargs: dict
+ :returns: Nothing.
+ :raises ValueError: If the node has an unknown node type.
+ """
+ if node['type'] == NodeType.DUT:
+ cmd = 'lb_add_del_intf_nat4'
+ err_msg = 'Failed to add interface nat4 on host {host}'.format(
+ host=node['host'])
+
+ is_add = kwargs.pop('is_add', True)
+ interface = kwargs.pop('interface', 0)
+ sw_if_index = Topology.get_interface_sw_index(node, interface)
+ args = dict(is_add=is_add, sw_if_index=sw_if_index)
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)
+ else:
+ raise ValueError('Node {host} has unknown NodeType: "{type}"'
+ .format(host=node['host'], type=node['type']))
diff --git a/resources/libraries/robot/lb/load_balancer.robot b/resources/libraries/robot/lb/load_balancer.robot
index 4dc66447d2..42cac6ae2e 100644
--- a/resources/libraries/robot/lb/load_balancer.robot
+++ b/resources/libraries/robot/lb/load_balancer.robot
@@ -45,20 +45,116 @@
| | VPP Interface Set IP Address | ${dut1} | ${dut1_if2}
| | ... | 192.168.60.73 | 24
| | ...
-| | VPP Add IP Neighbor | ${dut1} | ${dut1_if2} | 192.168.60.74 | ${tg_if2_mac}
-| | VPP Add IP Neighbor | ${dut1} | ${dut1_if2} | 192.168.60.75 | ${tg_if2_mac}
-| | VPP Add IP Neighbor | ${dut1} | ${dut1_if2} | 192.168.60.76 | ${tg_if2_mac}
-| | VPP Add IP Neighbor | ${dut1} | ${dut1_if2} | 192.168.60.77 | ${tg_if2_mac}
-| | VPP Add IP Neighbor | ${dut1} | ${dut1_if2} | 192.168.60.78 | ${tg_if2_mac}
-| | VPP Add IP Neighbor | ${dut1} | ${dut1_if2} | 192.168.60.79 | ${tg_if2_mac}
+| | Add Ip Neighbors | ${dut1} | ${dut1_if2} | 192.168.60 | ${tg_if2_mac}
| | ...
| | Vpp Route Add | ${dut1} | 192.168.60.0 | 24 | interface=${dut1_if2}
| | ...
| | Vpp Lb Conf | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
-| | Vpp Lb Add Del Vip | ${dut1} | vip_addr=90.1.2.1 | encap=${0} | new_len=${1024}
-| | Vpp Lb Add Del As | ${dut1} | vip_addr=90.1.2.1 | as_addr=192.168.60.74
-| | Vpp Lb Add Del As | ${dut1} | vip_addr=90.1.2.1 | as_addr=192.168.60.75
-| | Vpp Lb Add Del As | ${dut1} | vip_addr=90.1.2.1 | as_addr=192.168.60.76
-| | Vpp Lb Add Del As | ${dut1} | vip_addr=90.1.2.1 | as_addr=192.168.60.77
-| | Vpp Lb Add Del As | ${dut1} | vip_addr=90.1.2.1 | as_addr=192.168.60.78
-| | Vpp Lb Add Del As | ${dut1} | vip_addr=90.1.2.1 | as_addr=192.168.60.79
+| | Vpp Lb Add Del Vip | ${dut1} | vip_addr=90.1.2.1 | encap=${0}
+| | ... | new_len=${1024}
+| | Add Lb As Addresses | ${dut1} | 90.1.2.1 | 192.168.60
+
+| Initialize loadbalancer l3dsr
+| | [Documentation]
+| | ... | Set UP state on VPP interfaces in path on nodes in 2-node
+| | ... | circular topology. Get the interface MAC addresses and setup ARP on
+| | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
+| | ... | links.
+| | ...
+| | Set interfaces in path up
+| | ...
+| | ${fib_table}= | Set Variable | ${0}
+| | Add Fib Table | ${dut1} | ${fib_table}
+| | Assign Interface To Fib Table | ${dut1} | ${dut1_if1} | ${fib_table}
+| | Assign Interface To Fib Table | ${dut1} | ${dut1_if2} | ${fib_table}
+| | ...
+| | VPP Interface Set IP Address | ${dut1} | ${dut1_if1}
+| | ... | 192.168.50.72 | 24
+| | VPP Interface Set IP Address | ${dut1} | ${dut1_if2}
+| | ... | 192.168.60.73 | 24
+| | ...
+| | Add Ip Neighbors | ${dut1} | ${dut1_if2} | 192.168.60 | ${tg_if2_mac}
+| | ...
+| | Vpp Route Add | ${dut1} | 192.168.60.0 | 24 | interface=${dut1_if2}
+| | ...
+| | Vpp Lb Conf | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
+| | Vpp Lb Add Del Vip | ${dut1} | vip_addr=90.1.2.1 | encap=${2} | dscp=${7}
+| | ... | new_len=${1024}
+| | Add Lb As Addresses | ${dut1} | 90.1.2.1 | 192.168.60
+
+| Initialize loadbalancer nat4
+| | [Documentation]
+| | ... | Set UP state on VPP interfaces in path on nodes in 2-node
+| | ... | circular topology. Get the interface MAC addresses and setup ARP on
+| | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
+| | ... | links.
+| | ...
+| | Set interfaces in path up
+| | ...
+| | ${fib_table}= | Set Variable | ${0}
+| | Add Fib Table | ${dut1} | ${fib_table}
+| | Assign Interface To Fib Table | ${dut1} | ${dut1_if1} | ${fib_table}
+| | Assign Interface To Fib Table | ${dut1} | ${dut1_if2} | ${fib_table}
+| | ...
+| | VPP Interface Set IP Address | ${dut1} | ${dut1_if1}
+| | ... | 192.168.50.72 | 24
+| | VPP Interface Set IP Address | ${dut1} | ${dut1_if2}
+| | ... | 192.168.60.73 | 24
+| | ...
+| | Add Ip Neighbors | ${dut1} | ${dut1_if1} | 192.168.50 | ${tg_if1_mac}
+| | Add Ip Neighbors | ${dut1} | ${dut1_if2} | 192.168.60 | ${tg_if2_mac}
+| | ...
+| | Vpp Route Add | ${dut1} | 192.168.50.0 | 24 | interface=${dut1_if1}
+| | Vpp Route Add | ${dut1} | 192.168.60.0 | 24 | interface=${dut1_if2}
+| | ...
+| | Vpp Lb Conf | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
+| | Vpp Lb Add Del Vip | ${dut1} | vip_addr=90.1.2.1 | encap=${3}
+| | ... | protocol=${17} | port=${20000} | target_port=${3307} | new_len=${1024}
+| | Add Lb As Addresses
+| | ... | ${dut1} | 90.1.2.1 | 192.168.60 | protocol=${17} | port=${20000}
+| | Vpp Lb Add Del Intf Nat4 | ${dut1} | interface=${dut1_if2}
+
+| Add Ip Neighbors
+| | [Documentation] | Add IP neighbors to physical interface on DUT.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - VPP node. Type: dictionary
+| | ... | - interface - Interface key. Type: string
+| | ... | - ip_addr - IP address of the interface. Type: string
+| | ... | - mac_addr - MAC address of the interface. Type: string
+| | ...
+| | ... | *Example:*
+| | ... | \| Add Ip Neighbors \| ${dut1} \| ${dut1_if1} \| 192.168.50 \
+| | ... | \| ${tg_if1_mac}
+| | ...
+| | [Arguments] | ${node} | ${interface} | ${ip_addr} | ${mac_addr}
+| | ...
+| | :FOR | ${number} | IN RANGE | 74 | 80
+| | | VPP Add IP Neighbor
+| | | ... | ${node} | ${interface} | ${ip_addr}.${number} | ${mac_addr}
+
+| Add Lb As Addresses
+| | [Documentation] | Add Lb As Addresses on Vpp node.
+| | ...
+| | ... | *Arguments:*
+| | ... | - node - VPP node. Type: dictionary
+| | ... | - vip_addr - IPv4 address to be used as source for IPv4 traffic.
+| | ... | Type: string
+| | ... | - as_addr - The application server address. Type: string
+| | ... | - protocol - tcp or udp. Type: integer
+| | ... | - port - destination port. Type: integer
+| | ... | - is_del - 1 if the VIP should be removed otherwise 0. Type: integer
+| | ... | - is_flush - 1 if the sessions related to this AS should be flushed
+| | ... | otherwise 0. Type: integer
+| | ...
+| | ... | *Example:*
+| | ... | \| Add Lb As Addresses \| ${dut1} \| 90.1.2.1 \| 192.168.60 \
+| | ... | \| protocol=${17} \| port=${20000} \|
+| | ...
+| | [Arguments] | ${node} | ${vip_addr} | ${as_addr} | ${protocol}=${255}
+| | ... | ${port}=${0} | ${is_del}=${0} | ${is_flush}=${0}
+| | ...
+| | :FOR | ${number} | IN RANGE | 74 | 80
+| | | VPP Lb Add Del As
+| | | ... | ${node} | vip_addr=${vip_addr} | protocol=${protocol}
+| | | ... | port=${port} | as_addr=${as_addr}.${number}