Skip to content

Commit

Permalink
Merge pull request #112 from julienrf/strengthen-testing
Browse files Browse the repository at this point in the history
Strengthen testing
  • Loading branch information
tarzanek authored Mar 12, 2024
2 parents 98cc78e + e701af1 commit a7d43e0
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 16 deletions.
11 changes: 11 additions & 0 deletions .github/wait-for-port.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

port=$1
echo "Waiting for port ${port}"
attempts=0
max_attempts=30
while ! nc -z 127.0.0.1 $port && [[ $attempts < $max_attempts ]] ; do
attempts=$((attempts+1))
sleep 1;
echo "waiting... (${attempts}/${max_attempts})"
done
7 changes: 6 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ jobs:
- name: Build migrator
run: ./build.sh
- name: Set up services
run: docker compose -f docker-compose-tests.yml up --wait
run: |
docker compose -f docker-compose-tests.yml up -d
.github/wait-for-port.sh 8000 # ScyllaDB
.github/wait-for-port.sh 8001 # DynamoDB
.github/wait-for-port.sh 8080 # Spark master
.github/wait-for-port.sh 8081 # Spark worker
- name: Run tests
run: sbt test
- name: Stop services
Expand Down
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,38 @@ sbt migrator/assembly
~~~

And then re-run the tests.

## Debugging

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.

### Local Debugging

Follow the procedure documented [here](https://stackoverflow.com/a/15505308/561721).

### Debugging on the Spark Master Node

1. In the file `MigratorSuite.scala`, uncomment the line that sets the
`spark.driver.extraJavaOptions`.
2. Set up the remote debugger of your IDE to listen to the port 5005.
3. Run a test
4. When the test starts a Spark job, it waits for the remote debugger
5. Start the remote debugger from your IDE.
6. The test execution resumes, and you can interact with it from your debugger.

### Debugging on the Spark Worker Node

1. In the file `MigratorSuite.scala`, uncomment the line that sets the
`spark.executor.extraJavaOptions`.
2. Set up the remote debugger of your IDE to listen to the port 5006.
3. Run a test
4. 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/.
5. Start the remote debugger from your IDE.
6. The test execution resumes, and you can interact with it from your debugger.
4 changes: 4 additions & 0 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ services:
networks:
- scylla
expose:
- 5005
- 7001
- 7002
- 7003
Expand All @@ -46,6 +47,7 @@ services:
- 6066
ports:
- 4040:4040
- 5005:5005
- 6066:6066
- 7077:7077
- 8080:8080
Expand All @@ -65,13 +67,15 @@ services:
networks:
- scylla
expose:
- 5006
- 7012
- 7013
- 7014
- 7015
- 7016
- 8881
ports:
- 5006:5006
- 8081:8081
depends_on:
- spark-master
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ trait MigratorSuite extends munit.FunSuite {
"--master", "spark://spark-master:7077",
"--conf", "spark.driver.host=spark-master",
"--conf", s"spark.scylla.config=/app/configurations/${migratorConfigFile}",
// Uncomment one of the following lines to plug a remote debugger on the Spark master or worker.
// "--conf", "spark.driver.extraJavaOptions=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005",
// "--conf", "spark.executor.extraJavaOptions=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006",
"/jars/scylla-migrator-assembly-0.0.1.jar"
)
).run().exitValue().tap { statusCode =>
Expand Down

0 comments on commit a7d43e0

Please sign in to comment.