test(pipeline): add SparkTest trait with example#333
Closed
em3s wants to merge 3 commits into
Closed
Conversation
Introduce a minimal `SparkTest` trait that provides an implicit `local[2]` SparkSession for unit tests, plus `SparkPiDemoTest` as a usage example exercising `SparkPiDemo.estimatePi`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Provide a minimal `def main` example that builds the SparkSession directly, complementing the `SparkPiDemo`/`AbstractPipelineApplication` path for ad-hoc IDE exploration. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
`--add-exports` is a JDK 9+ option. On JDK 8 the JVM treats it as unknown and exits immediately, breaking IntelliJ's "Run main()" flow that routes through a Gradle JavaExec task. Gate the flag on `JavaVersion.current().isJava9Compatible` so JDK 8 users can run mains via Gradle while preserving the JDK 17 workaround. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
|
Closing. #314 includes this scope. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a minimal Spark test harness so that pipeline unit tests can mix in an implicit
SparkSessionwithout each test rebuilding one, plus standalone examples covering both JUnit-driven andmain-driven flows. Also unbreaks running mains via Gradle on JDK 8.Changes
SparkTesttrait providing an implicitlocal[2]SparkSessionshared across mixers via Spark'sgetOrCreatesemantics.spark.ui.enabled=falseandspark.driver.bindAddress=127.0.0.1keep test runs quiet and deterministic on dev/CI.SparkPiDemoTestas a JUnit usage example exercisingSparkPiDemo.estimatePiwithassertTrue(CI-verifiable).SparkPiMainas a standalonedef mainexample that builds theSparkSessiondirectly, for ad-hoc IDE exploration where no assertions are needed.--add-exports=java.base/sun.nio.ch=ALL-UNNAMEDJavaExecjvmArg behindJavaVersion.current().isJava9Compatible. On JDK 8 the JVM treats the flag as unknown and exits immediately, which broke IntelliJ's "Run main()" flow (it routes through a GradleJavaExectask). JDK 17 behaviour is preserved.How to Test
Run the JUnit example:
Expected: build succeeds, test passes,
SparkContextshuts down cleanly.Run the standalone
main:SparkPiMain.main— printsPi is roughly ~3.14.AI Assistance