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

Fix Random Failing UIEditWorkingSetWizardAuto.testEditPage #275 #1803

Conversation

Wittmaxi
Copy link
Contributor

@Wittmaxi Wittmaxi commented Apr 9, 2024

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes and editors before deleting the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the project-root.

This fix introduces a significant slowdown of the test (testing takes up to 2 seconds!) but since this is a single test and the test is important and the amount of fails (2%!) is big enough, I believe this tradeoff is very much justified.

I am confident in this fix working after seeing 400 consecutive runs that did not contain any fails (on windows).

#275

Copy link
Contributor

github-actions bot commented Apr 9, 2024

Test Results

   921 files  ±0     921 suites  ±0   45m 48s ⏱️ - 2m 3s
 7 516 tests ±0   7 365 ✅ ±0  151 💤 ±0  0 ❌ ±0 
23 700 runs  ±0  23 193 ✅ ±0  507 💤 ±0  0 ❌ ±0 

Results for commit d684fab. ± Comparison against base commit e987ac1.

♻️ This comment has been updated with latest results.

@Wittmaxi
Copy link
Contributor Author

Wittmaxi commented Apr 9, 2024

Random failing tests for this PR are documented here:

#1583
#1005

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.

Great to see this test failure being addressed, thank you! I have some questions/comments on the proposed fix.

@Wittmaxi Wittmaxi force-pushed the MW_FixRandomFailingUIEditWOrkingSetWizardAuto branch from 4759747 to ded182d Compare April 10, 2024 11:41
@Wittmaxi
Copy link
Contributor Author

Wittmaxi commented Apr 10, 2024

In 2000 consecutive runs, the error did not occur. If you try this yourself: there is an error occurring on the second run of the test:

grafik

This fail ALWAYS happens, ALWAYS on the second run of the series and NEVER in another place - I do not believe it to be worth our time since it is almost certainly related to having multiple runs back-to-back instead of running the test once (as it is intended to be).

Additionally, the test is now much faster, taking about 0.25s on average

@Wittmaxi
Copy link
Contributor Author

Random Failing test documented here: #1005

@Wittmaxi Wittmaxi force-pushed the MW_FixRandomFailingUIEditWOrkingSetWizardAuto branch from ded182d to 761cffd Compare April 11, 2024 06:42
@Wittmaxi
Copy link
Contributor Author

I believe the fix to be more adequate now

@Wittmaxi Wittmaxi force-pushed the MW_FixRandomFailingUIEditWOrkingSetWizardAuto branch 2 times, most recently from 8bb3de7 to 60d6f37 Compare April 12, 2024 08:42
@HeikoKlare HeikoKlare force-pushed the MW_FixRandomFailingUIEditWOrkingSetWizardAuto branch from 60d6f37 to 681b3a8 Compare April 16, 2024 09:06
Copy link
Contributor

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

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

You should recover the original value for auto-building after finishing the test.

@Override
public void doTearDown() throws Exception {
super.doTearDown();
setAutoBuilding(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't assume true was the original value.

Instead, save the original value in doSetUp and apply it again in doTearDown

Copy link
Contributor

Choose a reason for hiding this comment

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

Since there will be other tests that do not clean up properly, it is usually better to restore defaults than restoring the state before the test. So a general cleanup (also used by the platform resource tests), is to just restore the default workspace description:

ResourcesPlugin.getWorkspace().setDescription(Workspace.defaultWorkspaceDescription());

Copy link
Contributor

Choose a reason for hiding this comment

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

This would make the test(s) meddle with each other but I guess since one is restoring the default value then it should be OK.

In that case, why not push this all the way to the top to UITestCase::tearDown?

Copy link
Contributor

Choose a reason for hiding this comment

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

This would make the test(s) meddle with each other

It would do the exact opposite.

In that case, why not push this all the way to the top to UITestCase::tearDown?

Because it is out-of-scope of this PR to refactor the complete UI test infrastructure. Having unified cleanups to ensure proper test isolation would of course make sense but should be done (1) as a separate task and (2) should be done properly using mechanisms like JUnit 4 rules or JUnit 5 extensions instead of fostering test class inheritance.

Copy link
Contributor

Choose a reason for hiding this comment

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

This would make the test(s) meddle with each other

It would do the exact opposite.

It's a hack that makes this test "fix whatever other tests might have broken", that's what I meant. But it's ok, it's outside the scope of this PR to hunt down all the offending tests ;-) . BTW do you already know of any such tests (by name) or does this have to be investigated yet?

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW do you already know of any such tests (by name) or does this have to be investigated yet?

If I knew them, I would have created a ticket or fixed them. Most of the test failures I faced in the last year have one of two reasons:

  1. Race conditions
  2. Improper test isolation

What can be done systematically to ensure isolation is to encapsulate state changes or potential leaks (like job execution) into proper rules (JUnit 4) or extensions (JUnit 5).

@Wittmaxi
Copy link
Contributor Author

I have now changed the Setup/Teardown to

  1. disable autobuilding for the test
  2. reset the workspace description (as Heiko suggested)
@Override
  public void doSetUp() throws Exception {
  super.doSetUp();
  setAutoBuilding(false);
}

@Override
public void doTearDown() throws Exception {
  super.doTearDown();
  ResourcesPlugin.getWorkspace().setDescription(Workspace.defaultWorkspaceDescription());
}

…atform#275

In my experiments, the test failed in roughly 2% of runs.

The test didn't close all processes which potentially
accessed the files it contained.
This PR Makes the Job-Manager join all jobs before finally deleting the
project-root.

eclipse-platform#275
@Wittmaxi Wittmaxi force-pushed the MW_FixRandomFailingUIEditWOrkingSetWizardAuto branch from 681b3a8 to d684fab Compare April 16, 2024 15:54
@HeikoKlare
Copy link
Contributor

Failing checks because of new issues are only because of an outdated reference build. Recent master build reports the same new issues: https://ci.eclipse.org/platform/job/eclipse.platform.ui/job/master/421/

@HeikoKlare HeikoKlare merged commit d03f4ff into eclipse-platform:master Apr 17, 2024
13 of 16 checks passed
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.

3 participants