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

Wlb/adding nodeos param tests 2.0.x #10135

Merged
merged 11 commits into from
Mar 16, 2021
3 changes: 3 additions & 0 deletions .cicd/generate-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ EOF
- 'registry_2'
- EOSIO/skip-checkout#v0.1.1:
cd: ~
env:
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
PLATFORM_TYPE: $PLATFORM_TYPE
agents: "queue=mac-anka-node-fleet"
retry:
manual:
Expand Down
1 change: 1 addition & 0 deletions pipeline.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"170=v1.7.0"
]
},
// eosio-resume-from-state documentation: https://github.com/EOSIO/auto-eks-sync-nodes/blob/master/pipelines/eosio-resume-from-state/README.md
"eosio-resume-from-state":
{
"test":
Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/db_modes_test.sh ${CMAKE_CURRENT_BINA
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}/release-build.sh ${CMAKE_CURRENT_BINARY_DIR}/release-build.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version-label.sh ${CMAKE_CURRENT_BINARY_DIR}/version-label.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/full-version-label.sh ${CMAKE_CURRENT_BINARY_DIR}/full-version-label.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/print-build-info.sh ${CMAKE_CURRENT_BINARY_DIR}/print-build-info.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_producer_watermark_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_producer_watermark_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cli_test.py ${CMAKE_CURRENT_BINARY_DIR}/cli_test.py COPYONLY)

