Skip to content

test(pipeline): add SparkTest trait with example#333

Closed
em3s wants to merge 3 commits into
mainfrom
test/add-spark-test-harness
Closed

test(pipeline): add SparkTest trait with example#333
em3s wants to merge 3 commits into
mainfrom
test/add-spark-test-harness

Conversation

@em3s
Copy link
Copy Markdown
Contributor

@em3s em3s commented May 15, 2026

Summary

Add a minimal Spark test harness so that pipeline unit tests can mix in an implicit SparkSession without each test rebuilding one, plus standalone examples covering both JUnit-driven and main-driven flows. Also unbreaks running mains via Gradle on JDK 8.

Changes

  • Add SparkTest trait providing an implicit local[2] SparkSession shared across mixers via Spark's getOrCreate semantics. spark.ui.enabled=false and spark.driver.bindAddress=127.0.0.1 keep test runs quiet and deterministic on dev/CI.
  • Add SparkPiDemoTest as a JUnit usage example exercising SparkPiDemo.estimatePi with assertTrue (CI-verifiable).
  • Add SparkPiMain as a standalone def main example that builds the SparkSession directly, for ad-hoc IDE exploration where no assertions are needed.
  • Guard the --add-exports=java.base/sun.nio.ch=ALL-UNNAMED JavaExec jvmArg behind JavaVersion.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 Gradle JavaExec task). JDK 17 behaviour is preserved.

How to Test

Run the JUnit example:

./gradlew :pipeline:test --tests "com.kakao.actionbase.pipeline.app.SparkPiDemoTest"

Expected: build succeeds, test passes, SparkContext shuts down cleanly.

Run the standalone main:

  • From an IDE: Run SparkPiMain.main — prints Pi is roughly ~3.14.
  • Verified on both JDK 8 (zulu-8) and JDK 17 (zulu-17).

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (claude-opus-4-7)

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>
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 15, 2026
em3s and others added 2 commits May 15, 2026 11:14
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>
@em3s
Copy link
Copy Markdown
Contributor Author

em3s commented May 15, 2026

Closing.

#314 includes this scope.

@em3s em3s closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant