kubo/test/cli
Marcin Rataj 1301710a91
fix(ci): parallelize gotest, cleanup output, flakiness (#11113)
* ci: parallelize gotest by separating test/cli into own job

split the Go Test workflow into two parallel jobs:
- `unit-tests`: runs unit tests (excluding test/cli)
- `cli-tests`: runs test/cli end-to-end tests

test/cli takes ~3 minutes (~50% of total gotest time), so running
it in parallel should reduce wall-clock CI time by ~1.5-2.5 minutes.

both jobs produce JUnit XML and HTML reports for consistent debugging.

* ci(gotest): reduce noise on test timeout panics

add GOTRACEBACK=single to show only one goroutine stack instead of all
when a test timeout panic occurs. this makes CI output much cleaner
when tests hang.

* fix(ci): prevent stderr from corrupting test JSON output

- remove 2>&1 which mixed "go: downloading" stderr messages into JSON
- add JSON validation before parsing
- print failed test names for easier debugging

* ci(gotest): use gotestsum for human-readable test output

- replace per-package coverage loop with single gotestsum invocation
- both unit-tests and cli-tests now show human-readable output
- simplified coverage collection (single -coverprofile, no gocovmerge)
- clarified step names to indicate they run tests

* ci: fix codecov uploads by adding token

- add CODECOV_TOKEN to gotest.yml and sharness.yml
- update codecov-action to v5.5.2
- add fail_ci_if_error: false for robustness

codecov stopped receiving coverage data ~1 year ago when they
started requiring tokens for public repos

* refactor(make): add test_unit and test_cli targets

- add `make test_unit` for unit tests with coverage (used by CI)
- add `make test_cli` for CLI integration tests (used by CI)
- only disable colors when CI env var is set (local dev gets colors)
- remove legacy targets: test_go_test, test_go_short, test_go_race, test_go_expensive
- update gotest.yml to use make targets instead of inline commands
- add test artifacts to .gitignore

* fix(ci): move client/rpc tests to cli-tests job

client/rpc tests use test/cli/harness which requires the ipfs binary.
Move them from test_unit to test_cli where the binary is built.

also:
- update gotestsum to v1.13.0
- simplify workflow step names

* fix(ci): use build tags when listing test packages

go list needs build tags to properly exclude packages like fuse/mfs
when running with TEST_FUSE=0 (nofuse tag).

* fix(ci): move test/integration to cli-tests job

test/integration tests need the ipfs binary, move them from test_unit
to test_cli.

* fix(test): fix flaky kubo-as-a-library and GetClosestPeers tests

kubo-as-a-library: use `Bootstrap()` instead of raw `Swarm().Connect()`
to fix race condition between swarm connection and bitswap peer
discovery. `Bootstrap()` properly integrates peers into the routing
system, ensuring bitswap learns about connected peers synchronously.

GetClosestPeers: simplify retry logic using `EventuallyWithT` with
10-minute timeout. tests all 4 routing types (`auto`, `autoclient`,
`dht`, `dhtclient`) against real bootstrap peers with patient polling.

* fix(example): use bidirectional Swarm().Connect() for reliable bitswap

- connect nodes bidirectionally (A→B and B→A) to simulate mutual peering
- mutual peering protects connection from resource manager culling
- use port 0 for random available ports (avoids CI conflicts)
- enable LoopbackAddressesOnLanDHT for local testing
- move retry logic to test file using require.Eventually

* fix(ci): add test_examples target and parallel example-tests job

- add `make test_examples` target to mk/golang.mk for consistency with test_unit/test_cli
- move example tests to separate parallel CI job (example-tests)
- example: use Bootstrap() with autoconf.FallbackBootstrapPeers for reliable bitswap
- example: increase context timeout to 10 minutes
- test: add 60s per-request timeout to GetClosestPeers (server has 30s routing timeout)
- test: reduce EventuallyWithT to 3 minutes (locally passes in under 1 minute)

* fix(ci): improve test targets, exclusion patterns, and artifact naming

- define COVERPKG_EXCLUDE and UNIT_EXCLUDE as documented variables
- use grep -vE with single regex instead of multiple grep -v calls
- add mkdir -p before rm to ensure directories exist
- add DEPS_GO dependency to test_cli target
- make CLI test timeout configurable via TEST_CLI_TIMEOUT (default 10m)
- fix test_examples cleanup on failure using subshell
- reduce GetClosestPeers test wait time from 3m to 2m
- rename artifacts to match job names: unit-tests-{junit,html}, cli-tests-{junit,html}
- update cli-tests upload-artifact from v5 to v6

* fix(ci): fix unit test exclusion and speed up example test

- fix UNIT_EXCLUDE regex to match client/rpc at end of path
- remove public bootstrap peers from example (only connect to nodeA)
- example test now runs in ~3s instead of timing out

* fix(test): fix flaky TestAddMultipleGCLive race condition

added time.Sleep after spawning GC goroutines to ensure they reach
GCLock() before the test proceeds. without this, the adder's
maybePauseForGC() might check GCRequested() before GC has even
requested the lock, causing the lock to not be released and GC to
block indefinitely.

this matches the existing pattern in TestAddGCLive which already
had this sleep.

also replaced context.Background() with t.Context() in both
TestAddMultipleGCLive and TestAddGCLive for proper test lifecycle
management.

* fix(example): use test harness settings for reliable CI

the kubo-as-a-library example was flaky on CI. applied test-harness-like
settings that match what transports_test.go uses:

- TCP-only on 127.0.0.1 with random port (no QUIC/UDP)
- explicitly disable non-TCP transports (QUIC, Relay, WebTransport, etc)
- use NilRouterOption (no routing) since we connect peers directly
- bitswap works with directly connected peers without DHT lookups
- 2-minute context timeout
- streaming output in test for debugging
2026-01-08 05:07:08 +01:00
..
autoconf refactor(config): migration 17-to-18 to unify Provider/Reprovider into Provide.DHT (#10951) 2025-09-18 22:17:43 +02:00
fixtures feat(ipns): records with V2-only signatures (#9932) 2023-06-20 14:24:31 +02:00
harness fix: disable telemetry in test profile (#10931) 2025-08-24 14:30:35 +02:00
migrations fix: migrations for Windows (#11010) 2025-10-08 18:02:04 +02:00
testutils feat: support GetClosesPeers (IPIP-476) and ExposeRoutingAPI by default (#10954) 2025-11-19 10:51:56 +00:00
add_test.go feat: fast provide support in dag import (#11058) 2025-11-14 21:06:25 -08:00
agent_version_unicode_test.go fix(cmds): cleanup unicode identify strings (#9465) 2025-09-19 04:46:38 +02:00
backup_bootstrap_test.go feat(bootstrap): save connected peers as backup bootstrap peers (#8856) 2023-05-25 14:39:49 +02:00
basic_commands_test.go feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
bitswap_config_test.go chore: replace random test utils with equivalents in go-test/random (#10915) 2025-08-14 10:37:55 -07:00
bootstrap_auto_test.go feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
cid_test.go fix(cmd): exit 1 on error (#10903) 2025-08-08 17:25:05 -07:00
cli_https_test.go fix(cli): support HTTPS in ipfs --api (#10659) 2025-01-10 22:34:56 +01:00
commands_without_repo_test.go fix: ipfs cid without repo (#10897) 2025-08-08 16:39:34 +02:00
completion_test.go feat: add zsh completions (#10040) 2023-08-17 16:43:27 +02:00
config_secrets_test.go test: add regression tests for config secrets protection (#11061) 2025-11-17 19:10:40 +01:00
content_blocking_test.go fix typos in docs and comments (#10920) 2025-08-18 08:43:25 -07:00
content_routing_http_test.go chore: replace random test utils with equivalents in go-test/random (#10915) 2025-08-14 10:37:55 -07:00
daemon_test.go refactor: remove goprocess (#10872) 2025-08-06 00:33:45 +02:00
dag_test.go feat: fast provide support in dag import (#11058) 2025-11-14 21:06:25 -08:00
delegated_routing_v1_http_client_test.go feat(gateway): expose /routing/v1 server (opt-in) (#9877) 2023-08-25 17:30:04 +02:00
delegated_routing_v1_http_proxy_test.go feat: enable DHT Provide Sweep by default (#10955) 2025-11-12 23:55:17 +01:00
delegated_routing_v1_http_server_test.go fix(ci): parallelize gotest, cleanup output, flakiness (#11113) 2026-01-08 05:07:08 +01:00
dht_autoclient_test.go chore: replace random test utils with equivalents in go-test/random (#10915) 2025-08-14 10:37:55 -07:00
dht_opt_prov_test.go feat: enable DHT Provide Sweep by default (#10955) 2025-11-12 23:55:17 +01:00
files_test.go fix(mfs): add soft limit for --flush=false (#10985) 2025-09-26 01:25:23 +02:00
fuse_test.go refactor: remove goprocess (#10872) 2025-08-06 00:33:45 +02:00
gateway_limits_test.go feat(config): Gateway.RetrievalTimeout|MaxConcurrentRequests (#10905) 2025-08-15 02:36:33 +02:00
gateway_range_test.go feat(gateway): update gateway api, no multi-range support 2023-10-02 16:43:52 +02:00
gateway_test.go chore: use go-log/v2 (#10801) 2025-05-19 13:04:05 -07:00
http_gateway_over_libp2p_test.go chore: update dependencies (#10462)(#10466) 2024-07-30 16:42:18 +02:00
http_retrieval_client_test.go chore: replace random test utils with equivalents in go-test/random (#10915) 2025-08-14 10:37:55 -07:00
identity_cid_test.go fix: enforce identity CID size limits (#10949) 2025-09-09 20:22:21 +02:00
init_test.go style: gofumpt and godot [skip changelog] (#10081) 2023-08-17 14:02:08 +02:00
ipfswatch_test.go fix(ipfswatch): loading datastore plugins (#11078) 2025-12-10 02:50:59 +01:00
log_level_test.go fix(go-log@2.9/go-libp2p@0.45): dynamic log level control and tail (#11039) 2025-11-06 16:00:56 +01:00
must.go test: port remote pinning tests to Go (#9720) 2023-03-30 07:46:35 -04:00
name_test.go feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
peering_test.go feat: add identify option to swarm peers command 2023-03-30 04:34:57 +00:00
pin_ls_names_test.go fix: ipfs pin ls <cid> --names (#10970) 2025-09-19 03:17:45 +02:00
pin_name_validation_test.go feat: limit pin names to 255 bytes (#10981) 2025-09-25 23:54:04 +02:00
ping_test.go chore: update go-libp2p-kad-dht 2023-09-21 20:14:21 +02:00
pinning_remote_test.go chore: replace random test utils with equivalents in go-test/random (#10915) 2025-08-14 10:37:55 -07:00
pins_test.go Add bytes progress tracker for ipfs pin add (#11074) 2025-12-02 17:11:22 -08:00
provide_stats_test.go feat(provide): detailed ipfs provide stat (#11019) 2025-10-23 20:29:36 +02:00
provider_test.go feat(provider): resume cycle (#11031) 2025-10-29 11:07:46 +01:00
rcmgr_test.go fix: future proof with > rcmgr.DefaultLimit for new enum rcmgr values 2023-03-16 13:41:24 +01:00
repo_verify_test.go test: verifyWorkerRun and helptext (#11063) 2025-11-17 18:51:33 +01:00
routing_dht_test.go feat: enable DHT Provide Sweep by default (#10955) 2025-11-12 23:55:17 +01:00
rpc_auth_test.go test: add regression tests for API.Authorizations (#11060) 2025-11-17 18:52:05 +01:00
rpc_unixsocket_test.go Cleanup commented imports 2024-08-19 19:55:11 -07:00
stats_test.go fix: stats dht command when Routing.Type=auto (#9538) 2023-01-13 00:38:38 +01:00
swarm_test.go feat(ci): reusable spellcheck from unified CI (#10873) 2025-08-14 00:35:35 +00:00
telemetry_test.go feat(telemetry): collect high level provide DHT sweep settings (#11056) 2025-11-13 01:28:15 +01:00
tracing_test.go style: gofumpt and godot [skip changelog] (#10081) 2023-08-17 14:02:08 +02:00
transports_test.go fix(ci): make NewRandPort thread-safe (#10921) 2025-08-18 22:12:22 +02:00
webui_test.go feat: ipfs-webui v4.9.0 with retrieval diagnostics (#10969) 2025-09-19 04:16:21 +02:00