-
Notifications
You must be signed in to change notification settings - Fork 28.8k
[SPARK-53176][DEPLOY] Spark launcher should respect --load-spark-defaults
#51905
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,20 +38,91 @@ public class SparkSubmitCommandBuilderSuite extends BaseSuite { | |
|
||
private static File dummyPropsFile; | ||
private static File connectPropsFile; | ||
private static File driverMemPropsFile; | ||
private static SparkSubmitOptionParser parser; | ||
|
||
@BeforeAll | ||
public static void setUp() throws Exception { | ||
dummyPropsFile = File.createTempFile("spark", "properties"); | ||
connectPropsFile = File.createTempFile("spark", "properties"); | ||
Files.writeString(connectPropsFile.toPath(), "spark.remote=sc://connect-server:15002"); | ||
driverMemPropsFile = File.createTempFile("spark", "properties"); | ||
Files.writeString(driverMemPropsFile.toPath(), | ||
"spark.driver.memory=4g\nspark.driver.memoryOverhead=768m"); | ||
parser = new SparkSubmitOptionParser(); | ||
} | ||
|
||
@AfterAll | ||
public static void cleanUp() throws Exception { | ||
dummyPropsFile.delete(); | ||
connectPropsFile.delete(); | ||
driverMemPropsFile.delete(); | ||
} | ||
|
||
@Test | ||
public void testGetEffectiveConfig() throws Exception { | ||
doTestGetEffectiveConfig(null, true, true); | ||
doTestGetEffectiveConfig(null, true, false); | ||
doTestGetEffectiveConfig(null, false, true); | ||
doTestGetEffectiveConfig(null, false, false); | ||
doTestGetEffectiveConfig(driverMemPropsFile, true, true); | ||
doTestGetEffectiveConfig(driverMemPropsFile, true, false); | ||
doTestGetEffectiveConfig(driverMemPropsFile, false, true); | ||
doTestGetEffectiveConfig(driverMemPropsFile, false, false); | ||
} | ||
|
||
private void doTestGetEffectiveConfig( | ||
File propertiesFile, boolean loadSparkDefaults, boolean confDriverMemory) throws Exception { | ||
SparkSubmitCommandBuilder launcher = | ||
newCommandBuilder(Collections.emptyList()); | ||
launcher.loadSparkDefaults = loadSparkDefaults; | ||
launcher.conf.put("spark.foo", "bar"); | ||
launcher.childEnv.put("SPARK_CONF_DIR", System.getProperty("spark.test.home") | ||
+ "/launcher/src/test/resources"); | ||
|
||
if (propertiesFile != null) { | ||
launcher.setPropertiesFile(propertiesFile.getAbsolutePath()); | ||
} | ||
|
||
if (confDriverMemory) { | ||
launcher.conf.put(SparkLauncher.DRIVER_MEMORY, "2g"); | ||
} | ||
|
||
Map<String, String> effectiveConfig = launcher.getEffectiveConfig(); | ||
|
||
assertEquals("bar", effectiveConfig.get("spark.foo")); | ||
if (confDriverMemory) { | ||
assertEquals("2g", effectiveConfig.get(SparkLauncher.DRIVER_MEMORY)); | ||
} else if (propertiesFile != null) { | ||
try (FileReader reader = new FileReader(propertiesFile, StandardCharsets.UTF_8)) { | ||
Properties props = new Properties(); | ||
props.load(reader); | ||
if (props.containsKey(SparkLauncher.DRIVER_MEMORY)) { | ||
assertEquals(props.getProperty(SparkLauncher.DRIVER_MEMORY), | ||
effectiveConfig.get(SparkLauncher.DRIVER_MEMORY)); | ||
} | ||
} | ||
} else { | ||
assertEquals("1g", effectiveConfig.get(SparkLauncher.DRIVER_MEMORY)); | ||
} | ||
|
||
if (propertiesFile != null) { | ||
try (FileReader reader = new FileReader(propertiesFile, StandardCharsets.UTF_8)) { | ||
Properties props = new Properties(); | ||
props.load(reader); | ||
if (props.containsKey("spark.driver.memoryOverhead")) { | ||
assertEquals(props.getProperty("spark.driver.memoryOverhead"), | ||
effectiveConfig.get("spark.driver.memoryOverhead")); | ||
} | ||
} | ||
if (loadSparkDefaults) { | ||
assertEquals("/driver", effectiveConfig.get(SparkLauncher.DRIVER_EXTRA_CLASSPATH)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the default props contain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I reuse the existing |
||
} else { | ||
assertFalse(effectiveConfig.containsKey(SparkLauncher.DRIVER_EXTRA_CLASSPATH)); | ||
} | ||
} else { | ||
assertEquals("/driver", effectiveConfig.get(SparkLauncher.DRIVER_EXTRA_CLASSPATH)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this require There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's only present at |
||
} | ||
} | ||
|
||
@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.
Does this test use
loadSparkDefaults
to conditionally check something? Seems no?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.
used at line 118