Commit 38a1958
committed
[SPARK-51603][CONNECT][TESTS] Auto ignore tests that require starting
### What changes were proposed in this pull request?
After the merge of SPARK-48936 (#47402), the Maven module compilation order for the `connect-client-jvm` module was moved up to occur before the `assembly` build.
Since a portion of the tests in `connect-client-jvm` heavily rely on `SparkConnectServer` and related dependencies being collected into `assembly/target/scala-2.13/jars/`, it is necessary to build `assembly` before running `mvn test` for `connect-client-jvm`.
For example:
```
build/mvn clean install -DskipTests -Phive
build/mvn test -pl sql/connect/client/jvm
```
This sequence will result in successful tests.
However, if a full test suite is executed directly, such as:
```
build/mvn clean install -Phive
```
Failures similar to the following may occur:
```
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.044 s <<< FAILURE! -- in org.apache.spark.sql.JavaEncoderSuite
[ERROR] org.apache.spark.sql.JavaEncoderSuite -- Time elapsed: 0.044 s <<< FAILURE!
java.lang.AssertionError: assertion failed: Fail to locate the target folder: '/Users/yangjie01/SourceCode/git/spark-maven/sql/connect/server/target'. SPARK_HOME='/Users/yangjie01/SourceCode/git/spark-maven'. Make sure the spark project jars has been built (e.g. using build/sbt package)and the env variable `SPARK_HOME` is set correctly.
at scala.Predef$.assert(Predef.scala:279)
at org.apache.spark.sql.connect.test.IntegrationTestUtils$.tryFindJar(IntegrationTestUtils.scala:138)
at org.apache.spark.sql.connect.test.IntegrationTestUtils$.findJar(IntegrationTestUtils.scala:116)
at org.apache.spark.sql.connect.test.SparkConnectServerUtils$.sparkConnect$lzycompute(RemoteSparkSession.scala:65)
at org.apache.spark.sql.connect.test.SparkConnectServerUtils$.sparkConnect(RemoteSparkSession.scala:62)
at org.apache.spark.sql.connect.test.SparkConnectServerUtils$.start(RemoteSparkSession.scala:135)
at org.apache.spark.sql.connect.test.SparkConnectServerUtils$.createSparkSession(RemoteSparkSession.scala:181)
at org.apache.spark.sql.connect.test.SparkConnectServerUtils.createSparkSession(RemoteSparkSession.scala)
at org.apache.spark.sql.JavaEncoderSuite.setup(JavaEncoderSuite.java:42)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Suppressed: java.lang.NullPointerException: Cannot invoke "org.apache.spark.sql.SparkSession.stop()" because "org.apache.spark.sql.JavaEncoderSuite.spark" is null
at org.apache.spark.sql.JavaEncoderSuite.tearDown(JavaEncoderSuite.java:47)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092)
... 1 more
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] JavaEncoderSuite.setup:42 assertion failed: Fail to locate the target folder: '/Users/yangjie01/SourceCode/git/spark-maven/sql/connect/server/target'. SPARK_HOME='/Users/yangjie01/SourceCode/git/spark-maven'. Make sure the spark project jars has been built (e.g. using build/sbt package)and the env variable `SPARK_HOME` is set correctly.
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
```
To ensure that the above failing scenario can be tested successfully, the current pr makes the following changes:
1. Added `isAssemblyJarsDirExists` in `IntegrationTestUtils` to check if the directory `assembly/target/scala-2.13/jars/` exists.
2. Overrode the `test` function in the `trait RemoteSparkSession` from `AnyFunSuite` to ignore corresponding tests when `isAssemblyJarsDirExists` is `false`. Additionally, `RemoteSparkSession` will only try to start `SparkConnectServer` when `isAssemblyJarsDirExists` is `true`.
3. Made similar changes in `JavaEncoderSuite` as in step 2
### Why are the changes needed?
Make the Maven testing process smoother.
### Does this PR introduce _any_ user-facing change?
No, just for maven test.
### How was this patch tested?
- Pass Git Hub Actions
- Tested the `connect-client-jvm` module using Maven without `assembly` dir , and the results met expectations.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #50396 from LuciferYang/SPARK-51603.
Lead-authored-by: yangjie01 <yangjie01@baidu.com>
Co-authored-by: YangJie <yangjie01@baidu.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>SparkConnectServer when the directory assembly/target/scala-2.13/jars/ not exist1 parent 0fdff1b commit 38a1958
File tree
3 files changed
+32
-7
lines changed- sql/connect/client/jvm/src/test
- java/org/apache/spark/sql
- scala/org/apache/spark/sql/connect/test
3 files changed
+32
-7
lines changedLines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/test/IntegrationTestUtils.scala
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
208 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
209 | 213 | | |
210 | 214 | | |
211 | 215 | | |
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
215 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
216 | 222 | | |
217 | 223 | | |
218 | 224 | | |
| |||
224 | 230 | | |
225 | 231 | | |
226 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
227 | 242 | | |
0 commit comments