You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2022/05/04 21:24:00 UTC

[jira] [Updated] (HDDS-6655) Use injected clocks in PipelineManagerImp and BackgroundPipelineScrubber to ease testing

     [ https://issues.apache.org/jira/browse/HDDS-6655?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Attila Doroszlai updated HDDS-6655:
-----------------------------------
    Reporter: Stephen O'Donnell  (was: Mark Gui)

> 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: Stephen O'Donnell
>            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: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org