Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCK enhancement poll for task completion instead of sleeping #223

Closed
KyleAure opened this issue May 13, 2022 · 1 comment
Closed

TCK enhancement poll for task completion instead of sleeping #223

KyleAure opened this issue May 13, 2022 · 1 comment
Assignees
Labels
EE11 Suggested changes for Jakarta EE 11 enhancement New feature or request TCK
Milestone

Comments

@KyleAure
Copy link
Contributor

Currently, there are a number of tests that will use Thread.sleep() to pause execution to wait for task completion.
During the TCK port I centralized this activity to a single point for future enhancement:

/**
* USE WITH CAUTION!!
* When possible tests should use waitFor methods to wait for specific condition to be meet.
* Pausing the thread for a specific duration will directly impact test performance but in some cases is required.
*
* Pauses the calling thread for the specified duration
*
* @param duration - duration to sleep
* @throws InterruptedException
*/
public static void sleep(Duration duration) throws InterruptedException {
log.config("Sleeping " + duration.toMillis() + " milliseconds");
Thread.sleep(duration.toMillis());
}

Instead of sleeping the thread, we should instead use the already available waitForXXX() methods that exist in the test utility.
Or for cases when we are going down an error path and need to wait for something to expire, we should perform polling to either fail, or succeed as quickly as possible.

There are instances where polling is already performed and the poll interval and duration are standardized to a constant here:

//Durations
/** 1 second */
public static final Duration PollInterval = Duration.ofSeconds(1);
/** 15 seconds */
public static final Duration WaitTimeout = Duration.ofSeconds(15);

Consider introducing system properties to allow for implementations to specify their own interval and duration.

@KyleAure KyleAure added enhancement New feature or request TCK EE11 Suggested changes for Jakarta EE 11 labels May 13, 2022
@smillidge smillidge added this to the 3.1 milestone Jun 20, 2022
@KyleAure KyleAure changed the title TCK enhancement pool for task completion instead of sleeping TCK enhancement poll for task completion instead of sleeping Jul 31, 2023
@KyleAure KyleAure self-assigned this Aug 21, 2023
@KyleAure
Copy link
Contributor Author

I've standardized this behavior whenever possible in the TCK. There are now only a few required places were we need to sleep to verify behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EE11 Suggested changes for Jakarta EE 11 enhancement New feature or request TCK
Projects
None yet
Development

No branches or pull requests

2 participants