Skip to content

[SPARK-51653][CONNECT][TESTS] Migrate the tests related to RemoteSparkSession from the connect-client-jvm module to connect-client-integration-tests #50463

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
if [[ "$INCLUDED_TAGS" != "" ]]; then
./build/mvn $MAVEN_CLI_OPTS -pl "$TEST_MODULES" -Pyarn -Pkubernetes -Pvolcano -Phive -Phive-thriftserver -Phadoop-cloud -Pjvm-profiler -Pspark-ganglia-lgpl -Pkinesis-asl -Djava.version=${JAVA_VERSION/-ea} -Dtest.include.tags="$INCLUDED_TAGS" test -fae
elif [[ "$MODULES_TO_TEST" == "connect" ]]; then
./build/mvn $MAVEN_CLI_OPTS -Dtest.exclude.tags="$EXCLUDED_TAGS" -Djava.version=${JAVA_VERSION/-ea} -pl sql/connect/client/jvm,sql/connect/common,sql/connect/server test -fae
./build/mvn $MAVEN_CLI_OPTS -Dtest.exclude.tags="$EXCLUDED_TAGS" -Djava.version=${JAVA_VERSION/-ea} -pl sql/connect/client/jvm,sql/connect/client/integration-tests,sql/connect/common,sql/connect/server package test -fae
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, it is necessary to use package test. If only test is specified, then client-integration-tests will use the client-jvm's classes directory instead of a jar file as the build classpath, which will result in a failure of testCompile.

elif [[ "$EXCLUDED_TAGS" != "" ]]; then
./build/mvn $MAVEN_CLI_OPTS -pl "$TEST_MODULES" -Pyarn -Pkubernetes -Pvolcano -Phive -Phive-thriftserver -Phadoop-cloud -Pjvm-profiler -Pspark-ganglia-lgpl -Pkinesis-asl -Djava.version=${JAVA_VERSION/-ea} -Dtest.exclude.tags="$EXCLUDED_TAGS" test -fae
elif [[ "$MODULES_TO_TEST" == *"sql#hive-thriftserver"* ]]; then
Expand Down
14 changes: 0 additions & 14 deletions assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,6 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!-- zip pyspark archives to run python application on yarn mode -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
3 changes: 2 additions & 1 deletion dev/lint-scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ ERRORS=$(./build/mvn \
-pl sql/connect/common \
-pl sql/connect/server \
-pl sql/connect/client/jvm \
-pl sql/connect/client/integration-tests \
2>&1 | grep -e "Unformatted files found" \
)

if test ! -z "$ERRORS"; then
echo -e "The scalafmt check failed on sql/connect or sql/connect at following occurrences:\n\n$ERRORS\n"
echo "Before submitting your change, please make sure to format your code using the following command:"
echo "./build/mvn scalafmt:format -Dscalafmt.skip=false -Dscalafmt.validateOnly=false -Dscalafmt.changedOnly=false -pl sql/api -pl sql/connect/common -pl sql/connect/server -pl sql/connect/client/jvm"
echo "./build/mvn scalafmt:format -Dscalafmt.skip=false -Dscalafmt.validateOnly=false -Dscalafmt.changedOnly=false -pl sql/api -pl sql/connect/common -pl sql/connect/server -pl sql/connect/client/jvm -pl sql/connect/client/integration-tests"
exit 1
else
echo -e "Scalafmt checks passed."
Expand Down
1 change: 1 addition & 0 deletions dev/sparktestsupport/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def __hash__(self):
sbt_test_goals=[
"connect/test",
"connect-client-jvm/test",
"connect-client-integration-tests/test",
],
)

