Make ProjectUtils.waitForProjects() more robust#1552
Conversation
| // track whether we've reached a fixpoint in the build errors | ||
| allBuildErrors = getAllBuildErrors(projects); | ||
| if (DEBUG) { | ||
| buildErrorsChanging = |
There was a problem hiding this comment.
Would it make sense to try to check whether the build errors are the same as in the previous round instead of just the change in the count?
There was a problem hiding this comment.
It would. I should just put them into a Set and do a comparison with equals().
| @@ -184,9 +187,12 @@ public void run() { | |||
| /** Wait for any spawned jobs and builds to complete (e.g., validation jobs). */ | |||
| public static void waitForProjects(Runnable delayTactic, IProject... projects) { | |||
There was a problem hiding this comment.
This method is pretty long, I suggest to break out parts into helper methods:
- collecting jobs (including filtering on line 214-219
- logic when more than 60 seconds has passed
| Collections.addAll(jobs, jobManager.find("org.eclipse.wst.server.ui.family")); | ||
| Collections.addAll(jobs, jobManager.find(ValidationBuilder.FAMILY_VALIDATION_JOB)); | ||
|
|
||
| // Remove SLEEPING jobs as they may not run for a long time. |
There was a problem hiding this comment.
Tests are failing reliably, and I wonder if it has something to do with this. The Javadoc of Job.schedule() says
* Schedules this job to be run after a specified delay. The job is put in the
* {@link #SLEEPING} state until the specified delay has elapsed, after which
* the job is added to a queue of {@link #WAITING} jobs.
So, if an important job is scheduled with a delay, there is a chance we don't catch it. Not sure though.
| } | ||
| } | ||
| } | ||
| if (timer.elapsed(TimeUnit.SECONDS) > 60) { |
There was a problem hiding this comment.
So, if we go over 60 seconds, I guess we will print the state very frequently, every time we loop? A small interval might be a good idea.
|
There's something special about the autobuild jobs. |
Codecov Report
@@ Coverage Diff @@
## master #1552 +/- ##
============================================
+ Coverage 70.53% 71.27% +0.73%
- Complexity 1307 1341 +34
============================================
Files 233 233
Lines 8995 9198 +203
Branches 765 793 +28
============================================
+ Hits 6345 6556 +211
+ Misses 2326 2322 -4
+ Partials 324 320 -4
Continue to review full report at Codecov.
|
- minimize output to what's necessary - do proper build-error comparisons
|
PTAL @akerekes @chanseokoh |
| buildErrorsChanging = !previousBuildErrors.equals(currentBuildErrors); | ||
| previousBuildErrors = currentBuildErrors; | ||
|
|
||
| if (DEBUG || timer.elapsed(TimeUnit.SECONDS) > 10) { |
There was a problem hiding this comment.
I hope this doesn't print out too many messages. Once we go over 10 seconds, we log every time we loop.
There was a problem hiding this comment.
But we sleep, and we only log for the conditions that keep us in the loop which is important info.
ProjectUtils#waitForProjects()has a few issues:ProjectUtils#waitForProjects()would spin trying to join on the workbench's Auto-Build job.This change ensures:
Jobs