forked from scylladb/scylla-migrator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scylladb#121 from julienrf/test-cassandra
Expand the tests to cover migrations from Cassandra, ScyllaDB, and Parquet
- Loading branch information
Showing
24 changed files
with
624 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
attempt () { | ||
command=$1 | ||
attempts=0 | ||
max_attempts=240 | ||
while ! eval "$command" ; do | ||
[[ $attempts -ge $max_attempts ]] && echo "Failed!" && exit 1 | ||
attempts=$((attempts+1)) | ||
sleep 1; | ||
echo "waiting... (${attempts}/${max_attempts})" | ||
done | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
service=$1 | ||
|
||
source .github/attempt.sh | ||
|
||
echo "Waiting for CQL to be ready in service ${service}" | ||
attempt 'docker compose -f docker-compose-tests.yml exec ${service} bash -c "cqlsh -e '"'"'describe cluster'"'"'" > /dev/null' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
port=$1 | ||
|
||
source .github/attempt.sh | ||
|
||
echo "Waiting for successful HTTP status code on port ${port}" | ||
attempts=0 | ||
max_attempts=60 | ||
while ! curl -s "http://127.0.0.1:$port" > /dev/null ; do | ||
[[ $attempts -ge $max_attempts ]] && echo "Failed!" && exit 1 | ||
attempts=$((attempts+1)) | ||
sleep 1; | ||
echo "waiting... (${attempts}/${max_attempts})" | ||
done | ||
attempt 'curl -s "http://127.0.0.1:$port" > /dev/null' |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cassandra/ | ||
scylla/ | ||
spark-master/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
43 changes: 43 additions & 0 deletions
43
tests/src/test/configurations/cassandra-to-scylla-basic.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
source: | ||
type: cassandra | ||
host: cassandra | ||
port: 9042 | ||
localDC: datacenter1 | ||
credentials: | ||
username: dummy | ||
password: dummy | ||
keyspace: test | ||
table: basictest | ||
consistencyLevel: LOCAL_QUORUM | ||
preserveTimestamps: true | ||
splitCount: 8 | ||
connections: 8 | ||
fetchSize: 1000 | ||
|
||
target: | ||
type: scylla | ||
host: scylla | ||
port: 9042 | ||
localDC: datacenter1 | ||
credentials: | ||
username: dummy | ||
password: dummy | ||
keyspace: test | ||
table: basictest | ||
consistencyLevel: LOCAL_QUORUM | ||
connections: 16 | ||
stripTrailingZerosForDecimals: false | ||
|
||
renames: [] | ||
|
||
savepoints: | ||
path: /app/savepoints | ||
intervalSeconds: 300 | ||
skipTokenRanges: [] | ||
validation: | ||
compareTimestamps: true | ||
ttlToleranceMillis: 60000 | ||
writetimeToleranceMillis: 1000 | ||
failuresToFetch: 100 | ||
floatingPointTolerance: 0.001 | ||
timestampMsTolerance: 0 |
45 changes: 45 additions & 0 deletions
45
tests/src/test/configurations/cassandra-to-scylla-renames.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
source: | ||
type: cassandra | ||
host: cassandra | ||
port: 9042 | ||
localDC: datacenter1 | ||
credentials: | ||
username: dummy | ||
password: dummy | ||
keyspace: test | ||
table: renameditems | ||
consistencyLevel: LOCAL_QUORUM | ||
preserveTimestamps: true | ||
splitCount: 8 | ||
connections: 8 | ||
fetchSize: 1000 | ||
|
||
target: | ||
type: scylla | ||
host: scylla | ||
port: 9042 | ||
localDC: datacenter1 | ||
credentials: | ||
username: dummy | ||
password: dummy | ||
keyspace: test | ||
table: renameditems | ||
consistencyLevel: LOCAL_QUORUM | ||
connections: 16 | ||
stripTrailingZerosForDecimals: false | ||
|
||
renames: | ||
- from: bar | ||
to: quux | ||
|
||
savepoints: | ||
path: /app/savepoints | ||
intervalSeconds: 300 | ||
skipTokenRanges: [] | ||
validation: | ||
compareTimestamps: true | ||
ttlToleranceMillis: 60000 | ||
writetimeToleranceMillis: 1000 | ||
failuresToFetch: 100 | ||
floatingPointTolerance: 0.001 | ||
timestampMsTolerance: 0 |
31 changes: 31 additions & 0 deletions
31
tests/src/test/configurations/parquet-to-scylla-basic.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
source: | ||
type: parquet | ||
path: /app/parquet/basic.parquet | ||
|
||
target: | ||
type: scylla | ||
host: scylla | ||
port: 9042 | ||
localDC: datacenter1 | ||
credentials: | ||
username: dummy | ||
password: dummy | ||
keyspace: test | ||
table: basictest | ||
consistencyLevel: LOCAL_QUORUM | ||
connections: 16 | ||
stripTrailingZerosForDecimals: false | ||
|
||
renames: [] | ||
|
||
savepoints: | ||
path: /app/savepoints | ||
intervalSeconds: 300 | ||
skipTokenRanges: [] | ||
validation: | ||
compareTimestamps: true | ||
ttlToleranceMillis: 60000 | ||
writetimeToleranceMillis: 1000 | ||
failuresToFetch: 100 | ||
floatingPointTolerance: 0.001 | ||
timestampMsTolerance: 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
source: | ||
type: scylla | ||
host: scylla-source | ||
port: 9042 | ||
localDC: datacenter1 | ||
credentials: | ||
username: dummy | ||
password: dummy | ||
keyspace: test | ||
table: basictest | ||
consistencyLevel: LOCAL_QUORUM | ||
preserveTimestamps: true | ||
splitCount: 8 | ||
connections: 8 | ||
fetchSize: 1000 | ||
|
||
target: | ||
type: scylla | ||
host: scylla | ||
port: 9042 | ||
localDC: datacenter1 | ||
credentials: | ||
username: dummy | ||
password: dummy | ||
keyspace: test | ||
table: basictest | ||
consistencyLevel: LOCAL_QUORUM | ||
connections: 16 | ||
stripTrailingZerosForDecimals: false | ||
|
||
renames: [] | ||
|
||
savepoints: | ||
path: /app/savepoints | ||
intervalSeconds: 300 | ||
skipTokenRanges: [] | ||
validation: | ||
compareTimestamps: true | ||
ttlToleranceMillis: 60000 | ||
writetimeToleranceMillis: 1000 | ||
failuresToFetch: 100 | ||
floatingPointTolerance: 0.001 | ||
timestampMsTolerance: 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
datastax-java-driver { | ||
basic.request { | ||
timeout = 10 seconds | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/src/test/scala/com/scylladb/migrator/CassandraUtils.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.scylladb.migrator | ||
|
||
import com.datastax.oss.driver.api.core.CqlSession | ||
import com.datastax.oss.driver.api.core.`type`.DataTypes | ||
import com.datastax.oss.driver.api.querybuilder.SchemaBuilder | ||
|
||
object CassandraUtils { | ||
|
||
/** | ||
* Prepare a Scylla table for a test. Drop any existing table of the same name and recreates it. | ||
* | ||
* @param database Database session to use | ||
* @param keyspace Keyspace name | ||
* @param name Name of the table to create | ||
* @param columnName Function to possible transform the initial name of the columns | ||
*/ | ||
def dropAndRecreateTable(database: CqlSession, keyspace: String, name: String, columnName: String => String): Unit = { | ||
val dropTableStatement = | ||
SchemaBuilder | ||
.dropTable(keyspace, name) | ||
.ifExists() | ||
.build() | ||
database | ||
.execute(dropTableStatement) | ||
.ensuring(_.wasApplied()) | ||
val createTableStatement = | ||
SchemaBuilder | ||
.createTable(keyspace, name) | ||
.withPartitionKey("id", DataTypes.TEXT) | ||
.withColumn(columnName("foo"), DataTypes.TEXT) | ||
.withColumn(columnName("bar"), DataTypes.INT) | ||
.build() | ||
database | ||
.execute(createTableStatement) | ||
.ensuring(_.wasApplied()) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/src/test/scala/com/scylladb/migrator/SparkUtils.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.scylladb.migrator | ||
|
||
import scala.sys.process.Process | ||
|
||
object SparkUtils { | ||
|
||
/** | ||
* Run a migration by submitting a Spark job to the Spark cluster | ||
* and waiting for its successful completion. | ||
* | ||
* @param configFile Configuration file to use. Write your | ||
* configuration files in the directory | ||
* `src/test/configurations`, which is | ||
* automatically mounted to the Spark | ||
* cluster by Docker Compose. | ||
*/ | ||
def submitMigrationJob(configFile: String): Unit = { | ||
val process = | ||
Process( | ||
Seq( | ||
"docker", | ||
"compose", | ||
"-f", "docker-compose-tests.yml", | ||
"exec", | ||
"spark-master", | ||
"/spark/bin/spark-submit", | ||
"--class", "com.scylladb.migrator.Migrator", | ||
"--master", "spark://spark-master:7077", | ||
"--conf", "spark.driver.host=spark-master", | ||
"--conf", s"spark.scylla.config=/app/configurations/${configFile}", | ||
// 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" | ||
) | ||
) | ||
process | ||
.run() | ||
.exitValue() | ||
.ensuring(statusCode => statusCode == 0, "Spark job failed") | ||
() | ||
} | ||
|
||
} |
Oops, something went wrong.