]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py
Merge pull request #13183 from Pdoijode/pdoijode/pim-json-changes
[mirror_frr.git] / tests / topotests / bgp_l3vpn_to_bgp_vrf / scripts / scale_up.py
1 from lib.lutil import luCommand, luLast
2
3 num = 50000
4 b = int(num / (256 * 256))
5 if b > 0:
6 r = num - b * (256 * 256)
7 else:
8 r = num
9 c = int(r / 256)
10 if c > 0:
11 d = r - c * 256 - 1
12 else:
13 d = r
14 wait = 2 * num / 1000
15 mem_z = {}
16 mem_b = {}
17 rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"]
18 for rtr in rtrs:
19 mem_z[rtr] = {"value": 0, "units": "unknown"}
20 mem_b[rtr] = {"value": 0, "units": "unknown"}
21 ret = luCommand(
22 rtr,
23 'vtysh -c "show memory"',
24 r"zebra: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)",
25 "none",
26 "collect bgpd memory stats",
27 )
28 found = luLast()
29 if ret != False and found != None:
30 mem_z[rtr] = {"value": int(found.group(1)), "units": found.group(2)}
31 mem_b[rtr] = {"value": int(found.group(3)), "units": found.group(4)}
32
33 luCommand(
34 "ce1", 'vtysh -c "show mem"', "qmem sharpd", "none", "check if sharpd running"
35 )
36 doSharp = False
37 found = luLast()
38 if ret != False and found != None:
39 if len(found.group()):
40 doSharp = True
41
42 if doSharp != True:
43 luCommand(
44 "ce1",
45 'vtysh -c "sharp data nexthop"',
46 ".",
47 "pass",
48 "sharpd NOT running, skipping test",
49 )
50 else:
51 luCommand(
52 "ce1",
53 'vtysh -c "sharp install routes 10.0.0.0 nexthop 99.0.0.1 {}"'.format(num),
54 "",
55 "pass",
56 "Adding {} routes".format(num),
57 )
58 luCommand(
59 "ce2",
60 'vtysh -c "sharp install routes 10.0.0.0 nexthop 99.0.0.2 {}"'.format(num),
61 "",
62 "pass",
63 "Adding {} routes".format(num),
64 )
65 luCommand(
66 "ce1",
67 'vtysh -c "show ip route summ" | grep "sharp" | cut -d " " -f 33',
68 str(num),
69 "wait",
70 "See all sharp routes in rib on ce1",
71 wait,
72 wait_time=10,
73 )
74 luCommand(
75 "ce2",
76 'vtysh -c "show ip route summ" | grep "sharp" | cut -d " " -f 33',
77 str(num),
78 "wait",
79 "See all sharp routes in rib on ce2",
80 wait,
81 wait_time=10,
82 )
83
84 rtrs = ["ce1", "ce2", "ce3"]
85 for rtr in rtrs:
86 luCommand(
87 rtr,
88 'vtysh -c "show bgp ipv4 uni 10.{}.{}.{}"'.format(b, c, d),
89 "Last update:",
90 "wait",
91 "RXed last route, 10.{}.{}.{}".format(b, c, d),
92 wait,
93 wait_time=10,
94 )
95 luCommand(
96 rtr,
97 'vtysh -c "show bgp ipv4 uni" | grep -c 10\\.\\*/32',
98 str(num),
99 "wait",
100 "See all sharp routes in BGP",
101 wait,
102 wait_time=10,
103 )
104 luCommand(
105 "r1",
106 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 10.{}.{}.{}"'.format(b, c, d),
107 "99.0.0.1",
108 "wait",
109 "RXed -> 10.{}.{}.{} from CE1".format(b, c, d),
110 wait,
111 wait_time=10,
112 )
113 luCommand(
114 "r3",
115 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 10.{}.{}.{}"'.format(b, c, d),
116 "99.0.0.2",
117 "wait",
118 "RXed -> 10.{}.{}.{} from CE2".format(b, c, d),
119 wait,
120 wait_time=10,
121 )
122 luCommand(
123 "r1",
124 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
125 "99.0.0.1",
126 "wait",
127 "see VPN safi -> 10.{}.{}.{} from CE1".format(b, c, d),
128 )
129 luCommand(
130 "r3",
131 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
132 "99.0.0.2",
133 "wait",
134 "see VPN safi -> 10.{}.{}.{} from CE2".format(b, c, d),
135 )
136 luCommand(
137 "r3",
138 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
139 "1.1.1.1",
140 "wait",
141 "see VPN safi -> 10.{}.{}.{} from CE1".format(b, c, d),
142 )
143 luCommand(
144 "r1",
145 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
146 "3.3.3.3",
147 "wait",
148 "see VPN safi -> 10.{}.{}.{} from CE2".format(b, c, d),
149 )
150 luCommand(
151 "r4",
152 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
153 "1.1.1.1",
154 "wait",
155 "see VPN safi -> 10.{}.{}.{} from CE1".format(b, c, d),
156 )
157 luCommand(
158 "r4",
159 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
160 "3.3.3.3",
161 "wait",
162 "see VPN safi -> 10.{}.{}.{} from CE2".format(b, c, d),
163 )
164 rtrs = ["ce1", "ce2", "ce3"]
165 for rtr in rtrs:
166 luCommand(
167 rtr,
168 "ip route get 10.{}.{}.{}".format(b, c, d),
169 "dev",
170 "wait",
171 "Route to 10.{}.{}.{} available".format(b, c, d),
172 wait,
173 wait_time=10,
174 )
175 luCommand(
176 rtr,
177 "ip route show | grep -c \\^10\\.",
178 str(num),
179 "wait",
180 "See {} linux routes".format(num),
181 wait,
182 wait_time=10,
183 )
184
185 rtrs = ["r1", "r3", "r4"]
186 for rtr in rtrs:
187 luCommand(
188 rtr,
189 "ip route get vrf {}-cust1 10.{}.{}.{}".format(rtr, b, c, d),
190 "dev",
191 "wait",
192 "VRF route available",
193 wait,
194 wait_time=10,
195 )
196 luCommand(
197 rtr,
198 "ip route show vrf {}-cust1 | grep -c \\^10\\.".format(rtr),
199 str(num),
200 "wait",
201 "See {} linux routes".format(num),
202 wait,
203 wait_time=10,
204 )
205 rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"]
206 for rtr in rtrs:
207 ret = luCommand(
208 rtr,
209 'vtysh -c "show memory"',
210 r"zebra: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)",
211 "none",
212 "collect bgpd memory stats",
213 )
214 found = luLast()
215 if ret != False and found != None:
216 val_z = int(found.group(1))
217 if mem_z[rtr]["units"] != found.group(2):
218 val_z *= 1000
219 delta_z = val_z - int(mem_z[rtr]["value"])
220 ave_z = float(delta_z) / float(num)
221
222 val_b = int(found.group(3))
223 if mem_b[rtr]["units"] != found.group(4):
224 val_b *= 1000
225 delta_b = val_b - int(mem_b[rtr]["value"])
226 ave_b = float(delta_b) / float(num)
227 luCommand(
228 rtr,
229 'vtysh -c "show thread cpu"',
230 ".",
231 "pass",
232 "BGPd heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)".format(
233 mem_b[rtr]["value"],
234 mem_b[rtr]["units"],
235 found.group(3),
236 found.group(4),
237 round(ave_b, 4),
238 ),
239 )
240 luCommand(
241 rtr,
242 'vtysh -c "show thread cpu"',
243 ".",
244 "pass",
245 "Zebra heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)".format(
246 mem_z[rtr]["value"],
247 mem_z[rtr]["units"],
248 found.group(1),
249 found.group(2),
250 round(ave_z, 4),
251 ),
252 )
253 # done