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

[SPARK-26491][CORE][TEST] Use ConfigEntry for hardcoded configs for test categories #23413

Closed
wants to merge 7 commits into from

Conversation

mgaido91
Copy link
Contributor

What changes were proposed in this pull request?

The PR makes hardcoded spark.test and spark.testing configs to use ConfigEntry and put them in the config package.

How was this patch tested?

existing UTs

@SparkQA
Copy link

SparkQA commented Dec 30, 2018

Test build #100559 has finished for PR 23413 at commit 73618ce.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 30, 2018

Test build #100570 has finished for PR 23413 at commit ba41657.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mgaido91
Copy link
Contributor Author

mgaido91 commented Jan 1, 2019

cc @dongjoon-hyun @ueshin

@@ -267,7 +268,7 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
}

// Disable the background thread during tests.
if (!conf.contains("spark.testing")) {
if (!conf.contains(IS_TESTING)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can probably be Utils.isTesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, here we are checking the SparkConf, while in Utils.isTesting we check the system properties. So I don't think it is doable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, that's kinda the point. spark.testing is set as a system property by the build scripts. SparkConf just inherits system properties, which is why you can also check it there.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I saw your comment about the SHS tests removing the testing conf, let me take a look...)

@@ -103,7 +104,7 @@ private[deploy] class Worker(
private val CLEANUP_NON_SHUFFLE_FILES_ENABLED =
conf.getBoolean("spark.storage.cleanupFilesAfterExecutorExit", true)

private val testing: Boolean = sys.props.contains("spark.testing")
private val testing: Boolean = sys.props.contains(IS_TESTING.key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

@@ -43,7 +44,7 @@ private[spark] case class ProcfsMetrics(
// project.
private[spark] class ProcfsMetricsGetter(procfsDir: String = "/proc/") extends Logging {
private val procfsStatFile = "stat"
private val testing = sys.env.contains("SPARK_TESTING") || sys.props.contains("spark.testing")
private val testing = sys.env.contains("SPARK_TESTING") || sys.props.contains(IS_TESTING.key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

@@ -202,7 +203,7 @@ class TaskMetrics private[spark] () extends Serializable {
}

// Only used for test
private[spark] val testAccum = sys.props.get("spark.testing").map(_ => new LongAccumulator)
private[spark] val testAccum = sys.props.get(IS_TESTING.key).map(_ => new LongAccumulator)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it is doable but the code would become an if which seems to me less clean than the current code

.longConf
.createWithDefault(100)

val IS_TESTING = ConfigBuilder("spark.testing")
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to me that if you use Utils.isTesting everywhere, you don't need this. I took a look at the places where IS_TESTING is set explicitly, and they should work with that code removed. Unless there's a test that relies on isTesting being false, that should be doable.

spark.testing is set by the build scripts, so tests shouldn't need to set it to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are cases when it is removed (see the HistoryServer one) and when it is set to false (in the Kubernetes one). So I don't think it is doable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually tried out the k8s tests without that line and they work fine, which tells me it's not needed. Same for a lot of other explicit checks and setting of that property. I think eventually we should fix all this code to not mess with that property, especially since it's so inconsistent (SparkConf vs. system properties vs. env variable).

The SHS test does need to remove the conf, though; it could be implemented differently, but at that point it's probably better to do a separate change and leave this one as a simple "make everybody use constants for this" change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 for this. I think we should check case by case if some of them are not needed and removed, but I agree we best do that in dedicated PRs for each of these cases.

@SparkQA
Copy link

SparkQA commented Jan 3, 2019

Test build #100684 has finished for PR 23413 at commit b54a07b.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 3, 2019

Test build #100694 has finished for PR 23413 at commit a0ae515.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

@vanzin vanzin left a comment

Choose a reason for hiding this comment

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

looks good with a minor comment.

@@ -126,8 +127,8 @@ object SizeEstimator extends Logging {
private def getIsCompressedOops: Boolean = {
// This is only used by tests to override the detection of compressed oops. The test
Copy link
Contributor

Choose a reason for hiding this comment

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

Given this comment I wonder if changing this one config is needed. (I also don't see any SparkConf available in this context, so looks that even that route is not possible.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are cases when this config is set in the tests. It seems it is useless indeed, since we read it only here as a system property. I think we can consider removing the useless set as part of another PR related to that.

Otherwise we can try and replace the config with a string TEST_USE_COMPRESSED_OOPS_KEY which we use when setting/reading the system property. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't mean it's useless (it might be, didn't look), just that it could be kept as a system property instead of a config constant (since it's never set in or read from SparkConf). Using a string constant sounds fine, but given what I think is the goal of these changes (see SPARK-26060), that wouldn't really change much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the point is: it is set in SparkConf in some tests. But this is probably useless because we read it only here as a system property.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see; then it can probably be just removed from those tests.

@SparkQA
Copy link

SparkQA commented Jan 5, 2019

Test build #100797 has finished for PR 23413 at commit 10e0237.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 6, 2019

Test build #100806 has finished for PR 23413 at commit 0df2dfe.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mgaido91
Copy link
Contributor Author

mgaido91 commented Jan 6, 2019

retest this please

@SparkQA
Copy link

SparkQA commented Jan 6, 2019

Test build #100834 has finished for PR 23413 at commit 0df2dfe.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mgaido91
Copy link
Contributor Author

mgaido91 commented Jan 6, 2019

retest this please

@SparkQA
Copy link

SparkQA commented Jan 6, 2019

Test build #100843 has finished for PR 23413 at commit 0df2dfe.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@vanzin
Copy link
Contributor

vanzin commented Jan 7, 2019

Merging to master.

@asfgit asfgit closed this in 1a64152 Jan 7, 2019
@@ -67,7 +68,7 @@ private[spark] class KubernetesTestComponents(defaultClient: DefaultKubernetesCl
.set("spark.executors.instances", "1")
.set("spark.app.name", "spark-test-app")
.set("spark.ui.enabled", "true")
.set("spark.testing", "false")
.set(IS_TESTING, false)
Copy link
Member

Choose a reason for hiding this comment

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

Hi, All.
This causes a compilation failure because this is SparkAppConf. I made a PR, #23505 .

jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
…est categories

## What changes were proposed in this pull request?

The PR makes hardcoded `spark.test` and `spark.testing` configs to use `ConfigEntry` and put them in the config package.

## How was this patch tested?

existing UTs

Closes apache#23413 from mgaido91/SPARK-26491.

Authored-by: Marco Gaido <marcogaido91@gmail.com>
Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
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.

4 participants