implement "parallelism-safe" Yatspec results generation, and fix memory leak #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Yatspec's
HtmlIndexRenderer
doesn't currently support test runs that occur across multiple JVM's - for example, builds that seek to improve performance by simultaneously running tests in several JVMs in parallel (as in Surefire withforkCount
> 1), or builds that take an expedient approach to combating resource leaks by killing and re-spawning their test runner every so often (as in Gradle withforkEvery
> 0).This is because
HtmlIndexRenderer
only knows about tests run within its own JVM - more complex builds such as those described above would need some mechanism for passing data about test results between JVMs for index generation to work properly. This PR implements such a mechanism:ResultMetadata
, which provides a high-level subset of test result data sufficient forHtmlIndexRenderer
and other classes that generate "summary"/"index" reports; andSpecResultMetadataListener
, which a class can implement to receive this data about completed tests.HtmlIndexRenderer
is refactored to implement the latter interface.Result
andSpecResultListener
?Result
s between JVMs would require that whatever people put in their captured values beSerializable
, which is a big ask/would break backward compatibility.HtmlIndexRenderer
only holds onto the data it needs - and not captured values/spec text/other details which can run to hundreds/thousands of K per test for complex interaction tests - we've fixed a memory leak.ResultMedatata
for the test to the directory specified in theyatspec.data.dir
system property, using plain old Java serialization (so no additional library dependencies on Jackson/XStream/whatever). We also check this directory for any test results which may have appeared since the last test was completed, and if any are found, feed these to anySpecResultMetadataListener
s which have been registered.yatspec.data.dir
system property has a value - if this isn't specified, this mechanism doesn't operate, and Yatspec behaves as before.yatspec.data.dir
between runs, lest results from previous runs show up in any generated reports.SpecResultMetadataListener
s, and notSpecResultListener
s, get called by this mechanism - the idea being that each JVM should be responsible for writing the main result files about its tests, but index files should be a collective responsibility.Using this improved Yatspec has allowed us to use parallelism for the first time in some of our acceptance test builds, in one case improving the time of a notoriously long-running build by 40%. It's also improved index coverage in other builds which spawn multiple runners, to the point where these have become usable for the first time.
Note that to maintain backwards source compatibility with existing Yatspec uses these changes utilize default interface methods and therefore will require Java 8.