-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
Conversation
Test build #100559 has finished for PR 23413 at commit
|
Test build #100570 has finished for PR 23413 at commit
|
@@ -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)) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Test build #100684 has finished for PR 23413 at commit
|
Test build #100694 has finished for PR 23413 at commit
|
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Test build #100797 has finished for PR 23413 at commit
|
Test build #100806 has finished for PR 23413 at commit
|
retest this please |
Test build #100834 has finished for PR 23413 at commit
|
retest this please |
Test build #100843 has finished for PR 23413 at commit
|
Merging to master. |
@@ -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) |
There was a problem hiding this comment.
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 .
…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>
What changes were proposed in this pull request?
The PR makes hardcoded
spark.test
andspark.testing
configs to useConfigEntry
and put them in the config package.How was this patch tested?
existing UTs