forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix goroutine leaks in otlptracegrpc testing (#2409)
* Fail in RunEndToEndTest if collector stop fails * Use testing T.Cleanup to check shut downs * Add goroutine leak detection * Fix TestExporterShutdown go leak The shutdown tests checking if a context error is honored did not completely clean up the resources used by the client after the error was evaluated. Update the connection client to handle multiple calls to shutdown and make a second call to these clients that must succeed so the test does not have abandoned goroutines. * Fix leak in TestNew_WithTimeout The mockTraceService did not delay with its lock being held. This resulted in the mockCollector stopping and being able to acquire the lock. It was assumed that no export was taking place because of this and the mockTraceService was abandoned without cleaning up resources it held and goroutines it had spawned. This reworks the export blocking logic to block on a channel read. This will make the block more deterministic and not depend on the scheduler timing. Additionally, this blocking is moved inside the lock acquire. Meaning code will deadlock if the block is not released before a shutdown (something the developer will immediately be aware of when they submit a bad patch), and will ensure all resources are released before shutdown. Replace TestNew_WithTimeout with TestExportSpansTimeoutHonored which directly tests if a span export errors when the timeout is reached. This is the only unique thing that TestNew_WithTimeout, but it also tests the non-error path. That non-error path is tested in many other tests. * Guard otlptracehttp client stopCh when stopping In normal operations the exporter is guaranteed to only ever call the client Stop method once. However in testing we need to call this multiple times when checking it returns an error in particular context. Add a lightweight sync.Once to the closing of the stopCh to ensure tests do not panic when cleaning up. * Release export block after export Prevent deadlock in TestExportSpansTimeoutHonored.
- Loading branch information
Showing
9 changed files
with
193 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.