Tests are implemented in the tests
sbt submodule. They simulate the submission of a Spark job as described in the README. Therefore, before running the tests you need to build the migrator fat-jar and to set up a stack with a Spark cluster and databases to read data from and to write to.
-
Build the migrator fat-jar and its dependencies
./build.sh
-
Set up the testing stack with Docker
docker compose -f docker-compose-tests.yml up
-
Run the tests
sbt test
Or, to run a single test:
sbt testOnly com.scylladb.migrator.BasicMigrationTest
-
Ultimately, stop the Docker containers
docker compose -f docker-compose-tests.yml down
Make sure to re-build the fat-jar everytime you change something in the implementation:
sbt migrator/assembly
And then re-run the tests.
The tests involve the execution of code on several locations:
- locally (ie, on the machine where you invoke
sbt test
): tests initialization and assertions - on the Spark master node: the
Migrator
entry point - on the Spark worker node: RDD operations
In all those cases, it is possible to debug them by using the Java Debug Wire Protocol.
Follow the procedure documented here.
- In the file
MigratorSuite.scala
, uncomment the line that sets thespark.driver.extraJavaOptions
. - Set up the remote debugger of your IDE to listen to the port 5005.
- Run a test
- When the test starts a Spark job, it waits for the remote debugger
- Start the remote debugger from your IDE.
- The test execution resumes, and you can interact with it from your debugger.
- In the file
MigratorSuite.scala
, uncomment the line that sets thespark.executor.extraJavaOptions
. - Set up the remote debugger of your IDE to listen to the port 5006.
- Run a test
- When the test starts an RDD operation, it waits for the remote debugger. Note that the Spark master node will not display the output of the worker node, but you can see it in the worker web UI: http://localhost:8081/.
- Start the remote debugger from your IDE.
- The test execution resumes, and you can interact with it from your debugger.