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

Add test to JobGroupTest #675

Conversation

fedejeanne
Copy link
Contributor

@fedejeanne fedejeanne commented Sep 11, 2023

Add the test method org.eclipse.core.tests.runtime.jobs.JobGroupTest.testShouldCancel_5(). This test proves that the cancelation of "sibling" jobs in a JobGroup should be done via the cancelation policy of the group and not via the monitor.

This PR provides doesn't solve any issue, it merely provides context to this discussion: #654 (see comment)

@github-actions
Copy link
Contributor

github-actions bot commented Sep 11, 2023

Test Results

       42 files  ±0         42 suites  ±0   58m 58s ⏱️ + 2m 13s
  3 777 tests +1    3 774 ✔️ +1    3 💤 ±0  0 ±0 
11 334 runs  +3  11 307 ✔️ +3  27 💤 ±0  0 ±0 

Results for commit 4aef675. ± Comparison against base commit ca35cee.

♻️ This comment has been updated with latest results.

@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch 4 times, most recently from 79efc2e to 430ac3b Compare September 12, 2023 08:09
@fedejeanne fedejeanne marked this pull request as ready for review September 12, 2023 13:30
@fedejeanne
Copy link
Contributor Author

I'm a bit baffled about this error (it happens under Linux):

Error:  Failed to execute goal org.eclipse.tycho:tycho-apitools-plugin:4.0.2:verify (verify) on project org.eclipse.help.base: Execute ApiApplication failed: Application returned exit code 10 -> [Help 1]

It doesn't say much. Any ideas what could it be or how to fix it?

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added test randomly fails due to multiple race conditions. In particular, there is no order of the jobs to be executed, so cancelling the job group once a job with a specific number is executed does not give any guarantee regarding the number of jobs that have run in the end.

To reproduce a failure due to a race condition, add a sleep of several milliseconds into the if clause of the run method. The test will constantly fail.

@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch from 430ac3b to 6cf0bbe Compare September 19, 2023 13:23
@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch from 6cf0bbe to baa0a8e Compare September 19, 2023 13:32
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose the usage of a barrier instead of multiple latches for the reasons I give in the code comment.
In addition, the current implementation does not guarantee that all jobs are finished when the test finishes, as waitForCompletion has a timeout and may leave the jobs running. Using a barrier that waits in the main thread for at least the time the jobs themselves wait on that barrier avoids that risk.

@fedejeanne fedejeanne closed this Sep 21, 2023
@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch from baa0a8e to 3b64a07 Compare September 21, 2023 15:09
@fedejeanne fedejeanne reopened this Sep 21, 2023
@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch from e4b7455 to 97a12cf Compare September 22, 2023 07:32
@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch from 97a12cf to a6323c1 Compare September 22, 2023 08:34
@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch from 95acc32 to e0b0d0f Compare September 25, 2023 11:08
Add the test method
org.eclipse.core.tests.runtime.jobs.JobGroupTest.testShouldCancel_5().

See discussion:
eclipse-platform#654
@fedejeanne fedejeanne force-pushed the enhancements/add-testShouldCancel_5-to-JobGroupTest branch from e0b0d0f to 4aef675 Compare September 26, 2023 07:12
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test seems to be sound now. Hope that we did not drop something important during all the iterations 😉

We can merge after the freeze period.

@HeikoKlare HeikoKlare merged commit 9dbc9e4 into eclipse-platform:master Sep 29, 2023
13 of 14 checks passed
@fedejeanne fedejeanne deleted the enhancements/add-testShouldCancel_5-to-JobGroupTest branch September 29, 2023 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants