[
https://issues.apache.org/jira/browse/YUNIKORN-2155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17786250#comment-17786250
]
Kuan-Po Tseng edited comment on YUNIKORN-2155 at 11/15/23 9:04 AM:
-------------------------------------------------------------------
Maybe using a active loop with shorter sleeps ? Something like assert multiple
times with shorter sleeps until it is right in the given time period. Doing
this could make the test elapse less time.
If this approach is acceptable, I'm willing to do this !
was (Author: brandboat):
Maybe using a active loop with shorter sleeps ? Something like assert multiple
times until it is right in the given time period. Doing this could make the
test elapse less time.
If this approach is acceptable, I'm willing to do this !
> Eliminate long time.Sleep() calls from the application test code
> ----------------------------------------------------------------
>
> Key: YUNIKORN-2155
> URL: https://issues.apache.org/jira/browse/YUNIKORN-2155
> Project: Apache YuniKorn
> Issue Type: Bug
> Components: core - common, test - unit
> Reporter: Peter Bacsko
> Priority: Major
>
> {{TestResourceUsageAggregation()}} calls {{time.Sleep(3 * time.Second)}}
> three times. It means this test case sleeps for 9 seconds in total.
> Short sleeps can be acceptable (like the ones in {{{}TestStateTimeOut{}}}),
> but this is a lot. We need a different approach here.
> I recommend using a function variable like {{currentTime}} (type {{func()
> time.Time}}) which by default calls {{time.Now()}} inside
> {{TrackedResource.AggregateTrackedResource()}}. However, tests can change
> this to return an arbitrary {{time.Time}}. The original reference of
> {{currentTime()}} is restored in a defer call.
> {{TestFinishedTime}} also uses {{time.Sleep()}} which seems unnecessary.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]