Skip to content

Commit ee11be2

Browse files
steveloughransrowen
authored andcommitted
SPARK-6433 hive tests to import spark-sql test JAR for QueryTest access
1. Test JARs are built & published 1. log4j.resources is explicitly excluded. Without this, downstream test run logging depends on the order the JARs are listed/loaded 1. sql/hive pulls in spark-sql &...spark-catalyst for its test runs 1. The copied in test classes were rm'd, and a test edited to remove its now duplicate assert method 1. Spark streaming is now build with the same plugin/phase as the rest, but its shade plugin declaration is kept in (so different from the rest of the test plugins). Due to (#2), this means the test JAR no longer includes its log4j file. Outstanding issues: * should the JARs be shaded? `spark-streaming-test.jar` does, but given these are test jars for developers only, especially in the same spark source tree, it's hard to justify. * `maven-jar-plugin` v 2.6 was explicitly selected; without this the apache-1.4 parent template JAR version (2.4) chosen. * Are there any other resources to exclude? Author: Steve Loughran <stevel@hortonworks.com> Closes apache#5119 from steveloughran/stevel/patches/SPARK-6433-test-jars and squashes the following commits: 81ceb01 [Steve Loughran] SPARK-6433 add a clearer comment explaining what the plugin is doing & why a6dca33 [Steve Loughran] SPARK-6433 : pull configuration section form archive plugin c2b5f89 [Steve Loughran] SPARK-6433 omit "jar" goal from jar plugin fdac51b [Steve Loughran] SPARK-6433 -002; indentation & delegate plugin version to parent 650f442 [Steve Loughran] SPARK-6433 patch 001: test JARs are built; sql/hive pulls in spark-sql & spark-catalyst for its test runs
1 parent d36c5fc commit ee11be2

File tree

6 files changed

+34
-240
lines changed

6 files changed

+34
-240
lines changed

pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@
12651265
<id>create-source-jar</id>
12661266
<goals>
12671267
<goal>jar-no-fork</goal>
1268+
<goal>test-jar-no-fork</goal>
12681269
</goals>
12691270
</execution>
12701271
</executions>
@@ -1473,6 +1474,25 @@
14731474
<groupId>org.scalatest</groupId>
14741475
<artifactId>scalatest-maven-plugin</artifactId>
14751476
</plugin>
1477+
<!-- Build test-jar's for all projects, since some projects depend on tests from others -->
1478+
<plugin>
1479+
<groupId>org.apache.maven.plugins</groupId>
1480+
<artifactId>maven-jar-plugin</artifactId>
1481+
<executions>
1482+
<execution>
1483+
<id>prepare-test-jar</id>
1484+
<phase>prepare-package</phase>
1485+
<goals>
1486+
<goal>test-jar</goal>
1487+
</goals>
1488+
<configuration>
1489+
<excludes>
1490+
<exclude>log4j.properties</exclude>
1491+
</excludes>
1492+
</configuration>
1493+
</execution>
1494+
</executions>
1495+
</plugin>
14761496
</plugins>
14771497
</build>
14781498

sql/hive/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@
8989
<artifactId>junit</artifactId>
9090
<scope>test</scope>
9191
</dependency>
92+
<dependency>
93+
<groupId>org.apache.spark</groupId>
94+
<artifactId>spark-sql_${scala.binary.version}</artifactId>
95+
<type>test-jar</type>
96+
<version>${project.version}</version>
97+
<scope>test</scope>
98+
</dependency>
99+
<dependency>
100+
<groupId>org.apache.spark</groupId>
101+
<artifactId>spark-catalyst_${scala.binary.version}</artifactId>
102+
<type>test-jar</type>
103+
<version>${project.version}</version>
104+
<scope>test</scope>
105+
</dependency>
92106
</dependencies>
93107
<profiles>
94108
<profile>

sql/hive/src/test/scala/org/apache/spark/sql/QueryTest.scala

Lines changed: 0 additions & 140 deletions
This file was deleted.

sql/hive/src/test/scala/org/apache/spark/sql/catalyst/plans/PlanTest.scala

Lines changed: 0 additions & 57 deletions
This file was deleted.

sql/hive/src/test/scala/org/apache/spark/sql/hive/CachedTableSuite.scala

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@ import org.apache.spark.sql.{AnalysisException, DataFrame, QueryTest}
2424
import org.apache.spark.storage.RDDBlockId
2525

2626
class CachedTableSuite extends QueryTest {
27-
/**
28-
* Throws a test failed exception when the number of cached tables differs from the expected
29-
* number.
30-
*/
31-
def assertCached(query: DataFrame, numCachedTables: Int = 1): Unit = {
32-
val planWithCaching = query.queryExecution.withCachedData
33-
val cachedData = planWithCaching collect {
34-
case cached: InMemoryRelation => cached
35-
}
36-
37-
assert(
38-
cachedData.size == numCachedTables,
39-
s"Expected query to contain $numCachedTables, but it actually had ${cachedData.size}\n" +
40-
planWithCaching)
41-
}
4227

4328
def rddIdOf(tableName: String): Int = {
4429
val executedPlan = table(tableName).queryExecution.executedPlan

streaming/pom.xml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,6 @@
9797
<outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory>
9898
<testOutputDirectory>target/scala-${scala.binary.version}/test-classes</testOutputDirectory>
9999
<plugins>
100-
<!--
101-
This plugin forces the generation of jar containing streaming test classes,
102-
so that the tests classes of external modules can use them. The two execution profiles
103-
are necessary - first one for 'mvn package', second one for 'mvn test-compile'. Ideally,
104-
'mvn compile' should not compile test classes and therefore should not need this.
105-
However, an open Maven bug (http://jira.codehaus.org/browse/MNG-3559)
106-
causes the compilation to fail if streaming test-jar is not generated. Hence, the
107-
second execution profile for 'mvn test-compile'.
108-
-->
109-
<plugin>
110-
<groupId>org.apache.maven.plugins</groupId>
111-
<artifactId>maven-jar-plugin</artifactId>
112-
<executions>
113-
<execution>
114-
<goals>
115-
<goal>test-jar</goal>
116-
</goals>
117-
</execution>
118-
<execution>
119-
<id>test-jar-on-test-compile</id>
120-
<phase>test-compile</phase>
121-
<goals>
122-
<goal>test-jar</goal>
123-
</goals>
124-
</execution>
125-
</executions>
126-
</plugin>
127-
128100
<plugin>
129101
<groupId>org.apache.maven.plugins</groupId>
130102
<artifactId>maven-shade-plugin</artifactId>

0 commit comments

Comments
 (0)