DL-186: fix common.sh grep bug; kill MultiReader java process as expected
Author: xieliang <xieliang007@gmail.com>
Reviewers: Sijie Guo <sijie@apache.org>
Closes #114 from xieliang/DL-186-smoketest
diff --git a/distributedlog-benchmark/bin/common.sh b/distributedlog-benchmark/bin/common.sh
index 0b8278c..566563e 100755
--- a/distributedlog-benchmark/bin/common.sh
+++ b/distributedlog-benchmark/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-core/bin/common.sh b/distributedlog-core/bin/common.sh
index 0b8278c..566563e 100755
--- a/distributedlog-core/bin/common.sh
+++ b/distributedlog-core/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-service/bin/common.sh b/distributedlog-service/bin/common.sh
index 0b8278c..566563e 100755
--- a/distributedlog-service/bin/common.sh
+++ b/distributedlog-service/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-tutorials/distributedlog-basic/bin/common.sh b/distributedlog-tutorials/distributedlog-basic/bin/common.sh
index 0b8278c..566563e 100755
--- a/distributedlog-tutorials/distributedlog-basic/bin/common.sh
+++ b/distributedlog-tutorials/distributedlog-basic/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-tutorials/distributedlog-messaging/bin/common.sh b/distributedlog-tutorials/distributedlog-messaging/bin/common.sh
index 0b8278c..566563e 100755
--- a/distributedlog-tutorials/distributedlog-messaging/bin/common.sh
+++ b/distributedlog-tutorials/distributedlog-messaging/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests\|javadoc\|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/scripts/integration/smoketest.sh b/scripts/integration/smoketest.sh
index 0de830d..fdb10c6 100755
--- a/scripts/integration/smoketest.sh
+++ b/scripts/integration/smoketest.sh
@@ -42,10 +42,17 @@
SMOKESTREAM_PREFIX="smoketest-stream-"
# start the sandbox
+echo "start sandbox"
nohup ${DLOG_ROOT}/distributedlog-service/bin/dlog local ${ZK_PORT} > ${LOG_DIR}/sandbox.out 2>&1&
+
+if [ $? -ne 0 ]; then
+ echo "Failed to start sandbox"
+ exit 1
+fi
echo $! > ${LOG_DIR}/sandbox.pid
# create namespace
+echo "create namespace"
${DLOG_ROOT}/distributedlog-core/bin/dlog admin bind -l /ledgers -s 127.0.0.1:${ZK_PORT} -c distributedlog://127.0.0.1:${ZK_PORT}/messaging/${NAMESPACE}
if [ $? -ne 0 ]; then
@@ -54,6 +61,7 @@
fi
# create streams
+echo "create streams"
${DLOG_ROOT}/distributedlog-service/bin/dlog tool create -u distributedlog://127.0.0.1:${ZK_PORT}/messaging/${NAMESPACE} -r ${SMOKESTREAM_PREFIX} -e 1-5 -f
if [ $? -ne 0 ]; then
@@ -62,6 +70,7 @@
fi
# list streams
+echo "list streams"
STREAM_OUTPUT=$(${DLOG_ROOT}/distributedlog-service/bin/dlog tool list -u distributedlog://127.0.0.1:${ZK_PORT}/messaging/${NAMESPACE} | grep "${SMOKESTREAM_PREFIX}")
echo "Create streams : ${STREAM_OUTPUT}."
@@ -74,34 +83,43 @@
done
# start a write proxy
+echo "start a write proxy"
${DLOG_ROOT}/distributedlog-service/bin/dlog-daemon.sh start writeproxy
-# tail the the streams
+# tail the streams
+echo "tail the streams"
nohup ${DLOG_ROOT}/distributedlog-tutorials/distributedlog-basic/bin/runner run org.apache.distributedlog.basic.MultiReader distributedlog://127.0.0.1:${ZK_PORT}/messaging/${NAMESPACE} ${SMOKESTREAM_PREFIX}1,${SMOKESTREAM_PREFIX}2,${SMOKESTREAM_PREFIX}3,${SMOKESTREAM_PREFIX}4,${SMOKESTREAM_PREFIX}5 > ${LOG_DIR}/reader.out 2>&1&
echo $! > ${LOG_DIR}/reader.pid
# generate the records
+echo "generate the records"
nohup ${DLOG_ROOT}/distributedlog-tutorials/distributedlog-basic/bin/runner run org.apache.distributedlog.basic.RecordGenerator "inet!127.0.0.1:${WP_SERVICE_PORT}" ${SMOKESTREAM_PREFIX}1 1 > ${LOG_DIR}/writer.out 2>&1&
echo $! > ${LOG_DIR}/writer.pid
# wait for 20 seconds
+echo "sleep 20"
sleep 20
# kill the writer
+echo "kill the writer"
if [ -f ${LOG_DIR}/writer.pid ]; then
writerpid=$(cat ${LOG_DIR}/writer.pid)
if kill -0 $writerpid > /dev/null 2>&1; then
+ echo "kill $writerpid"
kill $writerpid
fi
fi
-# stop the reader
+# kill the reader
+echo "kill the reader"
if [ -f ${LOG_DIR}/reader.pid ]; then
readerpid=$(cat ${LOG_DIR}/reader.pid)
if kill -0 $readerpid > /dev/null 2>&1; then
+ echo "kill $readerpid"
kill $readerpid
fi
fi
+ps ax | grep MultiReader | grep java | grep -v grep | awk '{print $1}' | xargs kill -9
# check the number of records received
NUM_RECORDS=`cat ${LOG_DIR}/reader.out | grep "record-" | wc -l`
@@ -114,10 +132,12 @@
exit 1
fi
-# stop a write proxy
+# stop the write proxy
+echo "stop the write proxy"
${DLOG_ROOT}/distributedlog-service/bin/dlog-daemon.sh stop writeproxy
# stop the sandbox
+echo "stop the sandbox"
kill `cat ${LOG_DIR}/sandbox.pid`
exit 0