Skip to content

Commit 2c10193

Browse files
committed
Remove assembly in tests.
1 parent 310981d commit 2c10193

File tree

3 files changed

+56
-22
lines changed

3 files changed

+56
-22
lines changed

dev/run-tests.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def get_hadoop_profiles(hadoop_version):
323323
def build_spark_maven(hadoop_version):
324324
# Enable all of the profiles for the build:
325325
build_profiles = get_hadoop_profiles(hadoop_version) + modules.root.build_profile_flags
326-
mvn_goals = ["clean", "package", "-DskipTests"]
326+
mvn_goals = ["clean", "package", "-DskipTests", "-pl", "!assembly"]
327327
profiles_and_goals = build_profiles + mvn_goals
328328

329329
print("[info] Building Spark (w/Hive 1.2.1) using Maven with these arguments: ",
@@ -349,16 +349,6 @@ def build_spark_sbt(hadoop_version):
349349
exec_sbt(profiles_and_goals)
350350

351351

352-
def build_spark_assembly_sbt(hadoop_version):
353-
# Enable all of the profiles for the build:
354-
build_profiles = get_hadoop_profiles(hadoop_version) + modules.root.build_profile_flags
355-
sbt_goals = ["assembly/assembly"]
356-
profiles_and_goals = build_profiles + sbt_goals
357-
print("[info] Building Spark assembly (w/Hive 1.2.1) using SBT with these arguments: ",
358-
" ".join(profiles_and_goals))
359-
exec_sbt(profiles_and_goals)
360-
361-
362352
def build_apache_spark(build_tool, hadoop_version):
363353
"""Will build Spark against Hive v1.2.1 given the passed in build tool (either `sbt` or
364354
`maven`). Defaults to using `sbt`."""
@@ -574,9 +564,6 @@ def main():
574564
if build_tool == "sbt":
575565
# Note: compatibility tests only supported in sbt for now
576566
detect_binary_inop_with_mima()
577-
# Since we did not build assembly/assembly before running dev/mima, we need to
578-
# do it here because the tests still rely on it; see SPARK-13294 for details.
579-
build_spark_assembly_sbt(hadoop_version)
580567

581568
# run the test suites
582569
run_scala_tests(build_tool, hadoop_version, test_modules, excluded_tags)

launcher/src/main/java/org/apache/spark/launcher/AbstractCommandBuilder.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,38 @@ List<String> buildClassPath(String appClassPath) throws IOException {
144144
boolean isTesting = "1".equals(getenv("SPARK_TESTING"));
145145
if (prependClasses || isTesting) {
146146
String scala = getScalaVersion();
147-
List<String> projects = Arrays.asList("core", "repl", "mllib", "graphx",
148-
"streaming", "tools", "sql/catalyst", "sql/core", "sql/hive", "sql/hive-thriftserver",
149-
"yarn", "launcher",
150-
"common/network-common", "common/network-shuffle", "common/network-yarn");
147+
// All projects except assemblies:
148+
List<String> projects = Arrays.asList(
149+
"common/network-common",
150+
"common/network-shuffle",
151+
"common/network-yarn",
152+
"common/sketch",
153+
"common/tags",
154+
"common/unsafe",
155+
"core",
156+
"examples",
157+
"external/akka",
158+
"external/docker-integration-tests",
159+
"external/flume",
160+
"external/flume-sink",
161+
"external/kafka",
162+
"external/kinesis-asl",
163+
"external/mqtt",
164+
"external/spark-ganglia-lgpl",
165+
"external/twitter",
166+
"external/zeromq",
167+
"graphx",
168+
"launcher",
169+
"mllib",
170+
"repl",
171+
"sql/catalyst",
172+
"sql/core",
173+
"sql/hive",
174+
"sql/hive-thriftserver",
175+
"streaming",
176+
"tools",
177+
"yarn"
178+
);
151179
if (prependClasses) {
152180
if (!isTesting) {
153181
System.err.println(

python/run-tests.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,27 @@ def print_red(text):
5454
LOGGER = logging.getLogger()
5555

5656

57-
def run_individual_python_test(test_name, pyspark_python):
57+
def get_spark_dist_classpath():
58+
original_working_dir = os.getcwd()
59+
os.chdir(SPARK_HOME)
60+
cp = subprocess_check_output(
61+
["./build/sbt", "export assembly/managedClasspath"], universal_newlines=True)
62+
cp = cp.strip().split("\n")[-1]
63+
os.chdir(original_working_dir)
64+
return cp
65+
66+
67+
def run_individual_python_test(test_name, pyspark_python, spark_dist_classpath):
5868
env = dict(os.environ)
59-
env.update({'SPARK_TESTING': '1', 'PYSPARK_PYTHON': which(pyspark_python),
60-
'PYSPARK_DRIVER_PYTHON': which(pyspark_python)})
69+
env.update({
70+
# Setting SPARK_DIST_CLASSPATH is a simple way to make sure that any child processes
71+
# launched by the tests have access to the correct test-time classpath.
72+
'SPARK_DIST_CLASSPATH': spark_dist_classpath,
73+
'SPARK_TESTING': '1',
74+
'SPARK_PREPEND_CLASSES': '1',
75+
'PYSPARK_PYTHON': which(pyspark_python),
76+
'PYSPARK_DRIVER_PYTHON': which(pyspark_python),
77+
})
6178
LOGGER.debug("Starting test(%s): %s", pyspark_python, test_name)
6279
start_time = time.time()
6380
try:
@@ -175,14 +192,16 @@ def main():
175192
priority = 100
176193
task_queue.put((priority, (python_exec, test_goal)))
177194

195+
spark_dist_classpath = get_spark_dist_classpath()
196+
178197
def process_queue(task_queue):
179198
while True:
180199
try:
181200
(priority, (python_exec, test_goal)) = task_queue.get_nowait()
182201
except Queue.Empty:
183202
break
184203
try:
185-
run_individual_python_test(test_goal, python_exec)
204+
run_individual_python_test(test_goal, python_exec, spark_dist_classpath)
186205
finally:
187206
task_queue.task_done()
188207

0 commit comments

Comments
 (0)