Fix tests/integrate_test/cita_snapshot_test.sh
1. Exchange position of stopping nodes and taking snapshot
2. Fix `height` -> `$height`
3. Log more detail
@@ -59,7 +59,17 @@ done
echo "${timeout}s DONE"
################################################################################
-echo "5) Take snapshot on node-0 at height {0, 2, 100000} ..."
+echo "5) Stop node-1 and node-2, so that node-0 cannot grow up via cita-consensus and cita-sync mechanisms"
+${BINARY_DIR}/bin/cita stop ${CHAIN_NAME}/1
+${BINARY_DIR}/bin/cita stop ${CHAIN_NAME}/2
+
+# Ensure that the current round of BFT has been finished. So that node-0 will
+# not continue growing up, which means its height stay the same.
+sleep 3
+echo "DONE"
+
+################################################################################
+echo "6) Take snapshot on node-0 at height {0, 2, 100000} ..."
for height in {0,2,10000}; do
cd ${BINARY_DIR}/${CHAIN_NAME}/0
${BINARY_DIR}/bin/snapshot_tool \
@@ -74,17 +84,13 @@ done
cd "${BINARY_DIR}"
echo "DONE"
-################################################################################
-echo "6) Stop node-1 and node-2, so that node-0 cannot grow up via cita-consensus and cita-sync mechanisms"
-${BINARY_DIR}/bin/cita stop ${CHAIN_NAME}/1
-${BINARY_DIR}/bin/cita stop ${CHAIN_NAME}/2
-echo "DONE"
-
################################################################################
echo "7) Restore snapshot on node-0 ..."
-for height in {10000,2,0}; do
- current_height=`get_height 0`
+before_height=`get_height 0`
+for height in {10000,2,0,10000,2,0}; do
cd ${BINARY_DIR}/${CHAIN_NAME}/0
+ echo "restoring with before_height=${before_height}, height=${height} ..."
+
${BINARY_DIR}/bin/snapshot_tool \
--cmd restore \
--file snapshot-test-${height} || (
@@ -92,15 +98,15 @@ for height in {10000,2,0}; do
echo "error msg: fail to restore snapshot to ${height}"
exit 1)
- case height in
- 0) expect_height=${current_height};;
+ case $height in
+ 0) expect_height=${before_height};;
2) expect_height=2;;
- 10000) expect_height=${current_height};;
+ 10000) expect_height=${before_height};;
esac
current_height=`get_height 0`
- if [ "${current_height}" = "${expect_height}" ]; then
- echo "FAILED: restore to ${expect_height}-th but chain is ${current_height}-th"
+ if [ "${current_height}" != "${expect_height}" ]; then
+ echo "FAILED: expect_height(${expect_height})!= current_height(${current_height})"
exit 1
fi
done
@@ -112,13 +118,12 @@ echo "DONE"
echo "8) Start node-1 and node-2 and check all grow up ..."
${BINARY_DIR}/bin/cita start ${CHAIN_NAME}/1 trace
${BINARY_DIR}/bin/cita start ${CHAIN_NAME}/2 trace
-sleep 1
-wait_timeout=25
-timeout=`check_height_growth_normal 0 $wait_timeout` || (echo "FAILED"
+wait_timeout=30
+timeout=`check_height_growth_normal 1 $wait_timeout` || (echo "FAILED"
echo "error msg: ${timeout}"
exit 1)
-timeout=`check_height_growth_normal 1 $wait_timeout` || (echo "FAILED"
+timeout=`check_height_growth_normal 0 $wait_timeout` || (echo "FAILED"
echo "error msg: ${timeout}"
exit 1)
echo "DONE"
