Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func TestPassword(t *testing.T) {

}
t.Log("Wait till hold time expires: BGP should not be in ESTABLISHED state when passwords do not match.")
_, ok := gnmi.Watch(t, dut, nbrPath.SessionState().State(), (dutHoldTime+10)*time.Second, func(val *ygnmi.Value[oc.E_Bgp_Neighbor_SessionState]) bool {
_, ok := gnmi.Watch(t, dut, nbrPath.SessionState().State(), (dutHoldTime+60)*time.Second, func(val *ygnmi.Value[oc.E_Bgp_Neighbor_SessionState]) bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the increased timeout of 150 seconds (dutHoldTime of 90s + 60s) is correct according to the pull request description, using the magic number 60 makes the code harder to understand and maintain. The description explains this margin as keepalive_interval + 30s_margin. Since dutKeepaliveTime is 30s, this margin is equivalent to 2 * dutKeepaliveTime. Using this expression makes the intent clearer and ties the timeout to the relevant BGP parameters.

Suggested change
_, ok := gnmi.Watch(t, dut, nbrPath.SessionState().State(), (dutHoldTime+60)*time.Second, func(val *ygnmi.Value[oc.E_Bgp_Neighbor_SessionState]) bool {
_, ok := gnmi.Watch(t, dut, nbrPath.SessionState().State(), (dutHoldTime+2*dutKeepaliveTime)*time.Second, func(val *ygnmi.Value[oc.E_Bgp_Neighbor_SessionState]) bool {

state, ok := val.Val()
return ok && state != oc.Bgp_Neighbor_SessionState_ESTABLISHED
}).Await(t)
Expand Down
Loading