erigontech / erigontech/erigon

node/app/component: test package silently disabled by TestMain os.Exit(0)

Open
#21,552 1 comment 0 reactions 0 assignees View on GitHub
QA
Dominant language
Go
Stars
3.6k
Forks
1.5k
Avg merge
1d 16h
Merged PRs (30d)
455

Description

## Summary

The entire `node/app/component` test package never runs: `TestMain` calls `os.Exit(0)` without `m.Run()`.

```go
// node/app/component/component_test.go
func TestMain(m *testing.M) {
_ = m
os.Exit(0)
}
```

Introduced in ee703e2c69 (a `[wip] ci:` commit). As a result `go test ./node/app/component/` reports `ok` while running **zero** tests — including the gomock lifecycle tests, `event_flow_test.go`, the fuzz tests, and all of `hierarchy_test.go`.

## Why it can't simply be re-enabled yet

Switching to `os.Exit(m.Run())` and running under `-race` / repeated counts exposes:

1. **Data race on `eventBus.prevQueueSize`** — ✅ fixed in #21551.
2. **`TestEvents` is flaky** — `c.EventBus("t")` returns a shared/global bus whose subscriptions are not torn down between tests, so `bus.Post("test")` returns 3/5/7… instead of 2 as leaked handlers from earlier tests accumulate (`component_test.go:652`).
3. **Goroutine leak → deadlock** — under `-race -count=20` the suite times out with ~464 leaked goroutines: ~397 component actor goroutines (`component.go:320`/`:465`) blocked on `chan receive` (never shut down), plus workerpool/event workers blocked on `chan send`. The execpool saturates and the run hangs.

Items 2 and 3 share a root cause: a **test-isolation / lifecycle-teardown gap** — components and their event subscriptions/goroutines are not cleaned up between tests (and/or a shared root bus persists global state across tests).

## Suggested direction

- Give each test isolated component-domain/bus state, and/or ensure domain `Close()` stops all actor goroutines and clears subscriptions, with `t.Cleanup` in the tests.
- Once the suite is race-clean and leak-free under repeated `-race` runs, replace `os.Exit(0)` with `os.Exit(m.Run())`.

## Context

Found while reviewing #21455 (unskip disabled tests). That PR leaves the three gomock lifecycle tests skipped and does **not** touch `TestMain`; this issue tracks turning the package back on properly.

cc @AskAlexSharov (introduced the `os.Exit(0)` in ee703e2c69)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.