summaryrefslogtreecommitdiffstats
path: root/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py
blob: 190879cc278f943b6a68b21bdc639d0853229fc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from lib.lutil import luCommand, luLast

ret = luCommand(
    "ce1",
    'vtysh -c "show ip route" | grep -c \\ 10\\.\\*/32',
    "(.*)",
    "pass",
    "Looking for sharp routes",
)
found = luLast()
if ret != False and found != None:
    num = int(found.group())
    luCommand(
        "ce3", 'vtysh -c "show bgp sum"', ".", "pass", "See %s sharp routes" % num
    )
    if num > 0:
        rtrs = ["ce1", "ce2", "ce3"]
        for rtr in rtrs:
            luCommand(
                rtr,
                'vtysh -c "show bgp ipv4 uni" | grep Display',
                ".",
                "none",
                "BGP routes pre remove",
            )
            luCommand(
                rtr,
                "ip route show | cat -n | tail",
                ".",
                "none",
                "Linux routes pre remove",
            )
        wait = 2 * num / 500
        luCommand(
            "ce1",
            'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),
            ".",
            "none",
            "Removing {} routes".format(num),
        )
        luCommand(
            "ce2",
            'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),
            ".",
            "none",
            "Removing {} routes".format(num),
        )
        for rtr in rtrs:
            luCommand(
                rtr,
                'vtysh -c "show bgp ipv4 uni" | grep Display',
                " 14 route",
                "wait",
                "BGP routes removed",
                wait,
                wait_time=10,
            )
            luCommand(
                rtr,
                'vtysh -c "show bgp ipv4 uni"',
                ".",
                "none",
                "BGP routes post remove",
            )
        for rtr in rtrs:
            luCommand(
                rtr,
                "ip route show | grep -c \\^10\\.",
                "^0$",
                "wait",
                "Linux routes removed",
                wait,
                wait_time=10,
            )
            luCommand(rtr, "ip route show", ".", "none", "Linux routes post remove")
        rtrs = ["r1", "r3", "r4"]
        for rtr in rtrs:
            luCommand(
                rtr,
                "ip route show vrf {}-cust1 | grep -c \\^10\\.".format(rtr),
                "^0$",
                "wait",
                "VRF route removed",
                wait,
                wait_time=10,
            )
# done