Skip to content

Commit 402ee11

Browse files
authored
Merge pull request #116 from datastax/issue/CDM-22
Issue/cdm 22
2 parents 883c0ec + 9021a2b commit 402ee11

29 files changed

+701
-21
lines changed

SIT/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
output/
2+
13
setup.out
24
setup.err
35
execute.out

SIT/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
all: setup test_smoke env_teardown
2+
all: setup test_smoke_cmd test_features_cmd env_teardown
33

44
setup: build env_setup
55

@@ -13,6 +13,10 @@ test_smoke: reset test_smoke_cmd
1313
test_smoke_cmd:
1414
./test.sh -p smoke
1515

16+
test_features: reset test_features_cmd
17+
test_features_cmd:
18+
./test.sh -p features
19+
1620
env_setup:
1721
chmod -R 777 ./*.sh
1822
./environment.sh -m setup -j ../target/cassandra-data-migrator*.jar

SIT/cdm-assert.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
3+
assertCmd="egrep 'JobSession.* Final ' \${OUTPUT_FILE} | sed 's/^.*Final //'"
4+
5+
_usage() {
6+
cat <<EOF
7+
8+
usage: $0 -f output_file -a assertFile [-d directory]
9+
10+
Required
11+
-f output_file : a file with list of scenarios, same format as cdm.sh
12+
-a assertFile : a file with the assertions
13+
14+
Optional
15+
-d directory : directory in which output_file and assertFile may be found
16+
17+
==================
18+
assertFile Format
19+
==================
20+
Expected to contain the "Final" job session summary information, generated similar to
21+
${assertCmd}
22+
23+
File might look like:
24+
---------------
25+
Read Record Count: 3
26+
Mismatch Record Count: 0
27+
Corrected Mismatch Record Count: 0
28+
Missing Record Count: 0
29+
Corrected Missing Record Count: 0
30+
Valid Record Count: 3
31+
Skipped Record Count: 0
32+
---------------
33+
34+
EOF
35+
exit 1
36+
}
37+
38+
while getopts "f:d:a:" opt; do
39+
case $opt in
40+
f) OUTPUT_FILENAME="$OPTARG"
41+
;;
42+
d) CONFIG_DIR="$OPTARG"
43+
;;
44+
a) ASSERT_FILENAME="$OPTARG"
45+
;;
46+
?) echo "ERROR invalid option was specified - ${OPTARG}"
47+
_usage
48+
;;
49+
esac
50+
done
51+
52+
argErrors=0
53+
if [[ -z "$OUTPUT_FILENAME" ]]; then
54+
echo "missing -o output_file"
55+
argErrors=1
56+
else
57+
if [[ -z "${CONFIG_DIR}" ]]; then
58+
OUTPUT_FILE="${OUTPUT_FILENAME}"
59+
else
60+
OUTPUT_FILE="${CONFIG_DIR}/${OUTPUT_FILENAME}"
61+
fi
62+
if [[ ! -r ${OUTPUT_FILE} ]]; then
63+
echo "config file ${OUTPUT_FILE} not found, or is not readable"
64+
argErrors=1
65+
fi
66+
fi
67+
68+
if [[ -z "$ASSERT_FILENAME" ]]; then
69+
echo "missing -a assertFile"
70+
argErrors=1
71+
else
72+
if [[ -z "${CONFIG_DIR}" ]]; then
73+
ASSERT_FILE="${ASSERT_FILENAME}"
74+
else
75+
ASSERT_FILE="${CONFIG_DIR}/${ASSERT_FILENAME}"
76+
fi
77+
if [[ ! -r ${ASSERT_FILE} ]]; then
78+
echo "config file ${ASSERT_FILE} not found, or is not readable"
79+
argErrors=1
80+
fi
81+
fi
82+
83+
84+
if [ $argErrors -ne 0 ]; then
85+
_usage
86+
fi
87+
88+
WORKING_FILE="${ASSERT_FILENAME}".actual.out
89+
if [[ -n "${CONFIG_DIR}" ]]; then
90+
WORKING_FILE="${CONFIG_DIR}/${WORKING_FILE}"
91+
fi
92+
93+
eval ${assertCmd} > ${WORKING_FILE}
94+
95+
diff -q ${ASSERT_FILE} ${WORKING_FILE} > /dev/null 2>&1
96+
rtn=$?
97+
if [ $rtn -eq 1 ]; then
98+
echo "ERROR: CDM output $(basename ${OUTPUT_FILE}) differs from expected (expected vs actual):"
99+
sdiff ${ASSERT_FILE} ${WORKING_FILE}
100+
exit 1
101+
fi

SIT/cdm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ if [ $argErrors -ne 0 ]; then
9191
_usage
9292
fi
9393

94-
spark-submit --properties-file "${PROPERTIES}" --master "local[*]" --class ${CLASS} /local/cassandra-data-migrator.jar
94+
spark-submit --properties-file "${PROPERTIES}" --master "local[*]" --class ${CLASS} /local/cassandra-data-migrator.jar

SIT/environment.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ _createDockerCDM_Directory() {
184184
docker exec ${DOCKER_CDM} mkdir -p ${CDM_DIRECTORY}
185185
docker cp ${JAR} ${DOCKER_CDM}:${CDM_DIRECTORY}/${CDM_JARFILE}
186186
docker cp cdm.sh ${DOCKER_CDM}:${CDM_DIRECTORY}/cdm.sh
187+
docker cp cdm-assert.sh ${DOCKER_CDM}:${CDM_DIRECTORY}/cdm-assert.sh
187188
if [[ "$(_testDockerCDM_Directory)" != "yes" ]]; then
188189
_fatal "Directory ${CDM_DIRECTORY} cannot be created, or ${JAR} cannot be copied to ${CDM_DIRECTORY}"
189190
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
DELETE FROM target.feature_constant_column WHERE key='key2' AND const1='abcd';
3+
UPDATE target.feature_constant_column SET value='value999' WHERE key='key3' AND const1='abcd';
4+
SELECT * FROM target.feature_constant_column;
5+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Read Record Count: 3
2+
Mismatch Record Count: 1
3+
Corrected Mismatch Record Count: 1
4+
Missing Record Count: 1
5+
Corrected Missing Record Count: 1
6+
Valid Record Count: 1
7+
Skipped Record Count: 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Read Record Count: 3
2+
Skipped Record Count: 0
3+
Write Record Count: 3
4+
Error Record Count: 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
migrateData datastax.astra.migrate.Migrate migrate.properties
2+
validateData datastax.astra.migrate.DiffData migrate.properties
3+
fixData datastax.astra.migrate.DiffData fix.properties
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Read Record Count: 3
2+
Mismatch Record Count: 0
3+
Corrected Mismatch Record Count: 0
4+
Missing Record Count: 0
5+
Corrected Missing Record Count: 0
6+
Valid Record Count: 3
7+
Skipped Record Count: 0

0 commit comments

Comments
 (0)