Dale Richardson created YUNIKORN-3366:
-----------------------------------------

             Summary: Instrumented-package tests leak core-service goroutines 
by not stopping the services they start
                 Key: YUNIKORN-3366
                 URL: https://issues.apache.org/jira/browse/YUNIKORN-3366
             Project: Apache YuniKorn
          Issue Type: Bug
          Components: core - scheduler
            Reporter: Dale Richardson


Instrumented-package tests leak core-service goroutines by not stopping the 
services they start
Description:
Follow-up to YUNIKORN-3357 (PR #1124); burns down the "stoppable" leakcheck 
exemptions that are
test hygiene rather than production defects:
* scheduler.(*partitionManager).cleanRoot
* scheduler.(*partitionManager).cleanExpiredApps
* common/security.(*UserGroupCache).run
* events.(*EventSystemImpl).StartServiceWithPublisher.func1 (the test-only half)

These goroutines are all correctly stoppable in production — 
{{ClusterContext.Stop}} stops the two partition cleaners started by 
{{partitionManager.Run}}, {{UserGroupCache.Stop()}} closes the cleaner and 
resets the singleton (and {{ClusterContext.Stop}} calls it), and 
{{EventSystemImpl.Stop()}} stops the handler. The leaks are tests that 
construct these services (via {{events.Init()}}/{{StartService}}, a 
{{ClusterContext}}, or user resolution) and never call {{Stop()}}, so the 
goroutines outlive the test binary.

Repro: remove the corresponding exemption in 
{{pkg/common/leakcheck/leakcheck.go}} and run the package, e.g.
{code}
go test ./pkg/scheduler/... ./pkg/common/security/... ./pkg/events/...
{code}
goleak's {{VerifyTestMain}} then fails the binary with the leaked stack.

Proposed fix: have the affected tests {{defer <service>.Stop()}} after starting 
it, then delete the four exemptions. Can be split per-package if preferred 
(partition cleaners / UserGroupCache / event system).




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to