Skip to content

remove wall-clock sleeps in ALB/healthcheck tests via clock injection + synctest #1007

@crandles

Description

@crandles

The bulk of #1006 sprawled because reproducing failure modes needed integration shells with time.Sleep for healthcheck convergence -- 800ms-1.5s waits in integration/alb_matrix_test.go:249-253, integration/alb_chaos_test.go:88, pkg/backends/healthcheck/healthcheck_reregister_test.go:129, plus six polling loops in pkg/backends/alb/pool/pool_stale_cache_repro_test.go. There's no Clock abstraction in the tree (~58 files call time.Now() directly) and zero testing/synctest usage despite Go 1.26 in go.mod, so anything depending on probe interval / failure-threshold timing has to be exercised by wall-clock waits.

Scoped proposal:

  • add pkg/util/clock (small interface, default real-clock singleton)
  • thread it through pkg/backends/healthcheck/target.go and pkg/backends/alb/pool/health.go
  • convert those two packages' tests to synctest.Run

That should delete the polling loops in pool_stale_cache_repro_test.go and let the integration suite shed its healthcheck-converge sleeps.

Recommend looking attesting/synctest first, then k8s.io/utils/clock as fallback for paths a synctest bubble can't cover.

Related: #807 (proxy refactor umbrella), #1006 (motivating PR).

Metadata

Metadata

Assignees

No one assigned

    Labels

    albaffects the application load balancerhealthcheckingaffects health checkingproposalproposal providing and inviting feedback for a feature/changerefactorOptimize or modernize existing codetestsaffects unit tests

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions