Skip to content

Commit f3e012a

Browse files
authored
Merge pull request #104 from datastax/issue/97-integrationTest
Issue/97 integration test
2 parents 2f6d160 + e5a24c3 commit f3e012a

25 files changed

+811
-1
lines changed

SIT/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
setup.out
2+
setup.err
3+
execute.out
4+
execute.err
5+
actual.out
6+
actual.err

SIT/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
all: setup test_smoke env_teardown
3+
4+
setup: build env_setup
5+
6+
reset: build env_reset
7+
reset_hard: build env_teardown env_setup
8+
9+
build:
10+
cd .. && mvn clean package
11+
12+
test_smoke: reset test_smoke_cmd
13+
test_smoke_cmd:
14+
./test.sh -p smoke
15+
16+
env_setup:
17+
./environment.sh -m setup -j ../target/cassandra-data-migrator*.jar
18+
env_reset:
19+
./environment.sh -m reset -j ../target/cassandra-data-migrator*.jar
20+
env_validate:
21+
./environment.sh -m validate
22+
env_teardown:
23+
./environment.sh -m teardown
24+

SIT/cdm.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
_usage() {
4+
cat <<EOF
5+
6+
usage: $0 -s scenario -f config_file [-d directory]
7+
8+
Required
9+
-s scenario : scenario to run
10+
-f config_file : a file with list of scenarios
11+
12+
Optional
13+
-d directory : directory in which config_file may be found
14+
15+
config_file format
16+
==================
17+
File should be space-separated list of columns:
18+
19+
scenario: any one word that forms the key
20+
class: a valid CDM class to invoke, e.g. datastax.astra.migrate.Migrate
21+
properties: path to a valid CDM .properties file, there can be different files for each scenario
22+
23+
Example file:
24+
-------------------------
25+
migrateData datastax.astra.migrate.Migrate /smoke/01_basic_kvp/migrate.properties
26+
validateData datastax.astra.migrate.DiffData /smoke/01_basic_kvp/migrate.properties
27+
-------------------------
28+
29+
Output will be put into the same directory as the .properties file named like:
30+
cdm.scenario.out (stdout)
31+
cdm.scenario.err (stderr)
32+
33+
So the above example would generate files:
34+
cdm.migrateData.out
35+
cdm.migrateData.err
36+
cdm.validateData.out
37+
cdm.validateData.err
38+
39+
EOF
40+
exit 1
41+
}
42+
43+
while getopts "s:f:d:" opt; do
44+
case $opt in
45+
s) SCENARIO="$OPTARG"
46+
;;
47+
f) CONFIG_FILENAME="$OPTARG"
48+
;;
49+
d) CONFIG_DIR="$OPTARG"
50+
;;
51+
?) echo "ERROR invalid option was specified - ${OPTARG}"
52+
_usage
53+
;;
54+
esac
55+
done
56+
57+
argErrors=0
58+
if [[ -z "$CONFIG_FILENAME" ]]; then
59+
echo "missing -f config_file"
60+
argErrors=1
61+
else
62+
if [[ -z "${CONFIG_DIR}" ]]; then
63+
CONFIG_FILE="${CONFIG_FILENAME}"
64+
else
65+
CONFIG_FILE="${CONFIG_DIR}/${CONFIG_FILENAME}"
66+
fi
67+
if [[ ! -r ${CONFIG_FILE} ]]; then
68+
echo "config file ${CONFIG_FILE} not found, or is not readable"
69+
argErrors=1
70+
fi
71+
fi
72+
73+
if [[ -z "$SCENARIO" ]]; then
74+
echo "missing -s scenario"
75+
argErrors=1
76+
else
77+
if [[ $(egrep -c '^'$SCENARIO' ' $CONFIG_FILE) -ne 1 ]]; then
78+
echo "scenario not found in: ${CONFIG_FILE}"
79+
argErrors=1
80+
else
81+
CLASS=$(egrep '^'$SCENARIO' ' $CONFIG_FILE | awk '{print $2}')
82+
PROPERTIES=$(egrep '^'$SCENARIO' ' $CONFIG_FILE | awk '{print $3}')
83+
84+
if [[ ! -r "${PROPERTIES}" ]]; then
85+
echo ".properties file not found: ${PROPERTIES}"
86+
argErrors=1
87+
fi
88+
fi
89+
fi
90+
if [ $argErrors -ne 0 ]; then
91+
_usage
92+
fi
93+
94+
spark-submit --properties-file "${PROPERTIES}" --master "local[*]" --class ${CLASS} /local/cassandra-data-migrator.jar

SIT/common.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
DOCKER_CASS=cdm-sit-cass
2+
DOCKER_CDM=cdm-sit-cdm
3+
CASS_USERNAME=cassandra
4+
CASS_PASSWORD=cassandra
5+
KEYSPACES="source target"
6+
CDM_DIRECTORY=/local
7+
CDM_JARFILE=cassandra-data-migrator.jar
8+
9+
_info() {
10+
echo "INFO $*"
11+
}
12+
13+
_warn() {
14+
echo "WARN $*"
15+
}
16+
17+
_error() {
18+
echo "ERROR $*"
19+
}
20+
21+
_fatal() {
22+
echo "FATAL $*"
23+
exit 2
24+
}

0 commit comments

Comments
 (0)