From 0a34040a5c6fad9ce49b201c71560375fcf5849b Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Mar 2021 12:07:09 -0500 Subject: [PATCH 01/11] Adding test for nodeos option --print-build-info. --- tests/CMakeLists.txt | 4 +++ tests/print-build-info.sh | 68 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100755 tests/print-build-info.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 34770891dd2..3495ce06748 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) @@ -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}) diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh new file mode 100755 index 00000000000..6c75d032f80 --- /dev/null +++ b/tests/print-build-info.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# The purpose of this test is to ensure that the output of the "nodeos --print-build-info" 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/') +[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/build/' | sed 's,/build/,,') +echo "Using EOSIO_ROOT=\"$EOSIO_ROOT\"." +# determine expected value +BUILD_VARS="$EOSIO_ROOT/scripts/.build_vars" +if [[ -f "$BUILD_VARS" ]]; then + echo "Parsing \"$BUILD_VARS\"..." + $(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_MAJOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') + $(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_MINOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') + $(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_PATCH' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') + EXPECTED_BOOST_VERSION=$(printf "%d%03d%02d" $BOOST_VERSION_MAJOR $BOOST_VERSION_MINOR $BOOST_VERSION_PATCH) +else + echo 'No build vars available.' + exit 1 +fi +# fail if no expected value was found +if [[ -z "$BOOST_VERSION_MAJOR" || -z "$BOOST_VERSION_MINOR" || -z "$BOOST_VERSION_PATCH" ]]; then + echo 'ERROR: Could not determine expected value for version label!' + set +e + echo "EOSIO_ROOT=\"$EOSIO_ROOT\"" + echo "BUILD_VARS=\"$BUILD_VARS\"" + echo '' + echo "BOOST_VERSION_MAJOR=\"$BOOST_VERSION_MAJOR\"" + echo "BOOST_VERSION_MINOR=\"$BOOST_VERSION_MINOR\"" + echo "BOOST_VERSION_PATCH=\"$BOOST_VERSION_PATCH\"" + echo "EXPECTED_BOOST_VERSION=\"$EXPECTED_BOOST_VERSION\"" + echo '' + 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 + +OUTPUT=$($EOSIO_ROOT/build/bin/nodeos --print-build-info 2>&1) +if [[ $? -eq 0 ]]; then + echo 'Expected non-zero nodeos exit code.' + exit 1 +fi + +JSON=$(echo $OUTPUT | tr -d '\r\n' | sed 's/^.\+ JSON: \({ .\+ }\).\+$/\1/') +ACTUAL_BOOST_VERSION=$(echo $JSON | sed 's/^.\+"boost_version": \([0-9]\+\).\+$/\1/') + +echo "Expecting boost version \"$EXPECTED_BOOST_VERSION\"..." +if [[ "$EXPECTED_BOOST_VERSION" == "$ACTUAL_BOOST_VERSION" ]]; then + echo "Passed with \"$ACTUAL_BOOST_VERSION\"." + exit 0; +fi + +echo 'Failed!' +echo "\"$EXPECTED_BOOST_VERSION\" != \"$ACTUAL_BOOST_VERSION\"" +exit 1 From ee6e852977b4899b246940bbb9ae9631bf9def6d Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Mar 2021 15:56:57 -0500 Subject: [PATCH 02/11] Run these tests against any builds. --- tests/full-version-label.sh | 70 +++++++++++++++++++++++++++++++++++++ tests/print-build-info.sh | 9 ----- tests/version-label.sh | 9 ----- 3 files changed, 70 insertions(+), 18 deletions(-) create mode 100755 tests/full-version-label.sh diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh new file mode 100755 index 00000000000..4afb8eae0a0 --- /dev/null +++ b/tests/full-version-label.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# 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 +VERSION_HASH=$(grep -Irn version_hash $EOSIO_ROOT/build/libraries/version | grep std::string | sed 's/^.\+"\([a-f0-9]\+\)".\+$/\1/') +if [[ -z "$VERSION_HASH" ]]; then + echo 'No version hash found.' + exit 1 +fi +EXPECTED=$EXPECTED-$VERSION_HASH +echo "Expecting \"$EXPECTED\"..." +# get nodeos version +ACTUAL=$($EOSIO_ROOT/build/bin/nodeos --full-version) +# test +if [[ "$EXPECTED" == "$ACTUAL" ]]; then + echo "Passed with \"$ACTUAL\"." + exit 0 +fi +echo 'Failed!' +echo "\"$EXPECTED\" != \"$ACTUAL\"" +exit 1 diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh index 6c75d032f80..92e97d2e072 100755 --- a/tests/print-build-info.sh +++ b/tests/print-build-info.sh @@ -1,15 +1,6 @@ #!/bin/bash # The purpose of this test is to ensure that the output of the "nodeos --print-build-info" 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/') diff --git a/tests/version-label.sh b/tests/version-label.sh index 008c469d2b8..51ee708d342 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -1,15 +1,6 @@ #!/bin/bash # 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/') From b6dc160f62711880038c95130c523e75f1542f07 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Wed, 10 Mar 2021 17:03:00 -0500 Subject: [PATCH 03/11] Fix version-label tests pass output. --- tests/version-label.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/version-label.sh b/tests/version-label.sh index 51ee708d342..8d04e074cba 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -56,7 +56,7 @@ echo "Expecting \"$EXPECTED\"..." ACTUAL=$($EOSIO_ROOT/build/bin/nodeos --version) || : # nodeos currently returns -1 for --version # test if [[ "$EXPECTED" == "$ACTUAL" ]]; then - echo 'Passed with \"$ACTUAL\".' + echo "Passed with \"$ACTUAL\"." exit 0 fi echo 'Failed!' From 744302e74513bbc7040d100befdff2e67fdb6297 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Mar 2021 09:41:46 -0500 Subject: [PATCH 04/11] Verify that nodeos returns "0" exit code. --- tests/full-version-label.sh | 8 +++++++- tests/version-label.sh | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index 4afb8eae0a0..d72fb43f071 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -60,7 +60,13 @@ EXPECTED=$EXPECTED-$VERSION_HASH echo "Expecting \"$EXPECTED\"..." # get nodeos version ACTUAL=$($EOSIO_ROOT/build/bin/nodeos --full-version) -# test +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 diff --git a/tests/version-label.sh b/tests/version-label.sh index 8d04e074cba..2add83d7ebc 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -53,8 +53,14 @@ 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\"." exit 0 From 6327c33fdaff6e171023b3f4e334633c4a7283eb Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Mar 2021 09:42:14 -0500 Subject: [PATCH 05/11] Simplify how full-version-label test gets the eosio VERSION_HASH. --- tests/full-version-label.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index d72fb43f071..8fc1176d9e4 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -51,7 +51,7 @@ if [[ -z "$EXPECTED" ]]; then ls -la "$EOSIO_ROOT/build" exit 1 fi -VERSION_HASH=$(grep -Irn version_hash $EOSIO_ROOT/build/libraries/version | grep std::string | sed 's/^.\+"\([a-f0-9]\+\)".\+$/\1/') +VERSION_HASH=$BUILDKITE_COMMIT if [[ -z "$VERSION_HASH" ]]; then echo 'No version hash found.' exit 1 From b4453e9c99c29d63285c07b615acdaf10e7107c9 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Mar 2021 11:47:40 -0500 Subject: [PATCH 06/11] Updating print-build-info to get data from pinned build scripts. --- tests/print-build-info.sh | 92 +++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh index 92e97d2e072..b38549fb50a 100755 --- a/tests/print-build-info.sh +++ b/tests/print-build-info.sh @@ -1,59 +1,65 @@ #!/bin/bash -# The purpose of this test is to ensure that the output of the "nodeos --print-build-info" command matches the version string defined by our CMake files -echo '##### Nodeos Version Label Test #####' +# The purpose of this test is to ensure that the output of the "nodeos --print-build-info" command. +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\"." -# determine expected value -BUILD_VARS="$EOSIO_ROOT/scripts/.build_vars" -if [[ -f "$BUILD_VARS" ]]; then - echo "Parsing \"$BUILD_VARS\"..." - $(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_MAJOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') - $(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_MINOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') - $(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_PATCH' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') - EXPECTED_BOOST_VERSION=$(printf "%d%03d%02d" $BOOST_VERSION_MAJOR $BOOST_VERSION_MINOR $BOOST_VERSION_PATCH) -else - echo 'No build vars available.' + +OUTPUT=$($EOSIO_ROOT/build/bin/nodeos --print-build-info 2>&1) +EXIT_CODE=$? +echo "$OUTPUT" +if [[ $EXIT_CODE -eq 0 ]]; then + echo 'Expected non-zero nodeos exit code.' exit 1 fi -# fail if no expected value was found -if [[ -z "$BOOST_VERSION_MAJOR" || -z "$BOOST_VERSION_MINOR" || -z "$BOOST_VERSION_PATCH" ]]; then - echo 'ERROR: Could not determine expected value for version label!' - set +e - echo "EOSIO_ROOT=\"$EOSIO_ROOT\"" - echo "BUILD_VARS=\"$BUILD_VARS\"" - echo '' - echo "BOOST_VERSION_MAJOR=\"$BOOST_VERSION_MAJOR\"" - echo "BOOST_VERSION_MINOR=\"$BOOST_VERSION_MINOR\"" - echo "BOOST_VERSION_PATCH=\"$BOOST_VERSION_PATCH\"" - echo "EXPECTED_BOOST_VERSION=\"$EXPECTED_BOOST_VERSION\"" - echo '' - 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 + +OUTPUT=$(echo "$OUTPUT" | tr -d '\r\n') +OUTPUT=$(echo "$OUTPUT" | sed 's/^.\+JSON://') +OUTPUT=$(echo "$OUTPUT" | sed 's/}.\+$/}/') + +JQ_OUTPUT=$(echo "$OUTPUT" | jq type) +EXIT_CODE=$? +if [[ "$EXIT_CODE" -ne 0 ]]; then + echo "Not valid JSON type." + exit $EXIT_CODE fi -OUTPUT=$($EOSIO_ROOT/build/bin/nodeos --print-build-info 2>&1) -if [[ $? -eq 0 ]]; then - echo 'Expected non-zero nodeos exit code.' +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 -JSON=$(echo $OUTPUT | tr -d '\r\n' | sed 's/^.\+ JSON: \({ .\+ }\).\+$/\1/') -ACTUAL_BOOST_VERSION=$(echo $JSON | sed 's/^.\+"boost_version": \([0-9]\+\).\+$/\1/') +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 's/^.\+boost_\([0-9_]\+\) .\+$/\1/' | head) + BOOST_MAJOR=$(echo $BOOST | sed 's/^\([0-9]\)\+_[0-9]\+_[0-9]\+$/\1/') + BOOST_MINOR=$(echo $BOOST | sed 's/^[0-9]\+_\([0-9]\+\)_[0-9]\+$/\1/') + BOOST_PATCH=$(echo $BOOST | sed 's/^[0-9]\+_[0-9]\+_\([0-9]\)\+$/\1/') + E_BOOST=$(printf "%d%03d%02d" $BOOST_MAJOR $BOOST_MINOR $BOOST_PATCH) -echo "Expecting boost version \"$EXPECTED_BOOST_VERSION\"..." -if [[ "$EXPECTED_BOOST_VERSION" == "$ACTUAL_BOOST_VERSION" ]]; then - echo "Passed with \"$ACTUAL_BOOST_VERSION\"." - exit 0; + 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 'Failed!' -echo "\"$EXPECTED_BOOST_VERSION\" != \"$ACTUAL_BOOST_VERSION\"" -exit 1 +echo "Validation of build info complete." +exit 0 From e4a7c9075d1c935d26d1ca419f08593978765872 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Thu, 11 Mar 2021 17:47:28 -0500 Subject: [PATCH 07/11] Anka fixes for sed weirdness. --- tests/print-build-info.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh index b38549fb50a..ea9fdc448ff 100755 --- a/tests/print-build-info.sh +++ b/tests/print-build-info.sh @@ -16,8 +16,8 @@ if [[ $EXIT_CODE -eq 0 ]]; then fi OUTPUT=$(echo "$OUTPUT" | tr -d '\r\n') -OUTPUT=$(echo "$OUTPUT" | sed 's/^.\+JSON://') -OUTPUT=$(echo "$OUTPUT" | sed 's/}.\+$/}/') +OUTPUT=$(echo "$OUTPUT" | sed -E 's/^.+JSON://') +OUTPUT=$(echo "$OUTPUT" | sed -E 's/}.+$/}/') JQ_OUTPUT=$(echo "$OUTPUT" | jq type) EXIT_CODE=$? @@ -48,10 +48,10 @@ if [[ "$PLATFORM_TYPE" == "pinned" ]]; then exit 1 fi FILE=$(ls $EOSIO_ROOT/.cicd/platforms/pinned/$IMAGE_TAG* | head) - BOOST=$(cat $FILE | grep boost | tr -d '\r\n' | sed 's/^.\+boost_\([0-9_]\+\) .\+$/\1/' | head) - BOOST_MAJOR=$(echo $BOOST | sed 's/^\([0-9]\)\+_[0-9]\+_[0-9]\+$/\1/') - BOOST_MINOR=$(echo $BOOST | sed 's/^[0-9]\+_\([0-9]\+\)_[0-9]\+$/\1/') - BOOST_PATCH=$(echo $BOOST | sed 's/^[0-9]\+_[0-9]\+_\([0-9]\)\+$/\1/') + 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\"." From 79cffb222d3b6047320ab34607d181a4868d6cbe Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Mar 2021 12:46:17 -0500 Subject: [PATCH 08/11] Updates per code review request. --- tests/full-version-label.sh | 6 +----- tests/print-build-info.sh | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index 8fc1176d9e4..663c4e60c59 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -51,11 +51,7 @@ if [[ -z "$EXPECTED" ]]; then ls -la "$EOSIO_ROOT/build" exit 1 fi -VERSION_HASH=$BUILDKITE_COMMIT -if [[ -z "$VERSION_HASH" ]]; then - echo 'No version hash found.' - 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 diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh index ea9fdc448ff..a5d20214338 100755 --- a/tests/print-build-info.sh +++ b/tests/print-build-info.sh @@ -1,5 +1,6 @@ #!/bin/bash # 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/') From e1ddda9cb91573381407f15993649dce11dbabc4 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Fri, 12 Mar 2021 12:46:40 -0500 Subject: [PATCH 09/11] Ensure that Anka Unit Tests have expected flags. --- .cicd/generate-pipeline.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.cicd/generate-pipeline.sh b/.cicd/generate-pipeline.sh index ba9ed3e21b2..9df96b23b0f 100755 --- a/.cicd/generate-pipeline.sh +++ b/.cicd/generate-pipeline.sh @@ -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: From 0a88965efc622f7fad5841daa921dbdbe16e3a6e Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 15 Mar 2021 13:40:43 -0400 Subject: [PATCH 10/11] Set explicit fail on bad command. --- tests/full-version-label.sh | 1 + tests/print-build-info.sh | 12 +++++------- tests/version-label.sh | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index 663c4e60c59..2a988980252 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -1,4 +1,5 @@ #!/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 diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh index a5d20214338..79195e9603d 100755 --- a/tests/print-build-info.sh +++ b/tests/print-build-info.sh @@ -1,4 +1,5 @@ #!/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 #####' @@ -8,13 +9,10 @@ echo '##### Nodeos Print Build Info Test #####' [[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/build/' | sed 's,/build/,,') echo "Using EOSIO_ROOT=\"$EOSIO_ROOT\"." -OUTPUT=$($EOSIO_ROOT/build/bin/nodeos --print-build-info 2>&1) -EXIT_CODE=$? -echo "$OUTPUT" -if [[ $EXIT_CODE -eq 0 ]]; then - echo 'Expected non-zero nodeos exit code.' - exit 1 -fi +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://') diff --git a/tests/version-label.sh b/tests/version-label.sh index 2add83d7ebc..769b8f60c1e 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -1,4 +1,5 @@ #!/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 echo '##### Nodeos Version Label Test #####' # orient ourselves From 19a1268c265aaacf3e6f656ca2d059f7aad83177 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Mon, 15 Mar 2021 15:58:06 -0400 Subject: [PATCH 11/11] Move eosio-resume-from-state documentation into a readme file --- pipeline.jsonc | 1 + 1 file changed, 1 insertion(+) diff --git a/pipeline.jsonc b/pipeline.jsonc index 2c52abae182..b809b704ff3 100644 --- a/pipeline.jsonc +++ b/pipeline.jsonc @@ -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":