Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7728 from EOSIO/zach-1.8-fix-db-modes-test
Browse files Browse the repository at this point in the history
Fix db_modes_test
  • Loading branch information
kj4ezj authored Aug 5, 2019
2 parents 4d361c5 + 28c5a26 commit 163fa86
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 135 deletions.
6 changes: 3 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_multiple_version_protocol_feat
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/consensus-validation-malicious-producers.py ${CMAKE_CURRENT_BINARY_DIR}/consensus-validation-malicious-producers.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/validate-dirty-db.py ${CMAKE_CURRENT_BINARY_DIR}/validate-dirty-db.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/launcher_test.py ${CMAKE_CURRENT_BINARY_DIR}/launcher_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/db_modes_test.py ${CMAKE_CURRENT_BINARY_DIR}/db_modes_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/db_modes_test.sh ${CMAKE_CURRENT_BINARY_DIR}/db_modes_test.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/prod_preactivation_test.py ${CMAKE_CURRENT_BINARY_DIR}/prod_preactivation_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version-label.sh ${CMAKE_CURRENT_BINARY_DIR}/version-label.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_producer_watermark_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_producer_watermark_test.py COPYONLY)
Expand Down Expand Up @@ -84,8 +84,8 @@ add_test(NAME validate_dirty_db_test COMMAND tests/validate-dirty-db.py -v --cle
set_property(TEST validate_dirty_db_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME launcher_test COMMAND tests/launcher_test.py -v --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST launcher_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME db_modes_test COMMAND tests/db_modes_test.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST db_modes_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME db_modes_test COMMAND tests/db_modes_test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_tests_properties(db_modes_test PROPERTIES COST 6000)
add_test(NAME version-label-test COMMAND tests/version-label.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

# Long running tests
Expand Down
132 changes: 0 additions & 132 deletions tests/db_modes_test.py

This file was deleted.

101 changes: 101 additions & 0 deletions tests/db_modes_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env bash

# This test is intended to verify that switching between DB modes "just works". Addtionally
# it tries to make sure the dirty bit behaves as expected even in heap mode.

set -euo pipefail

VERBOSE=0
TEST_LOCKED_MODE=0

while getopts ":lv" opt; do
case ${opt} in
l)
TEST_LOCKED_MODE=1
;;
v)
VERBOSE=1
set -o xtrace
;;
\?)
echo "Use -v for verbose; -l to enable test of locked mode"
exit 1;
;;
:)
echo "Invalid option"
exit 1;
;;
esac
done

EOSIO_STUFF_DIR=$(mktemp -d)
trap "rm -rf $EOSIO_STUFF_DIR" EXIT
NODEOS_LAUNCH_PARAMS="./programs/nodeos/nodeos -d $EOSIO_STUFF_DIR --config-dir $EOSIO_STUFF_DIR \
--chain-state-db-size-mb 8 --chain-state-db-guard-size-mb 0 --reversible-blocks-db-size-mb 1 \
--reversible-blocks-db-guard-size-mb 0 -e -peosio"

run_nodeos() {
if (( $VERBOSE == 0 )); then
$NODEOS_LAUNCH_PARAMS --http-server-address '' --p2p-listen-endpoint '' "$@" 2>/dev/null &
else
$NODEOS_LAUNCH_PARAMS --http-server-address '' --p2p-listen-endpoint '' "$@" &
fi
}

run_expect_success() {
run_nodeos "$@"
local NODEOS_PID=$!
sleep 10
kill $NODEOS_PID
wait $NODEOS_PID
}

run_and_kill() {
run_nodeos "$@"
local NODEOS_PID=$!
sleep 10
kill -KILL $NODEOS_PID
! wait $NODEOS_PID
}

run_expect_failure() {
run_nodeos "$@"
local NODEOS_PID=$!
MYPID=$$
(sleep 20; kill -ALRM $MYPID) & local TIMER_PID=$!
trap "kill $NODEOS_PID; wait $NODEOS_PID; exit 1" ALRM
sleep 10
if wait $NODEOS_PID; then exit 1; fi
kill $TIMER_PID
trap ALRM
}

#new chain with mapped mode
run_expect_success --delete-all-blocks
#use previous DB with heap mode
run_expect_success --database-map-mode heap
#test lock mode if enabled
if (( $TEST_LOCKED_MODE == 1 )); then
run_expect_success --database-map-mode locked
fi
#locked mode should fail when it's not possible to lock anything
ulimit -l 0
run_expect_failure --database-map-mode locked
#But shouldn't result in the dirty flag staying set; so next launch should run
run_expect_success
#Try killing with KILL
run_and_kill
#should be dirty now
run_expect_failure
#should also still be dirty in heap mode
run_expect_failure --database-map-mode heap

#start over again! but this time start with heap mode
run_expect_success --delete-all-blocks --database-map-mode heap
#Then switch back to mapped
run_expect_success
#try killing it while in heap mode
run_and_kill --database-map-mode heap
#should be dirty if we run in either mode node
run_expect_failure --database-map-mode heap
run_expect_failure

0 comments on commit 163fa86

Please sign in to comment.