Skip to content
25 changes: 18 additions & 7 deletions python/pyspark/streaming/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,7 @@ def search_kinesis_asl_assembly_jar():
os.path.join(kinesis_asl_assembly_dir,
"target/scala-*/spark-streaming-kinesis-asl-assembly-*.jar"))
if not jars:
raise Exception(
("Failed to find Spark Streaming Kinesis ASL assembly jar in %s. " %
kinesis_asl_assembly_dir) + "You need to build Spark with "
"'build/sbt -Pkinesis-asl assembly/assembly streaming-kinesis-asl-assembly/assembly' "
"or 'build/mvn -Pkinesis-asl package' before running this test")
return None
elif len(jars) > 1:
raise Exception(("Found multiple Spark Streaming Kinesis ASL assembly JARs in %s; please "
"remove all but one") % kinesis_asl_assembly_dir)
Expand All @@ -1013,7 +1009,22 @@ def search_kinesis_asl_assembly_jar():
kafka_assembly_jar = search_kafka_assembly_jar()
flume_assembly_jar = search_flume_assembly_jar()
kinesis_asl_assembly_jar = search_kinesis_asl_assembly_jar()
jars = "%s,%s,%s" % (kafka_assembly_jar, flume_assembly_jar, kinesis_asl_assembly_jar)
if kinesis_asl_assembly_jar is None:
kinesis_jar_present = False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If ENABLE_KINESIS_TESTS is set to 1 but kinesis_jar_present is false, I think we should fail the test because it should be a bug that the assembly jar cannot be generated correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is a good point. If that flag is set, then the use definitely wants to run ALL the kinesis tests. In that case its best to fail.

jars = "%s,%s" % (kafka_assembly_jar, flume_assembly_jar)
else:
kinesis_jar_present = True
jars = "%s,%s,%s" % (kafka_assembly_jar, flume_assembly_jar, kinesis_asl_assembly_jar)

print kinesis_jar_present, jars
os.environ["PYSPARK_SUBMIT_ARGS"] = "--jars %s pyspark-shell" % jars
unittest.main()
testcases = [BasicOperationTests, WindowFunctionTests, StreamingContextTests, \
CheckpointTests, KafkaStreamTests, FlumeStreamTests, FlumePollingStreamTests]
if kinesis_jar_present is True:
testcases.append(KinesisStreamTests)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: extra empty line

sys.stderr.write("Running tests %s\n" % (str(testcases)))
for testcase in testcases:
print "[", testcase, "]"
tests = unittest.TestLoader().loadTestsFromTestCase(testcase)
unittest.TextTestRunner(verbosity=2).run(tests)