Skip to content

Commit 2975205

Browse files
authored
[bgpcfgd] Fix flaky UT failure in test_as_path (#22542)
Why I did it DEVICE_METADATA["localhost"]["t2_group_asns"] is a comma separated list of ASNs. bgpcfgd would parse and loop this list and do some operations. Sometimes ut in bgpcfgd would fail due to list parsing order for t2_group_asns How I did it Update UT, ignore order for modifying asns How to verify it UT passed
1 parent 9ba2cc0 commit 2975205

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/sonic-bgpcfgd/tests/test_as_path.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_metadata_with_asns():
5353
m.cfg_mgr.push.assert_has_calls([
5454
call("bgp as-path access-list T2_GROUP_ASNS permit _64120_"),
5555
call("bgp as-path access-list T2_GROUP_ASNS permit _64121_")
56-
])
56+
], any_order=True)
5757

5858

5959
# test if T2_GROUP_ASNS has been updated
@@ -67,7 +67,11 @@ def test_metadata_with_asns_update():
6767
call("no bgp as-path access-list T2_GROUP_ASNS seq 5 permit _64128_"),
6868
call("bgp as-path access-list T2_GROUP_ASNS permit _64120_"),
6969
call("bgp as-path access-list T2_GROUP_ASNS permit _64121_")
70-
])
70+
], any_order=True)
71+
72+
actual_calls = m.cfg_mgr.push.mock_calls
73+
assert (actual_calls[0] == call("no bgp as-path access-list T2_GROUP_ASNS seq 5 permit _64128_"),
74+
"Didn't find call to clear previous ASN")
7175

7276

7377
# test if T2_GROUP_ASNS has been cleared
@@ -81,4 +85,7 @@ def test_del_handler():
8185
call("bgp as-path access-list T2_GROUP_ASNS permit _64120_"),
8286
call("bgp as-path access-list T2_GROUP_ASNS permit _64121_"),
8387
call("no bgp as-path access-list T2_GROUP_ASNS")
84-
])
88+
], any_order=True)
89+
actual_calls = m.cfg_mgr.push.mock_calls
90+
assert (actual_calls[-1] == call("no bgp as-path access-list T2_GROUP_ASNS"),
91+
"Didn't find call to delete access-list")

0 commit comments

Comments
 (0)