[
https://issues.apache.org/jira/browse/HDDS-6655?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Attila Doroszlai resolved HDDS-6655.
------------------------------------
Fix Version/s: 1.3.0
Resolution: Implemented
> Use injected clocks in PipelineManagerImp and BackgroundPipelineScrubber to
> ease testing
> ----------------------------------------------------------------------------------------
>
> Key: HDDS-6655
> URL: https://issues.apache.org/jira/browse/HDDS-6655
> Project: Apache Ozone
> Issue Type: Improvement
> Reporter: Mark Gui
> Assignee: Stephen O'Donnell
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.3.0
>
>
> "There are a couple of places in the new scrubber code and the existing
> scrubber code in PipelineManagerImpl, where it uses {{Time.monotonicNow()}}
> to decide if the Safemode interval has passed, or if a pipeline has been
> Closed long enough etc. The unit tests do not correctly test these scenarios,
> as we just set the time to zero so there is no delay, otherwise the tests
> would need sleep calls, which will make them slow.
> In ReplicationManager, we addressed this problem by injecting a Clock
> dependency. See {{MonotonicClock}} - if we inject this as a dependency to the
> scrubber code, then we can inject a {{MonotonicClock}} for runtime, but
> inject {{TestClock}} for tests. Then you can properly test the safemode delay
> by advancing the clock between check calls. Same for pipelines - we can check
> CLOSED ones are not removed before the delay, and then check they are
> scrubbed after the delay.
> In general, we should try to avoid calls to {{Time.monotonicNow()}} across
> the codebase, and instead inject a clock as a dependency to make the code
> more testable without sleeps."
> -- Stephen
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]