Skip to content

Commit ce7fdef

Browse files
authored
Merge pull request #237 from arvy/makes-test-bash-script-more-robust
Makes test.sh more robust
2 parents c247725 + 00199f6 commit ce7fdef

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

SIT/test.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ fi
3737
_captureOutput() {
3838
_info "Copying ${DOCKER_CDM}:/${testDir} into ${testDir}/output/"
3939
docker cp ${DOCKER_CDM}:/${testDir} ${testDir}/output/
40+
4041
_info "Moving ${testDir}/output/$(basename ${testDir})/*.out TO ${testDir}/output/"
41-
mv -v ${testDir}/output/$(basename ${testDir})/*.out ${testDir}/output/
42+
find ${testDir}/output/$(basename ${testDir})/ -type f -name "*.out" | xargs -I{} mv {} ${testDir}/output/
43+
4244
_info "Moving ${testDir}/output/$(basename ${testDir})/*.err TO ${testDir}/output/"
43-
mv -v ${testDir}/output/$(basename ${testDir})/*.err ${testDir}/output/
44-
_info "Moving ${testDir}/output/$(basename ${testDir})/output/*.out TO ${testDir}/output/"
45-
mv -v ${testDir}/output/$(basename ${testDir})/output/*.out ${testDir}/output/
45+
find ${testDir}/output/$(basename ${testDir})/ -type f -name "*.err" | xargs -I{} mv {} ${testDir}/output/
46+
47+
_info "Moving ${testDir}/output/$(basename ${testDir})/output/*.out TO ${testDir}/output"
48+
find ${testDir}/output/$(basename ${testDir})/output/ -type f -name "*.out" | xargs -I{} mv {} ${testDir}/output/
49+
4650
_info "Moving ${testDir}/output/$(basename ${testDir})/output/*.err TO ${testDir}/output/"
47-
mv -v ${testDir}/output/$(basename ${testDir})/output/*.err ${testDir}/output/
51+
find ${testDir}/output/$(basename ${testDir})/output/ -type f -name "*.err" | xargs -I{} mv {} ${testDir}/output/
52+
4853
_info "Removing ${testDir}/output/$(basename ${testDir})"
4954
rm -rf ${testDir}/output/$(basename ${testDir})
5055
}
@@ -80,7 +85,7 @@ for testDir in $(ls -d ${PHASE}/*); do
8085
done
8186

8287
# The .jar file is expected to be present
83-
docker exec ${DOCKER_CDM} ls -d ${CDM_JAR} >/dev/null 2>&1
88+
docker exec ${DOCKER_CDM} bash -c "ls -d ${CDM_JAR} >/dev/null 2>&1"
8489
if [ $? -ne 0 ]; then
8590
_error "Required file ${CDM_JAR} is not installed in Docker container ${DOCKER_CDM}"
8691
errors=1
@@ -109,7 +114,7 @@ errors=0
109114
for testDir in $(ls -d ${PHASE}/*); do
110115
export testDir
111116
_info ${testDir} Setup tables and data
112-
docker exec ${DOCKER_CASS} cqlsh -u $CASS_USERNAME -p $CASS_PASSWORD -f $testDir/setup.cql > $testDir/output/setup.out 2>$testDir/output/setup.err
117+
docker exec ${DOCKER_CASS} bash -c "cqlsh -u ${CASS_USERNAME} -p ${CASS_PASSWORD} -f ${testDir}/setup.cql" > ${testDir}/output/setup.out 2>${testDir}/output/setup.err
113118
if [ $? -ne 0 ]; then
114119
_error "${testDir}/setup.cql failed, see $testDir/output/setup.out and $testDir/output/setup.err"
115120
errors=1
@@ -128,7 +133,7 @@ errors=0
128133
for testDir in $(ls -d ${PHASE}/*); do
129134
export testDir
130135
_info ${testDir} Executing test
131-
docker exec ${DOCKER_CDM} bash -e -c "$testDir/execute.sh /$testDir > $testDir/output/execute.out 2>$testDir/output/execute.err"
136+
docker exec ${DOCKER_CDM} bash -e -c "${testDir}/execute.sh /${testDir}" > ${testDir}/output/execute.out 2>${testDir}/output/execute.err
132137
if [ $? -ne 0 ]; then
133138
_error "${testDir}/execute.sh failed, see $testDir/output/execute.out and $testDir/output/execute.err"
134139
echo "=-=-=-=-=-=-=- Container Directory Listing -=-=-=-=-=-=-=-"
@@ -156,7 +161,7 @@ for testDir in $(ls -d ${PHASE}/*); do
156161
${testDir}/alternateCheckResults.sh > $testDir/output/actual.out 2>$testDir/output/actual.err
157162
else
158163
_info ${testDir} Check Expected Results
159-
docker exec ${DOCKER_CASS} cqlsh -u $CASS_USERNAME -p $CASS_PASSWORD -f $testDir/expected.cql > $testDir/output/actual.out 2>$testDir/output/actual.err
164+
docker exec ${DOCKER_CASS} bash -c "cqlsh -u ${CASS_USERNAME} -p ${CASS_PASSWORD} -f ${testDir}/expected.cql" > ${testDir}/output/actual.out 2>${testDir}/output/actual.err
160165
fi
161166
if [ $? -ne 0 ]; then
162167
_error "${testDir}/expected.cql failed, see $testDir/output/actual.out $testDir/output/and actual.err"

0 commit comments

Comments
 (0)