Skip to content

Commit 2280da5

Browse files
markx-aristarraghav-cisco
authored andcommitted
Fix memory comparison in test_bgp_session_flap when baseline stat is 0 (sonic-net#21451)
Fix test_bgp_session_flap when memory stat is always 0, e.g., v4 neighbors memory usage in v6 topo. Signed-off-by: markxiao <[email protected]> Signed-off-by: Raghavendran Ramanathan <[email protected]>
1 parent 953e900 commit 2280da5

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

tests/bgp/test_bgp_session_flap.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ def test_bgp_single_session_flaps(setup):
168168
assert stats[index][0] < (stats[0][0] + cpuSpike)
169169
assert stats[index][1] < (stats[0][1] + cpuSpike)
170170
assert stats[index][2] < (stats[0][2] + cpuSpike)
171-
assert stats[index][3] < (stats[0][3] * memSpike)
172-
assert stats[index][4] < (stats[0][4] * memSpike)
173-
assert stats[index][5] < (stats[0][5] * memSpike)
174-
assert stats[index][6] < (stats[0][6] * memSpike)
175-
assert stats[index][7] < (stats[0][7] * memSpike)
176-
assert stats[index][8] < (stats[0][8] * memSpike)
171+
# Use <= for memory usage comparison because it can be 0 (e.g., No V4 neighbors in V6 topo)
172+
assert stats[index][3] <= (stats[0][3] * memSpike)
173+
assert stats[index][4] <= (stats[0][4] * memSpike)
174+
assert stats[index][5] <= (stats[0][5] * memSpike)
175+
assert stats[index][6] <= (stats[0][6] * memSpike)
176+
assert stats[index][7] <= (stats[0][7] * memSpike)
177+
assert stats[index][8] <= (stats[0][8] * memSpike)
177178

178179
time.sleep(wait_time)
179180

@@ -215,12 +216,13 @@ def test_bgp_multiple_session_flaps(setup):
215216
assert stats[index][0] < (stats[0][0] + cpuSpike)
216217
assert stats[index][1] < (stats[0][1] + cpuSpike)
217218
assert stats[index][2] < (stats[0][2] + cpuSpike)
218-
assert stats[index][3] < (stats[0][3] * memSpike)
219-
assert stats[index][4] < (stats[0][4] * memSpike)
220-
assert stats[index][5] < (stats[0][5] * memSpike)
221-
assert stats[index][6] < (stats[0][6] * memSpike)
222-
assert stats[index][7] < (stats[0][7] * memSpike)
223-
assert stats[index][8] < (stats[0][8] * memSpike)
219+
# Use <= for memory usage comparison because it can be 0 (e.g., No V4 neighbors in V6 topo)
220+
assert stats[index][3] <= (stats[0][3] * memSpike)
221+
assert stats[index][4] <= (stats[0][4] * memSpike)
222+
assert stats[index][5] <= (stats[0][5] * memSpike)
223+
assert stats[index][6] <= (stats[0][6] * memSpike)
224+
assert stats[index][7] <= (stats[0][7] * memSpike)
225+
assert stats[index][8] <= (stats[0][8] * memSpike)
224226

225227
time.sleep(wait_time)
226228

0 commit comments

Comments
 (0)