Expand Down Expand Up @@ -94,6 +96,8 @@ add_test(NAME db_modes_test COMMAND tests/db_modes_test.sh WORKING_DIRECTORY ${C
set_tests_properties(db_modes_test PROPERTIES COST 6000)
add_test(NAME release-build-test COMMAND tests/release-build.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME version-label-test COMMAND tests/version-label.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME full-version-label-test COMMAND tests/full-version-label.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME print-build-info-test COMMAND tests/print-build-info.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

# Long running tests
add_test(NAME nodeos_sanity_lr_test COMMAND tests/nodeos_run_test.py -v --sanity-test --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
Expand Down
73 changes: 73 additions & 0 deletions tests/full-version-label.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
set -eo pipefail
# The purpose of this test is to ensure that the output of the "nodeos --full-version" command matches the version string defined by our CMake files
echo '##### Nodeos Full Version Label Test #####'
# orient ourselves
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/eos/')
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/EOSIO/eosio/')
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/build/' | sed 's,/build/,,')
echo "Using EOSIO_ROOT=\"$EOSIO_ROOT\"."
# determine expected value
CMAKE_CACHE="$EOSIO_ROOT/build/CMakeCache.txt"
CMAKE_LISTS="$EOSIO_ROOT/CMakeLists.txt"
if [[ -f "$CMAKE_CACHE" && $(cat "$CMAKE_CACHE" | grep -c 'DOXY_EOS_VERSION') > 0 ]]; then
echo "Parsing \"$CMAKE_CACHE\"..."
EXPECTED="v$(cat "$CMAKE_CACHE" | grep 'DOXY_EOS_VERSION' | cut -d '=' -f 2)"
elif [[ -f "$CMAKE_LISTS" ]]; then
echo "Parsing \"$CMAKE_LISTS\"..."
export $(cat $CMAKE_LISTS | grep -ie 'set *( *VERSION_MAJOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1"="$2}')
export $(cat $CMAKE_LISTS | grep -ie 'set *( *VERSION_MINOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1"="$2}')
export $(cat $CMAKE_LISTS | grep -ie 'set *( *VERSION_PATCH' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1"="$2}')
if [[ $(cat $CMAKE_LISTS | grep -ice 'set *( *VERSION_SUFFIX') > 0 ]]; then
echo 'Using version suffix...'
export $(cat $CMAKE_LISTS | grep -ie 'set *( *VERSION_SUFFIX' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1"="$2}')
export $(echo "$(cat $CMAKE_LISTS | grep -ie 'set *( *VERSION_FULL.*VERSION_SUFFIX' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1"="$2}')" | sed "s/VERSION_MAJOR/$VERSION_MAJOR/" | sed "s/VERSION_MINOR/$VERSION_MINOR/" | sed "s/VERSION_PATCH/$VERSION_PATCH/" | sed "s/VERSION_SUFFIX/$VERSION_SUFFIX/" | tr -d '"{}$')
else
echo 'No version suffix found.'
export $(echo "$(cat $CMAKE_LISTS | grep -ie 'set *( *VERSION_FULL' | grep -ive 'VERSION_SUFFIX' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1"="$2}')" | sed "s/VERSION_MAJOR/$VERSION_MAJOR/" | sed "s/VERSION_MINOR/$VERSION_MINOR/" | sed "s/VERSION_PATCH/$VERSION_PATCH/" | tr -d '"{}$')
fi
EXPECTED="v$VERSION_FULL"
fi
# fail if no expected value was found
if [[ -z "$EXPECTED" ]]; then
echo 'ERROR: Could not determine expected value for version label!'
set +e
echo "EOSIO_ROOT=\"$EOSIO_ROOT\""
echo "CMAKE_CACHE=\"$CMAKE_CACHE\""
echo "CMAKE_LISTS=\"$CMAKE_LISTS\""
echo ''
echo "VERSION_MAJOR=\"$VERSION_MAJOR\""
echo "VERSION_MINOR=\"$VERSION_MINOR\""
echo "VERSION_PATCH=\"$VERSION_PATCH\""
echo "VERSION_SUFFIX=\"$VERSION_SUFFIX\""
echo "VERSION_FULL=\"$VERSION_FULL\""
echo ''
echo '$ cat "$CMAKE_CACHE" | grep "DOXY_EOS_VERSION"'
cat "$CMAKE_CACHE" | grep "DOXY_EOS_VERSION"
echo '$ pwd'
pwd
echo '$ ls -la "$EOSIO_ROOT"'
ls -la "$EOSIO_ROOT"
echo '$ ls -la "$EOSIO_ROOT/build"'
ls -la "$EOSIO_ROOT/build"
exit 1
fi
[[ -z "$BUILDKITE_COMMIT" ]] && VERSION_HASH="$(git rev-parse HEAD 2>/dev/null || :)" || VERSION_HASH=$BUILDKITE_COMMIT
EXPECTED=$EXPECTED-$VERSION_HASH
echo "Expecting \"$EXPECTED\"..."
# get nodeos version
ACTUAL=$($EOSIO_ROOT/build/bin/nodeos --full-version)
EXIT_CODE=$?
# verify 0 exit code explicitly
if [[ $EXIT_CODE -ne 0 ]]; then
echo "Nodeos produced non-zero exit code \"$EXIT_CODE\"."
exit $EXIT_CODE
fi
# test version
if [[ "$EXPECTED" == "$ACTUAL" ]]; then
echo "Passed with \"$ACTUAL\"."
exit 0
fi
echo 'Failed!'
echo "\"$EXPECTED\" != \"$ACTUAL\""
exit 1
64 changes: 64 additions & 0 deletions tests/print-build-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
set -eo pipefail
# The purpose of this test is to ensure that the output of the "nodeos --print-build-info" command.
# This includes verifying valid output in JSON shape and checking parameters (only boost for now).
echo '##### Nodeos Print Build Info Test #####'
# orient ourselves
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/eos/')
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/EOSIO/eosio/')
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/build/' | sed 's,/build/,,')
echo "Using EOSIO_ROOT=\"$EOSIO_ROOT\"."

exec 9>&1 # enable tee to write to STDOUT as a file
PRINT_BUILD_INFO="$EOSIO_ROOT/build/bin/nodeos --print-build-info 2>&1 | tee >(cat - >&9) || :"
echo "$ $PRINT_BUILD_INFO"
OUTPUT="$(eval $PRINT_BUILD_INFO)"

OUTPUT=$(echo "$OUTPUT" | tr -d '\r\n')
OUTPUT=$(echo "$OUTPUT" | sed -E 's/^.+JSON://')
OUTPUT=$(echo "$OUTPUT" | sed -E 's/}.+$/}/')

JQ_OUTPUT=$(echo "$OUTPUT" | jq type)
EXIT_CODE=$?
if [[ "$EXIT_CODE" -ne 0 ]]; then
echo "Not valid JSON type."
exit $EXIT_CODE
fi

V_ARCH=$(echo "$OUTPUT" | jq '.arch')
echo "ARCH: $V_ARCH"
V_BOOST=$(echo "$OUTPUT" | jq '.boost_version')
echo "BOOST_VERSION: $V_BOOST"
V_COMPILER=$(echo "$OUTPUT" | jq '.compiler')
echo "COMPILER: $V_COMPILER"
V_DEBUG=$(echo "$OUTPUT" | jq '.debug')
echo "DEBUG: $V_DEBUG"
V_OS=$(echo "$OUTPUT" | jq '.os')
echo "OS: $V_OS"

if [[ -z "$V_ARCH" || -z "$V_BOOST" || -z "$V_COMPILER" || -z "$V_DEBUG" || -z "$V_OS" ]]; then
echo "Missing expected build info key(s)."
exit 1
fi

if [[ "$PLATFORM_TYPE" == "pinned" ]]; then
if [[ -z "$IMAGE_TAG" ]]; then
echo "Missing IMAGE_TAG variable."
exit 1
fi
FILE=$(ls $EOSIO_ROOT/.cicd/platforms/pinned/$IMAGE_TAG* | head)
BOOST=$(cat $FILE | grep boost | tr -d '\r\n' | sed -E 's/^.+boost_([0-9]+_[0-9]+_[0-9]+).+$/\1/' | head)
BOOST_MAJOR=$(echo $BOOST | sed -E 's/^([0-9])+_[0-9]+_[0-9]+$/\1/')
BOOST_MINOR=$(echo $BOOST | sed -E 's/^[0-9]+_([0-9]+)_[0-9]+$/\1/')
BOOST_PATCH=$(echo $BOOST | sed -E 's/^[0-9]+_[0-9]+_([0-9])+$/\1/')
E_BOOST=$(printf "%d%03d%02d" $BOOST_MAJOR $BOOST_MINOR $BOOST_PATCH)

echo "Verifying boost version: \"$E_BOOST\" == \"$V_BOOST\"."
if [[ "$E_BOOST" != "$V_BOOST" ]]; then
echo "Expected boost version \"$E_BOOST\" does not match actual \"$V_BOOST\"."
exit 1
fi
fi

echo "Validation of build info complete."
exit 0
22 changes: 10 additions & 12 deletions tests/version-label.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/bin/bash
set -eo pipefail
# The purpose of this test is to ensure that the output of the "nodeos --version" command matches the version string defined by our CMake files
# If the environment variable BUILDKITE_TAG is empty or unset, this test will echo success
echo '##### Nodeos Version Label Test #####'
if [[ "$BUILDKITE_TAG" == '' || "$BUILDKITE" != 'true' ]]; then
echo 'This test is only run in Buildkite against tagged builds.'
[[ "$BUILDKITE" != 'true' ]] && echo 'This is not Buildkite.'
[[ "$BUILDKITE_TAG" == '' ]] && echo 'This is not a tagged build.'
echo 'Exiting...'
exit 0
fi
echo 'Tagged build detected, running test.'
# orient ourselves
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/eos/')
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/EOSIO/eosio/')
Expand Down Expand Up @@ -62,10 +54,16 @@ if [[ "$EXPECTED" == '' ]]; then
fi
echo "Expecting \"$EXPECTED\"..."
# get nodeos version
ACTUAL=$($EOSIO_ROOT/build/bin/nodeos --version) || : # nodeos currently returns -1 for --version
# test
ACTUAL=$($EOSIO_ROOT/build/bin/nodeos --version)
EXIT_CODE=$?
# verify 0 exit code explicitly
if [[ $EXIT_CODE -ne 0 ]]; then
echo "Nodeos produced non-zero exit code \"$EXIT_CODE\"."
exit $EXIT_CODE
fi
# test version
if [[ "$EXPECTED" == "$ACTUAL" ]]; then
echo 'Passed with \"$ACTUAL\".'
echo "Passed with \"$ACTUAL\"."
exit 0
fi
echo 'Failed!'
Expand Down