Expand Down
4 changes: 2 additions & 2 deletions dev/test-jars.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ core/src/test/resources/TestHelloV3_2.13.jar
core/src/test/resources/TestUDTF.jar
data/artifact-tests/junitLargeJar.jar
data/artifact-tests/smallJar.jar
sql/connect/client/jvm/src/test/resources/TestHelloV2_2.13.jar
sql/connect/client/jvm/src/test/resources/udf2.13.jar
sql/connect/client/integration-tests/src/test/resources/TestHelloV2_2.13.jar
sql/connect/client/integration-tests/src/test/resources/udf2.13.jar
sql/connect/common/src/test/resources/artifact-tests/junitLargeJar.jar
sql/connect/common/src/test/resources/artifact-tests/smallJar.jar
sql/core/src/test/resources/SPARK-33084.jar
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<module>sql/connect/server</module>
<module>sql/connect/common</module>
<module>sql/connect/client/jvm</module>
<module>sql/connect/client/integration-tests</module>
<module>assembly</module>
<module>examples</module>
<module>repl</module>
Expand Down
62 changes: 44 additions & 18 deletions project/SparkBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ object BuildCommons {
val streamingProjects@Seq(streaming, streamingKafka010) =
Seq("streaming", "streaming-kafka-0-10").map(ProjectRef(buildLocation, _))

val connectProjects@Seq(connectCommon, connect, connectClient, connectShims) =
Seq("connect-common", "connect", "connect-client-jvm", "connect-shims")
.map(ProjectRef(buildLocation, _))
val connectProjects@Seq(connectCommon, connect, connectClient, connectClientIT, connectShims) =
Seq("connect-common", "connect", "connect-client-jvm", "connect-client-integration-tests",
"connect-shims").map(ProjectRef(buildLocation, _))

val allProjects@Seq(
core, graphx, mllib, mllibLocal, repl, networkCommon, networkShuffle, launcher, unsafe, tags, sketch, kvstore,
Expand Down Expand Up @@ -369,7 +369,7 @@ object SparkBuild extends PomBuild {
Seq(
spark, hive, hiveThriftServer, repl, networkCommon, networkShuffle, networkYarn,
unsafe, tags, tokenProviderKafka010, sqlKafka010, connectCommon, connect, connectClient,
variant, connectShims, profiler
variant, connectShims, connectClientIT, profiler
).contains(x)
}

Expand Down Expand Up @@ -417,6 +417,7 @@ object SparkBuild extends PomBuild {
enable(SparkConnectCommon.settings)(connectCommon)
enable(SparkConnect.settings)(connect)
enable(SparkConnectClient.settings)(connectClient)
enable(SparkConnectClientIT.settings)(connectClientIT)

/* Protobuf settings */
enable(SparkProtobuf.settings)(protobuf)
Expand Down Expand Up @@ -804,7 +805,6 @@ object SparkConnect {

object SparkConnectClient {
import BuildCommons.protoVersion
val buildTestDeps = TaskKey[Unit]("buildTestDeps", "Build needed dependencies for test.")

lazy val settings = Seq(
// For some reason the resolution from the imported Maven build does not work for some
Expand All @@ -828,18 +828,6 @@ object SparkConnectClient {
)
},

buildTestDeps := {
(LocalProject("assembly") / Compile / Keys.`package`).value
(LocalProject("catalyst") / Test / Keys.`package`).value
},

// SPARK-42538: Make sure the `${SPARK_HOME}/assembly/target/scala-$SPARK_SCALA_VERSION/jars` is available for testing.
// At the same time, the build of `connect`, `connect-client-jvm` and `sql` will be triggered by `assembly` build,
// so no additional configuration is required.
test := ((Test / test) dependsOn (buildTestDeps)).value,

testOnly := ((Test / testOnly) dependsOn (buildTestDeps)).evaluated,

(assembly / test) := { },

(assembly / logLevel) := Level.Info,
Expand All @@ -859,11 +847,11 @@ object SparkConnectClient {
},

(assembly / assemblyShadeRules) := Seq(
ShadeRule.rename("com.google.protobuf.**" -> "org.sparkproject.com.google.protobuf.@1").inAll,
ShadeRule.rename("io.grpc.**" -> "org.sparkproject.connect.client.io.grpc.@1").inAll,
ShadeRule.rename("com.google.**" -> "org.sparkproject.connect.client.com.google.@1").inAll,
ShadeRule.rename("io.netty.**" -> "org.sparkproject.connect.client.io.netty.@1").inAll,
ShadeRule.rename("org.checkerframework.**" -> "org.sparkproject.connect.client.org.checkerframework.@1").inAll,
ShadeRule.rename("javax.annotation.**" -> "org.sparkproject.connect.client.javax.annotation.@1").inAll,
ShadeRule.rename("io.perfmark.**" -> "org.sparkproject.connect.client.io.perfmark.@1").inAll,
ShadeRule.rename("org.codehaus.**" -> "org.sparkproject.connect.client.org.codehaus.@1").inAll,
ShadeRule.rename("android.annotation.**" -> "org.sparkproject.connect.client.android.annotation.@1").inAll
Expand All @@ -878,6 +866,44 @@ object SparkConnectClient {
)
}

object SparkConnectClientIT {
val buildTestDeps = TaskKey[Unit]("buildTestDeps", "Build needed dependencies for test.")

def filterSparkDependencies(
files: Seq[Attributed[File]],
scalaBinaryVer: String): Seq[Attributed[File]] = {
val packageNames = Seq(
"spark-connect-client-jvm",
"spark-connect-common",
"spark-connect",
"spark-sql"
).map(name => s"${name}_$scalaBinaryVer")

files.filterNot(f => packageNames.exists(name => f.toString.contains(name)))
}

lazy val settings = Seq(
buildTestDeps := {
(LocalProject("connect-client-jvm") / assembly).value
(LocalProject("catalyst") / Test / Keys.`package`).value
},

(Test / compile) := ((Test / compile) dependsOn buildTestDeps).value,
test := ((Test / test) dependsOn (buildTestDeps)).value,
testOnly := ((Test / testOnly) dependsOn (buildTestDeps)).evaluated,

(Test / dependencyClasspath) :=
filterSparkDependencies((Test / dependencyClasspath).value, scalaBinaryVersion.value),
(Test / fullClasspath) :=
filterSparkDependencies((Test / fullClasspath).value, scalaBinaryVersion.value),
(Test / unmanagedJars) += {
val jarName = s"spark-connect-client-jvm-assembly-${version.value}.jar"
val basePath = s"${baseDirectory.value}/../jvm/target/scala-${scalaBinaryVersion.value}"
Attributed.blank(file(s"$basePath/$jarName"))
}
)
}

object SparkProtobuf {
import BuildCommons.protoVersion

Expand Down
117 changes: 117 additions & 0 deletions sql/connect/client/integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.spark</groupId>
<artifactId>spark-parent_2.13</artifactId>
<version>4.1.0-SNAPSHOT</version>
<relativePath>../../../../pom.xml</relativePath>
</parent>

<artifactId>spark-connect-client-integration-tests_2.13</artifactId>
<packaging>jar</packaging>
<name>Spark Project Connect Client Integration Test</name>
<url>https://spark.apache.org/</url>
<properties>
<sbt.project.name>connect-client-integration-tests</sbt.project.name>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-connect-client-jvm_${scala.binary.version}</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.spark</groupId>
<artifactId>spark-connect-common_${scala.binary.version}</artifactId>
</exclusion>
</exclusions>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql-api_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql-api_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-tags_${scala.binary.version}</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-common-utils_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-assembly_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.binary.version}</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.spark</groupId>
<artifactId>spark-connect_${scala.binary.version}</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.spark</groupId>
<artifactId>spark-connect-common_${scala.binary.version}</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.lihaoyi</groupId>
<artifactId>ammonite_${scala.version}</artifactId>
<version>${ammonite.version}</version>
<exclusions>
<!--
Exclude fine-grained jline jars and in favor the bundled jline jar pulled by scala-compiler.
-->
<exclusion>
<groupId>org.jline</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory>
<testOutputDirectory>target/scala-${scala.binary.version}/test-classes</testOutputDirectory>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.apache.spark.sql.functions.*;
import static org.apache.spark.sql.RowFactory.create;
import org.apache.spark.api.java.function.MapFunction;
import org.apache.spark.sql.connect.test.IntegrationTestUtils;
import org.apache.spark.sql.connect.test.SparkConnectServerUtils;
import org.apache.spark.sql.types.StructType;

Expand All @@ -40,18 +39,14 @@ public class JavaEncoderSuite implements Serializable {

@BeforeAll
public static void setup() {
Assumptions.assumeTrue(IntegrationTestUtils.isAssemblyJarsDirExists(),
"Skipping all tests because assembly jars directory does not exist.");
spark = SparkConnectServerUtils.createSparkSession();
}

@AfterAll
public static void tearDown() {
if (spark != null) {
spark.stop();
spark = null;
SparkConnectServerUtils.stop();
}
spark.stop();
spark = null;
SparkConnectServerUtils.stop();
}

private static BigDecimal bigDec(long unscaled, int scale) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Set everything to be logged to the file target/unit-tests.log
rootLogger.level = info
rootLogger.appenderRef.file.ref = ${sys:test.appender:-File}

appender.file.type = File
appender.file.name = File
appender.file.fileName = target/unit-tests.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = %d{yy/MM/dd HH:mm:ss.SSS} %t %p %c{1}: %m%n%ex

# Tests that launch java subprocesses can set the "test.appender" system property to
# "console" to avoid having the child process's logs overwrite the unit test's
# log file.
appender.console.type = Console
appender.console.name = console
appender.console.target = SYSTEM_ERR
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{HH:mm:ss.SSS} %p %c: %maxLen{%m}{512}%n%ex{8}%n

# Ignore messages below warning level from Jetty, because it's a bit verbose
logger.jetty.name = org.sparkproject.jetty
logger.jetty.level = warn
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ class ReplE2ESuite extends ConnectFunSuite with RemoteSparkSession with BeforeAn
// scalastyle:off classforname line.size.limit
val sparkHome = IntegrationTestUtils.sparkHome
val testJar = Paths
.get(s"$sparkHome/sql/connect/client/jvm/src/test/resources/TestHelloV2_$scalaVersion.jar")
.get(
s"$sparkHome/sql/connect/client/integration-tests/src/test/resources/TestHelloV2_$scalaVersion.jar")
.toFile

assume(testJar.exists(), "Missing TestHelloV2 jar!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.nio.file.{Files, Paths}

import scala.util.Properties

import com.google.protobuf.ByteString
import org.sparkproject.com.google.protobuf.ByteString

import org.apache.spark.connect.proto
import org.apache.spark.sql.connect.common.ProtoDataTypes
Expand Down
Loading