bufbuild / httplb

Client-side load balancing for net/http
https://pkg.go.dev/github.com/bufbuild/httplb
Apache License 2.0
48 stars 2 forks source link

Eliminate test flakes in recently-added heap tests #65

Closed jhump closed 7 months ago

jhump commented 7 months ago

Perhaps the sift up/down ops inside the heap impl are not entirely deterministic? It seemed rather consistent in my tests, and has mostly been true in CI. And yet there were also these two failures 🤔:

https://github.com/bufbuild/httplb/actions/runs/8754637253/job/24026890423 https://github.com/bufbuild/httplb/actions/runs/8755567093/job/24029992149

So this adjusts the test to not care about precise order. Instead, it only cares about distinctness of the items picked.

Edit: source of non-determinism was use of a map inside the implementation of update, nothing to do with any non-determinism in the container/heap package.

jhump commented 7 months ago

range over newMap

🤦, yes, that's exactly what it is. Great observation! That's why on both failed runs it doesn't show up until later in the test, and it's always between "g" and "h" (two elements in the map, so some iterations they are inserted in one order, others the opposite order).