@cryptotaxi247 / kubo / commits / c0bb1f89e

test: fix flaky tests on ci (#11236)

* test: increase GetClosestPeers DHT timeout from 2m to 5m passing runs finish in 8-48s, but WAN DHT bootstrap occasionally fails entirely in CI (~4.3% flake rate on master), hitting the 2m ceiling. bumping to 5m gives more retry attempts without affecting passing runs. * test: fix flaky TestThreeLeggedCatTransfer - add 3-minute context timeout instead of unbounded context.Background(), so failures produce a meaningful error instead of burning 10 minutes - reduce data from 100 MB to 1 MB; the test verifies three-legged DHT discovery + bitswap transfer, not bulk throughput - explicitly provide root CID to DHT before catter fetches, eliminating the race between async reprovider and immediate Get

Marcin Rataj committed Mar 15, 2026 at 13:58 UTC c0bb1f89e9d9d049b4dd6113a0307c9d782913a3
2 files changed +13 -4
test/cli/delegated_routing_v1_http_server_test.go
+4 -2
@@ -252,7 +252,9 @@ func TestRoutingV1Server(t *testing.T) {
252 // Wait for WAN DHT routing table to be populated.
253 // The server has a 30-second routing timeout, so we use 60 seconds
254 // per request to allow for network latency while preventing hangs.
255 - // Total wait time is 2 minutes (locally passes in under 1 minute).
255 + // Total wait time is 5 minutes to accommodate slow CI DHT bootstrapping.
256 + // Passing runs finish in 8-48s; failures are total bootstrap failures,
257 + // not slow convergence, so extra headroom doesn't waste time on success.
258 var records []*types.PeerRecord
259 require.EventuallyWithT(t, func(ct *assert.CollectT) {
260 ctx, cancel := context.WithTimeout(t.Context(), 60*time.Second)
@@ -263,7 +265,7 @@ func TestRoutingV1Server(t *testing.T) {
265 }
266 records, err = iter.ReadAllResults(resultsIter)
267 assert.NoError(ct, err)
266 - }, 2*time.Minute, 5*time.Second)
268 + }, 5*time.Minute, 5*time.Second)
269
270 // Verify we got some peers back from WAN DHT
271 require.NotEmpty(t, records, "should return peers close to own peerid")
test/integration/three_legged_cat_test.go
+9 -2
@@ -26,7 +26,7 @@ func TestThreeLeggedCatTransfer(t *testing.T) {
26 RoutingLatency: 0,
27 BlockstoreLatency: 0,
28 }
29 - if err := RunThreeLeggedCat(RandomBytes(100*unit.MB), conf); err != nil {
29 + if err := RunThreeLeggedCat(RandomBytes(1*unit.MB), conf); err != nil {
30 t.Fatal(err)
31 }
32 }
@@ -64,7 +64,7 @@ func TestThreeLeggedCat100MBMacbookCoastToCoast(t *testing.T) {
64 }
65
66 func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
67 - ctx, cancel := context.WithCancel(context.Background())
67 + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
68 defer cancel()
69
70 // create network
@@ -122,6 +122,13 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
122 return err
123 }
124
125 + // Explicitly provide the root CID to the DHT so the catter can discover
126 + // the adder. Without this, the async reprovider may not have propagated
127 + // the record before the catter queries.
128 + if err := adder.Routing.Provide(ctx, added.RootCid(), true); err != nil {
129 + return err
130 + }
131 +
132 readerCatted, err := catterAPI.Unixfs().Get(ctx, added)
133 if err != nil {
134 return err