Skip to content

Commit

Permalink
Merge branch 'master' into update-docs-catchup
Browse files Browse the repository at this point in the history
  • Loading branch information
ashcherbakov authored Aug 16, 2023
2 parents 0afdd28 + 6febcf2 commit 62dd053
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 1 deletion.
19 changes: 18 additions & 1 deletion integration_tests/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ else
fi

cleanup() {
make localnet_clean
make localnet_clean
}
trap cleanup EXIT

Expand Down Expand Up @@ -185,6 +185,21 @@ if [[ $TESTS_TO_RUN =~ "all" || $TESTS_TO_RUN =~ "deploy" ]]; then
fi
fi

test_add_new_node_after_upgrade() {
ADD_NEW_NODE_AFTER_UPGRADE="./integration_tests/upgrade/add-new-node-after-upgrade.sh"

log "*****************************************************************************************"
log "Running $ADD_NEW_NODE_AFTER_UPGRADE"
log "*****************************************************************************************"

if bash "$ADD_NEW_NODE_AFTER_UPGRADE" &>${DETAILED_OUTPUT_TARGET}; then
log "$ADD_NEW_NODE_AFTER_UPGRADE finished successfully"
else
log "$ADD_NEW_NODE_AFTER_UPGRADE failed"
exit 1
fi
}

# Upgrade procedure tests
if [[ $TESTS_TO_RUN =~ "all" || $TESTS_TO_RUN =~ "upgrade" ]]; then
UPGRADE_SHELL_TEST="./integration_tests/upgrade/test-upgrade.sh"
Expand All @@ -196,7 +211,9 @@ if [[ $TESTS_TO_RUN =~ "all" || $TESTS_TO_RUN =~ "upgrade" ]]; then
log "*****************************************************************************************"

if bash "$UPGRADE_SHELL_TEST" &>${DETAILED_OUTPUT_TARGET}; then
rm dcld_mainnet_stable
log "$UPGRADE_SHELL_TEST finished successfully"
test_add_new_node_after_upgrade
else
log "$UPGRADE_SHELL_TEST failed"
exit 1
Expand Down
131 changes: 131 additions & 0 deletions integration_tests/upgrade/add-new-node-after-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
source integration_tests/cli/common.sh
set +euo pipefail

localnet_dir=".localnet"
dcl_user_home="/var/lib/dcl"
DCL_DIR="$dcl_user_home/.dcl"
mainnet_stable_version="0.12.1"
latest_release_binary_version="1.2.0"

node_name="new-observer"
node_p2p_port=26670
node_client_port=26671
chain_id="dclchain"
ip="192.167.10.28"
docker_network="distributed-compliance-ledger_localnet"

function check_expected_catching_up_status_for_interval {
local expected_status="$1"
local overall_ping_time_sec="${2:-100}"
local sleep_time_sec="${3:-1}"
local seconds=0

while [ $seconds -lt $overall_ping_time_sec ]; do
local dcld_status=$(docker exec --user root $node_name dcld status 2>&1)

status_substring="\"catching_up\":$expected_status"
if [[ $dcld_status == *"$status_substring"* ]]; then
echo -e "dcld status:\n$dcld_status"
return 1
fi

sleep $sleep_time_sec
local seconds=$((seconds+1))
done

return 0
}

cleanup() {
if docker container ls -a | grep -q $node_name; then
if docker container inspect $node_name | grep -q '"Status": "running"'; then
echo "Stopping container"
docker container kill $node_name
fi

echo "Removing container"
docker container rm -f "$node_name"
fi
}
trap cleanup EXIT

cleanup

echo "1. run $node_name container"
docker run -d --name $node_name --ip $ip -p "$node_p2p_port-$node_client_port:26656-26657" --network $docker_network -i dcledger

test_divider

echo "2. install dcld v$mainnet_stable_version to $node_name"
wget "https://github.com/zigbee-alliance/distributed-compliance-ledger/releases/download/v$mainnet_stable_version/dcld"
chmod ugo+x dcld
docker cp ./dcld "$node_name":"$dcl_user_home"/
rm -f ./dcld

test_divider

echo "3. Set up configuration files for $node_name"
docker exec $node_name ./dcld init $node_name --chain-id $chain_id
docker cp "$localnet_dir/node0/config/genesis.json" $node_name:$DCL_DIR/config
peers="$(cat "$localnet_dir/node0/config/config.toml" | grep -o -E "persistent_peers = \".*\"")"
docker exec $node_name sed -i "s/persistent_peers = \"\"/$peers/g" $DCL_DIR/config/config.toml
docker exec $node_name sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' $DCL_DIR/config/config.toml

test_divider

echo "4. Locate the app to $DCL_DIR/cosmovisor/genesis/bin directory in $node_name"
docker exec $node_name mkdir -p "$DCL_DIR"/cosmovisor/genesis/bin
docker exec $node_name cp -f ./dcld "$DCL_DIR"/cosmovisor/genesis/bin/

test_divider

echo "5. Start Node \"$node_name\""
docker exec -d $node_name cosmovisor start

test_divider

echo "6. Check dcld version == $mainnet_stable_version in $node_name"
dcld_version=$(docker exec $node_name dcld version)
echo "dcld_version = $dcld_version"
if [ "$dcld_version" != $mainnet_stable_version ]; then
echo "installed dcld version $dcld_version != dcld mainnet version $mainnet_stable_version"
exit 1
fi

test_divider

sleep_time_sec=1
overall_ping_time_sec=200
echo "7. Check node $node_name for START catching up process pinging it every $sleep_time_sec second for $overall_ping_time_sec seconds"

check_expected_catching_up_status_for_interval true $overall_ping_time_sec $sleep_time_sec
is_catching_up=$?

if [ $is_catching_up == 0 ] ; then
echo "Catch-up procedure does not started"
exit 1
fi

test_divider

echo "8. Check node $node_name for FINISH catching up process pinging it every $sleep_time_sec second for $overall_ping_time_sec seconds"

check_expected_catching_up_status_for_interval false $overall_ping_time_sec $sleep_time_sec
is_not_catching_up=$?

if [ $is_not_catching_up == 0 ] ; then
echo "Catch-up procedure does not finished"
exit 1
fi

test_divider

echo "9. Check node $node_name dcld updated to version $latest_release_binary_version"
dcld_version=$(docker exec $node_name dcld version)
echo "dcld_version = $dcld_version"
if [ "$dcld_version" != "$latest_release_binary_version" ]; then
echo "installed dcld version $dcld_version != dcld expected version $latest_release_binary_version"
exit 1
fi

echo "PASSED"

0 comments on commit 62dd053

Please sign in to comment.