Fix Broadcaster goroutine leak causing 35-minute test timeout

Problem

Tests that call handlers.NewApp() or newTestEnv() never shut down the Broadcaster created by configureEvents(). Each leaked Broadcaster.run() goroutine blocks on a select{} for the lifetime of the test binary. These accumulate across tests and eventually cause the 35-minute CI timeout.

The flaky test name (database-api-load-balancing-discovery-pg_curr_version-1_25-valkey::TestMain) is misleading. The timeout fires while unrelated tests are running because the goroutine leak is cumulative across the entire test binary.

Root cause

  1. NewApp did not clean up the event sink if an error occurred after configureEvents().
  2. Integration tests that create an App (via NewApp or newTestEnv) did not call GracefulShutdown on cleanup.

Fix

  1. Close Broadcaster on NewApp error — add a deferred cleanup in NewApp so that if any step after configureEvents() fails, GracefulShutdown closes the event sink.
  2. Refactor NewApp error cleanup — replace the eventsSinkConfigured bool flag with a named error return and a defer that calls GracefulShutdown on failure, avoiding duplicated sink-close logic.
  3. Add GracefulShutdown to test cleanup — all app_integration_test.go tests that successfully create an App now register GracefulShutdown via t.Cleanup.
  4. Add missing Cleanup calls — several tests in api_integration_test.go create a second newTestEnv (typically with auth options) without calling Cleanup, leaking a Broadcaster. These now call env.Cleanup(t).
  5. Use skipDatabaseNotEnabled helper — lockfile tests replaced manual REGISTRY_DATABASE_ENABLED env var checks with the existing helper for consistency.
Edited by Hayley Swimelar