Python3: resources and libraries
[csit.git] / resources / libraries / robot / lb / load_balancer.robot
1 # Copyright (c) 2019 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 | ${dut1} | ${dut1_if1} | ${fib_table}
41 | | Assign Interface To Fib Table | ${dut1} | ${dut1_if2} | ${fib_table}
42 | |
43 | | VPP Interface Set IP Address | ${dut1} | ${dut1_if1}
44 | | ... | 192.168.50.72 | 24
45 | | VPP Interface Set IP Address | ${dut1} | ${dut1_if2}
46 | | ... | 192.168.60.73 | 24
47 | |
48 | | Add Ip Neighbors | ${dut1} | ${dut1_if2} | 192.168.60 | ${tg_if2_mac}
49 | |
50 | | Vpp Route Add | ${dut1} | 192.168.60.0 | 24 | interface=${dut1_if2}
51 | |
52 | | Vpp Lb Conf | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
53 | | Vpp Lb Add Del Vip | ${dut1} | vip_addr=90.1.2.1 | encap=${0}
54 | | ... | new_len=${1024}
55 | | Add Lb As Addresses | ${dut1} | 90.1.2.1 | 192.168.60
56
57 | Initialize loadbalancer l3dsr
58 | | [Documentation]
59 | | ... | Set UP state on VPP interfaces in path on nodes in 2-node
60 | | ... | circular topology. Get the interface MAC addresses and setup ARP on
61 | | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
62 | | ... | links.
63 | |
64 | | Set interfaces in path up
65 | |
66 | | ${fib_table}= | Set Variable | ${0}
67 | | Add Fib Table | ${dut1} | ${fib_table}
68 | | Assign Interface To Fib Table | ${dut1} | ${dut1_if1} | ${fib_table}
69 | | Assign Interface To Fib Table | ${dut1} | ${dut1_if2} | ${fib_table}
70 | |
71 | | VPP Interface Set IP Address | ${dut1} | ${dut1_if1}
72 | | ... | 192.168.50.72 | 24
73 | | VPP Interface Set IP Address | ${dut1} | ${dut1_if2}
74 | | ... | 192.168.60.73 | 24
75 | |
76 | | Add Ip Neighbors | ${dut1} | ${dut1_if2} | 192.168.60 | ${tg_if2_mac}
77 | |
78 | | Vpp Route Add | ${dut1} | 192.168.60.0 | 24 | interface=${dut1_if2}
79 | |
80 | | Vpp Lb Conf | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
81 | | Vpp Lb Add Del Vip | ${dut1} | vip_addr=90.1.2.1 | encap=${2} | dscp=${7}
82 | | ... | new_len=${1024}
83 | | Add Lb As Addresses | ${dut1} | 90.1.2.1 | 192.168.60
84
85 | Initialize loadbalancer nat4
86 | | [Documentation]
87 | | ... | Set UP state on VPP interfaces in path on nodes in 2-node
88 | | ... | circular topology. Get the interface MAC addresses and setup ARP on
89 | | ... | all VPP interfaces. Setup IPv4 addresses with /24 prefix on DUT-TG
90 | | ... | links.
91 | |
92 | | Set interfaces in path up
93 | |
94 | | ${fib_table}= | Set Variable | ${0}
95 | | Add Fib Table | ${dut1} | ${fib_table}
96 | | Assign Interface To Fib Table | ${dut1} | ${dut1_if1} | ${fib_table}
97 | | Assign Interface To Fib Table | ${dut1} | ${dut1_if2} | ${fib_table}
98 | |
99 | | VPP Interface Set IP Address | ${dut1} | ${dut1_if1}
100 | | ... | 192.168.50.72 | 24
101 | | VPP Interface Set IP Address | ${dut1} | ${dut1_if2}
102 | | ... | 192.168.60.73 | 24
103 | |
104 | | Add Ip Neighbors | ${dut1} | ${dut1_if1} | 192.168.50 | ${tg_if1_mac}
105 | | Add Ip Neighbors | ${dut1} | ${dut1_if2} | 192.168.60 | ${tg_if2_mac}
106 | |
107 | | Vpp Route Add | ${dut1} | 192.168.50.0 | 24 | interface=${dut1_if1}
108 | | Vpp Route Add | ${dut1} | 192.168.60.0 | 24 | interface=${dut1_if2}
109 | |
110 | | Vpp Lb Conf | ${dut1} | ip4_src_addr=192.168.60.73 | buckets_per_core=${128}
111 | | Vpp Lb Add Del Vip | ${dut1} | vip_addr=90.1.2.1 | encap=${3}
112 | | ... | protocol=${17} | port=${20000} | target_port=${3307} | new_len=${1024}
113 | | Add Lb As Addresses
114 | | ... | ${dut1} | 90.1.2.1 | 192.168.60 | protocol=${17} | port=${20000}
115 | | Vpp Lb Add Del Intf Nat4 | ${dut1} | interface=${dut1_if2}
116
117 | Add Ip Neighbors
118 | | [Documentation] | Add IP neighbors to physical interface on DUT.
119 | |
120 | | ... | *Arguments:*
121 | | ... | - node - VPP node. Type: dictionary
122 | | ... | - interface - Interface key. Type: string
123 | | ... | - ip_addr - IP address of the interface. Type: string
124 | | ... | - mac_addr - MAC address of the interface. Type: string
125 | |
126 | | ... | *Example:*
127 | | ... | \| Add Ip Neighbors \| ${dut1} \| ${dut1_if1} \| 192.168.50 \
128 | | ... | \| ${tg_if1_mac}
129 | |
130 | | [Arguments] | ${node} | ${interface} | ${ip_addr} | ${mac_addr}
131 | |
132 | | FOR | ${number} | IN RANGE | 74 | 80
133 | | | VPP Add IP Neighbor
134 | | | ... | ${node} | ${interface} | ${ip_addr}.${number} | ${mac_addr}
135 | | END
136
137 | Add Lb As Addresses
138 | | [Documentation] | Add Lb As Addresses on Vpp node.
139 | |
140 | | ... | *Arguments:*
141 | | ... | - node - VPP node. Type: dictionary
142 | | ... | - vip_addr - IPv4 address to be used as source for IPv4 traffic.
143 | | ... | Type: string
144 | | ... | - as_addr - The application server address. Type: string
145 | | ... | - protocol - tcp or udp. Type: integer
146 | | ... | - port - destination port. Type: integer
147 | | ... | - is_del - 1 if the VIP should be removed otherwise 0. Type: integer
148 | | ... | - is_flush - 1 if the sessions related to this AS should be flushed
149 | | ... | otherwise 0. Type: integer
150 | |
151 | | ... | *Example:*
152 | | ... | \| Add Lb As Addresses \| ${dut1} \| 90.1.2.1 \| 192.168.60 \
153 | | ... | \| protocol=${17} \| port=${20000} \|
154 | |
155 | | [Arguments] | ${node} | ${vip_addr} | ${as_addr} | ${protocol}=${255}
156 | | ... | ${port}=${0} | ${is_del}=${0} | ${is_flush}=${0}
157 | |
158 | | FOR | ${number} | IN RANGE | 74 | 80
159 | | | VPP Lb Add Del As
160 | | | ... | ${node} | vip_addr=${vip_addr} | protocol=${protocol}
161 | | | ... | port=${port} | as_addr=${as_addr}.${number}
162 | | END