@@ -1113,6 +1113,23 @@ class SparkSubmitSuite
1113
1113
}
1114
1114
}
1115
1115
1116
+ test(" SPARK-48392: Allow both spark-defaults.conf and properties file" ) {
1117
+ forConfDir(Map (" spark.executor.memory" -> " 3g" )) { path =>
1118
+ withPropertyFile(" spark-conf.properties" , Map (" spark.executor.cores" -> " 16" )) { propsFile =>
1119
+ val unusedJar = TestUtils .createJarWithClasses(Seq .empty)
1120
+ val args = Seq (
1121
+ " --class" , SimpleApplicationTest .getClass.getName.stripSuffix(" $" ),
1122
+ " --name" , " testApp" ,
1123
+ " --master" , " local" ,
1124
+ " --properties-file" , propsFile,
1125
+ unusedJar.toString)
1126
+ val appArgs = new SparkSubmitArguments (args, env = Map (" SPARK_CONF_DIR" -> path))
1127
+ appArgs.executorMemory should be(" 3g" )
1128
+ appArgs.executorCores should be(" 16" )
1129
+ }
1130
+ }
1131
+ }
1132
+
1116
1133
test(" support glob path" ) {
1117
1134
withTempDir { tmpJarDir =>
1118
1135
withTempDir { tmpFileDir =>
@@ -1623,6 +1640,22 @@ class SparkSubmitSuite
1623
1640
}
1624
1641
}
1625
1642
1643
+ private def withPropertyFile (fileName : String , conf : Map [String , String ])(f : String => Unit ) = {
1644
+ withTempDir { tmpDir =>
1645
+ val props = new java.util.Properties ()
1646
+ val propsFile = File .createTempFile(fileName, " " , tmpDir)
1647
+ val propsOutputStream = new FileOutputStream (propsFile)
1648
+ try {
1649
+ conf.foreach { case (k, v) => props.put(k, v) }
1650
+ props.store(propsOutputStream, " " )
1651
+ } finally {
1652
+ propsOutputStream.close()
1653
+ }
1654
+
1655
+ f(propsFile.getPath)
1656
+ }
1657
+ }
1658
+
1626
1659
private def updateConfWithFakeS3Fs (conf : Configuration ): Unit = {
1627
1660
conf.set(" fs.s3a.impl" , classOf [TestFileSystem ].getCanonicalName)
1628
1661
conf.set(" fs.s3a.impl.disable.cache" , " true" )
@@ -1694,40 +1727,31 @@ class SparkSubmitSuite
1694
1727
val infixDelimFromFile = s " ${delimKey}infixDelimFromFile " -> s " ${CR }blah ${LF }"
1695
1728
val nonDelimSpaceFromFile = s " ${delimKey}nonDelimSpaceFromFile " -> " blah\f "
1696
1729
1697
- val testProps = Seq (leadingDelimKeyFromFile, trailingDelimKeyFromFile, infixDelimFromFile,
1730
+ val testProps = Map (leadingDelimKeyFromFile, trailingDelimKeyFromFile, infixDelimFromFile,
1698
1731
nonDelimSpaceFromFile)
1699
1732
1700
- val props = new java.util.Properties ()
1701
- val propsFile = File .createTempFile(" test-spark-conf" , " .properties" ,
1702
- Utils .createTempDir())
1703
- val propsOutputStream = new FileOutputStream (propsFile)
1704
- try {
1705
- testProps.foreach { case (k, v) => props.put(k, v) }
1706
- props.store(propsOutputStream, " test whitespace" )
1707
- } finally {
1708
- propsOutputStream.close()
1709
- }
1733
+ withPropertyFile(" test-spark-conf.properties" , testProps) { propsFile =>
1734
+ val clArgs = Seq (
1735
+ " --class" , " org.SomeClass" ,
1736
+ " --conf" , s " ${lineFeedFromCommandLine._1}= ${lineFeedFromCommandLine._2}" ,
1737
+ " --conf" , " spark.master=yarn" ,
1738
+ " --properties-file" , propsFile,
1739
+ " thejar.jar" )
1710
1740
1711
- val clArgs = Seq (
1712
- " --class" , " org.SomeClass" ,
1713
- " --conf" , s " ${lineFeedFromCommandLine._1}= ${lineFeedFromCommandLine._2}" ,
1714
- " --conf" , " spark.master=yarn" ,
1715
- " --properties-file" , propsFile.getPath,
1716
- " thejar.jar" )
1741
+ val appArgs = new SparkSubmitArguments (clArgs)
1742
+ val (_, _, conf, _) = submit.prepareSubmitEnvironment(appArgs)
1717
1743
1718
- val appArgs = new SparkSubmitArguments (clArgs)
1719
- val (_, _, conf, _) = submit.prepareSubmitEnvironment(appArgs)
1744
+ Seq (
1745
+ lineFeedFromCommandLine,
1746
+ leadingDelimKeyFromFile,
1747
+ trailingDelimKeyFromFile,
1748
+ infixDelimFromFile
1749
+ ).foreach { case (k, v) =>
1750
+ conf.get(k) should be (v)
1751
+ }
1720
1752
1721
- Seq (
1722
- lineFeedFromCommandLine,
1723
- leadingDelimKeyFromFile,
1724
- trailingDelimKeyFromFile,
1725
- infixDelimFromFile
1726
- ).foreach { case (k, v) =>
1727
- conf.get(k) should be (v)
1753
+ conf.get(nonDelimSpaceFromFile._1) should be (" blah" )
1728
1754
}
1729
-
1730
- conf.get(nonDelimSpaceFromFile._1) should be (" blah" )
1731
1755
}
1732
1756
1733
1757
test(" get a Spark configuration from arguments" ) {
0 commit comments