Improve pf layer
[csit.git] / resources / libraries / robot / lb / load_balancer.robot
1 # Copyright (c) 2020 Intel and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | Collections
16 | Library | String
17
18 | Library | resources.libraries.python.InterfaceUtil
19 | Library | resources.libraries.python.IPUtil
20 | Library | resources.libraries.python.topology.Topology
21 | Library | resources.libraries.python.LoadBalancerUtil
22 | Library | resources.libraries.python.NodePath
23 |
24 | Resource | resources/libraries/robot/shared/interfaces.robot
25 |
26 | Documentation | LoadBalancer suite keywords - configuration
27
28 *** Keywords ***
29 | Initialize loadbalancer maglev
30 | | [Documentation]
31 | | ... | Set UP state on VPP interfaces in path on nodes in 2-node
32 | | ... | circular topology. Get the interface MAC addresses and setup ARP on
33 | | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
34 | | ... | links.
35 | |
36 | | Set interfaces in path up
37 | |
38 | | ${fib_table}= | Set Variable | ${0}
39 | | Add Fib Table | ${dut1} | ${fib_table}
40 | | Assign Interface To Fib Table
41 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${fib_table}
42 | | Assign Interface To Fib Table
43 | | ... | ${dut1} | ${DUT1_${int}2}[0] | ${fib_table}
44 | | VPP Interface Set IP Address
45 | | ... | ${dut1} | ${DUT1_${int}1}[0] | 192.168.50.72 | 24
46 | | VPP Interface Set IP Address
47 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 192.168.60.73 | 24
48 | | Add Ip Neighbors
49 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 192.168.60 | ${TG_pf2_mac}[0]
50 | | Vpp Route Add
51 | | ... | ${dut1} | 192.168.60.0 | 24 | interface=${DUT1_${int}2}[0]
52 | | Vpp Lb Conf
53 | | ... | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
54 | | Vpp Lb Add Del Vip
55 | | ... | ${dut1} | vip_addr=90.1.2.1 | encap=${0} | new_len=${1024}
56 | | Add Lb As Addresses
57 | | ... | ${dut1} | 90.1.2.1 | 192.168.60
58
59 | Initialize loadbalancer l3dsr
60 | | [Documentation]
61 | | ... | Set UP state on VPP interfaces in path on nodes in 2-node
62 | | ... | circular topology. Get the interface MAC addresses and setup ARP on
63 | | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
64 | | ... | links.
65 | |
66 | | Set interfaces in path up
67 | |
68 | | ${fib_table}= | Set Variable | ${0}
69 | | Add Fib Table | ${dut1} | ${fib_table}
70 | | Assign Interface To Fib Table
71 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${fib_table}
72 | | Assign Interface To Fib Table
73 | | ... | ${dut1} | ${DUT1_${int}2}[0] | ${fib_table}
74 | | VPP Interface Set IP Address
75 | | ... | ${dut1} | ${DUT1_${int}1}[0] | 192.168.50.72 | 24
76 | | VPP Interface Set IP Address
77 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 192.168.60.73 | 24
78 | | Add Ip Neighbors
79 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 192.168.60 | ${TG_pf2_mac}[0]
80 | | Vpp Route Add
81 | | ... | ${dut1} | 192.168.60.0 | 24 | interface=${DUT1_${int}2}[0]
82 | | Vpp Lb Conf
83 | | ... | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
84 | | Vpp Lb Add Del Vip
85 | | ... | ${dut1} | vip_addr=90.1.2.1 | encap=${2} | dscp=${7} | new_len=${1024}
86 | | Add Lb As Addresses
87 | | ... | ${dut1} | 90.1.2.1 | 192.168.60
88
89 | Initialize loadbalancer nat4
90 | | [Documentation]
91 | | ... | Set UP state on VPP interfaces in path on nodes in 2-node
92 | | ... | circular topology. Get the interface MAC addresses and setup ARP on
93 | | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
94 | | ... | links.
95 | |
96 | | Set interfaces in path up
97 | |
98 | | ${fib_table}= | Set Variable | ${0}
99 | | Add Fib Table | ${dut1} | ${fib_table}
100 | | Assign Interface To Fib Table
101 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${fib_table}
102 | | Assign Interface To Fib Table
103 | | ... | ${dut1} | ${DUT1_${int}2}[0] | ${fib_table}
104 | | VPP Interface Set IP Address
105 | | ... | ${dut1} | ${DUT1_${int}1}[0] | 192.168.50.72 | 24
106 | | VPP Interface Set IP Address
107 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 192.168.60.73 | 24
108 | | Add Ip Neighbors
109 | | ... | ${dut1} | ${DUT1_${int}1}[0] | 192.168.50 | ${TG_pf1_mac}[0]
110 | | Add Ip Neighbors
111 | | ... | ${dut1} | ${DUT1_${int}2}[0] | 192.168.60 | ${TG_pf2_mac}[0]
112 | | Vpp Route Add
113 | | ... | ${dut1} | 192.168.50.0 | 24 | interface=${DUT1_${int}1}[0]
114 | | Vpp Route Add
115 | | ... | ${dut1} | 192.168.60.0 | 24 | interface=${DUT1_${int}2}[0]
116 | | Vpp Lb Conf
117 | | ... | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
118 | | Vpp Lb Add Del Vip
119 | | ... | ${dut1} | vip_addr=90.1.2.1 | encap=${3}
120 | | ... | protocol=${17} | port=${20000} | target_port=${3307} | new_len=${1024}
121 | | Add Lb As Addresses
122 | | ... | ${dut1} | 90.1.2.1 | 192.168.60 | protocol=${17} | port=${20000}
123 | | Vpp Lb Add Del Intf Nat4
124 | | ... | ${dut1} | interface=${DUT1_${int}2}[0]
125
126 | Add Ip Neighbors
127 | | [Documentation] | Add IP neighbors to physical interface on DUT.
128 | |
129 | | ... | *Arguments:*
130 | | ... | - node - VPP node. Type: dictionary
131 | | ... | - interface - Interface key. Type: string
132 | | ... | - ip_addr - IP address of the interface. Type: string
133 | | ... | - mac_addr - MAC address of the interface. Type: string
134 | |
135 | | ... | *Example:*
136 | | ... | \| Add Ip Neighbors \| ${dut1} \| ${dut1_if1} \| 192.168.50 \
137 | | ... | \| ${tg_if1_mac}
138 | |
139 | | [Arguments] | ${node} | ${interface} | ${ip_addr} | ${mac_addr}
140 | |
141 | | FOR | ${number} | IN RANGE | 74 | 80
142 | | | VPP Add IP Neighbor
143 | | | ... | ${node} | ${interface} | ${ip_addr}.${number} | ${mac_addr}
144 | | END
145
146 | Add Lb As Addresses
147 | | [Documentation] | Add Lb As Addresses on Vpp node.
148 | |
149 | | ... | *Arguments:*
150 | | ... | - node - VPP node. Type: dictionary
151 | | ... | - vip_addr - IPv4 address to be used as source for IPv4 traffic.
152 | | ... | Type: string
153 | | ... | - as_addr - The application server address. Type: string
154 | | ... | - protocol - tcp or udp. Type: integer
155 | | ... | - port - destination port. Type: integer
156 | | ... | - is_del - 1 if the VIP should be removed otherwise 0. Type: integer
157 | | ... | - is_flush - 1 if the sessions related to this AS should be flushed
158 | | ... | otherwise 0. Type: integer
159 | |
160 | | ... | *Example:*
161 | | ... | \| Add Lb As Addresses \| ${dut1} \| 90.1.2.1 \| 192.168.60 \
162 | | ... | \| protocol=${17} \| port=${20000} \|
163 | |
164 | | [Arguments] | ${node} | ${vip_addr} | ${as_addr} | ${protocol}=${255}
165 | | ... | ${port}=${0} | ${is_del}=${0} | ${is_flush}=${0}
166 | |
167 | | FOR | ${number} | IN RANGE | 74 | 80
168 | | | VPP Lb Add Del As
169 | | | ... | ${node} | vip_addr=${vip_addr} | protocol=${protocol}
170 | | | ... | port=${port} | as_addr=${as_addr}.${number}
171 | | END