You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2013/12/23 15:42:01 UTC
[Bug 55925] New: junit task should support parallel/threads option
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
Bug ID: 55925
Summary: junit task should support parallel/threads option
Product: Ant
Version: 1.9.2
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Optional Tasks
Assignee: notifications@ant.apache.org
Reporter: john.elion@verizon.net
Created attachment 31146
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31146&action=edit
Zip file with patch, 5 modified source files to implement junit with parallel
test execution threads
Ant's JUnit task should natively support a "threads" or "parallel" option,
which executes unit tests in parallel in a specified number of threads. The
default if not specified should be 1, which is the current behavior. Given the
set of test to be executed, each of the "n" threads should continue picking off
and executing the 'next' test element until all elements have been executed. I
have made an attempt to implement the feature.
While a possible workaround is to specify a parallel block with multiple JUnit
entries, this forces the burden of breaking the tests down into groups of
roughly equal execution time on the programmer; such blocks may not be
convenient and as the tests evolve and the set grows, the groups are likely to
become uneven unless carefully maintained. This burden should not be
necessary. While 'picking off the next test' doesn't guarantee minimal
execution (the longest test could be the last one) it will generally make a
pretty good improvement.
I have seen one third-party add-on entry into this arena
(http://lmax-exchange.github.io/parallel-junit/), which was a very nice effort.
We got it working but the output was not good - output line ran together,
sometimes were embedded within other lines. I hoped a native implementation
wouldn't have that.
I have attached a patch as well as the 5 modified files in my implementation
attempt, which seems to work well in "per test" execution. I had to add the
test name to the results line, since that line didn't necessarily immediately
follow the "Executing <classname>...". I don't claim to have understood all of
the Ant coding conventions.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 55925] junit task should support parallel/threads option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
--- Comment #3 from Antoine Levy-Lambert <an...@apache.org> ---
Thanks again for reporting this issue and proposing a fix for it.
The changes that you prepare contain at some places the addition of a new
argument threadid to existing protected or public methods.
Can you make a fresh checkout from HEAD out of svn (svn checkout
http://svn.apache.org/repos/asf/ant/core/trunk ant-core) and reapply your
changes, and rework your solution keeping for each method where the threadid
has been added to the argument list a duplicate method with the old signature,
which would call the new method passing a 0 in the threadid argument.
Once this is done please create a new patch file
- then attach the output of "svn diff "
the command to create a sandbox is :
svn checkout http://svn.apache.org/repos/asf/ant/core/trunk ant-core
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 55925] junit task should support parallel/threads option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
John Elion <jo...@verizon.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |john.elion@verizon.net
--- Comment #5 from John Elion <jo...@verizon.net> ---
Created attachment 31404
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31404&action=edit
Patch from core as of 3/15/2014
Updated patch includes requested change (restore original subroutine
signatures).
I also played with haltOnFailure/haltOnError, which had been completely ignored
as the exception simply unwound the thread stack, abandoning a single test
thread but leaving the others to continue running tests. When a test fails and
throws a halt exception (BuildException) the other threads will finish running
whatever (test or batch) they are running but will not start new tests or
batches. I saw the code in the "parallel" task that will immediately abort
other threads but was not prepared to try to merge that in.
Also, I had not realized that some of the options can be overridden by
individual tests or batches. Mixed HaltOnFailure/HaltOnError appears to work
fine, but mixing fork on and off options with threads will not produce nice
results.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 55925] junit task should support parallel/threads option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
Antoine Levy-Lambert <an...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |1.9.4
--- Comment #6 from Antoine Levy-Lambert <an...@apache.org> ---
Patch committed, thanks.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 55925] junit task should support parallel/threads option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
John Elion <jo...@verizon.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31146|0 |1
is obsolete| |
--- Comment #2 from John Elion <jo...@verizon.net> ---
Created attachment 31163
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31163&action=edit
Zip file with patch, 5 modified source files to Ant 1.9.2 release
I wish to update the patch. In my own further testing:
1) I have still been seeing run-on lines in the Ant output; that is, I still am
seeing lines that look like this:
[junit] {1:com.test.classname4] Tests run: 2 Failed: 0 Errors: 0 Elapsed time:
0.952s [junit] {3:com.test.classname9] Tests run: 5 Failed: 0 Errors: 0
Elapsed time: 1.483s
It appears that the OutputStream class in Java is not thread-safe, and that two
unit test threads are occasionally writing Ant output at the same time. This
happens more frequently with shorter tests. So far, in the cases I have seen,
the lines aren't broken except immediately before the line terminator; there is
generally a blank line after the run-on line. This make it harder to process
the log afterwards.
So I have replaced the calls to out.write/out.flush with a synchronized
subroutine. I'm thinking that since each unit test only makes two calls on
this subroutine - once at test start and once at test finish, this isn't a
severe penalty.
2) I have moved the class name printed in the results line (since the result
line for test X may not appear immediately after the line that says "Starting
test X") to the end of the line. This makes the resulting 'results line' looks
mostly like it did before, which should be easer on post-processing scripts.
The patch is against the 1.9.2 release source. Only
SummaryJUnitResultFormatter.java has changed from the previous patch.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 55925] junit task should support parallel/threads option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
Antoine Levy-Lambert <an...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|1.9.2 |1.9.3
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 55925] junit task should support parallel/threads option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
--- Comment #4 from John Elion <jo...@verizon.net> ---
Will do. (If there is a target date let me know - I've seen this request but
won't get to this right away.)
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 55925] junit task should support parallel/threads option
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55925
--- Comment #1 from Antoine Levy-Lambert <an...@apache.org> ---
This is a very useful contribution, I will test that and see if we can get this
in the codebase.
--
You are receiving this mail because:
You are the assignee for the bug.