GitHub user hvanhovell opened a pull request:
https://github.com/apache/spark/pull/16174
[SPARK-18741][STREAMING] Reuse or clean-up SparkContext in streaming tests
## What changes were proposed in this pull request?
Tests in Spark Streaming currently create a `SparkContext` for each test,
and sometimes do not clean-up afterwards. This is resource intensive and it can
lead to unneeded test failures (flakyness) when
park.driver.allowMultipleContexts is disabled (this happens when the order of
tests changes).
This PR makes most test re-use a `SparkContext`. For tests that have to
create a new context (for instance `CheckpointSuite`) we make sure that no
active `SparkContext` exists before the test, and that the created
`SparkContext` is cleaned up afterwards. I have refactored the `TestSuiteBase`
into two classes `TestSuiteBase` and a parent class `ReusableSparkContext`;
this to make `SparkContext` management relatively straightforward for most
tests.
I have done a simple very unscientific benchmark (n=1), and streaming tests
with this patch took 212 seconds and streaming tests without this patch took
252 seconds.
## How was this patch tested?
The patch only covers test code.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/hvanhovell/spark SPARK-18741
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/16174.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #16174
----
commit 04ce488e9d6927f3cb172e854928c78ec094fb8d
Author: Herman van Hovell <[email protected]>
Date: 2016-12-06T16:29:23Z
Reuse or clean-up SparkContext in streaming tests
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]