From 1a19c1ab90be637e0969f64a535b4acc26532b1d Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Tue, 14 May 2019 14:32:24 -0400 Subject: [PATCH 1/2] Created "version-label" Integration Test --- tests/CMakeLists.txt | 2 ++ tests/version-label.sh | 73 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 tests/version-label.sh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 66a826fa0e6..58ef93a8b2b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -43,6 +43,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_voting_test.py ${CMAKE_CURRENT 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}/version-label.sh ${CMAKE_CURRENT_BINARY_DIR}/version-label.sh COPYONLY) #To run plugin_test with all log from blockchain displayed, put --verbose after --, i.e. plugin_test -- --verbose add_test(NAME plugin_test COMMAND plugin_test --report_level=detailed --color_output) @@ -78,6 +79,7 @@ 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 version-label-test COMMAND tests/version-label.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/version-label.sh b/tests/version-label.sh new file mode 100755 index 00000000000..463122cf405 --- /dev/null +++ b/tests/version-label.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# The purpose of this test is to ensure that the output of the "nodeos --version" command matches the +# 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 +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 [[ "$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 +echo "Expecting \"$EXPECTED\"..." +# get nodeos version +ACTUAL=$($EOSIO_ROOT/build/bin/nodeos --version) || : # nodeos currently returns -1 for --version +# test +if [[ "$EXPECTED" == "$ACTUAL" ]]; then + echo 'Passed with \"$ACTUAL\".' + exit 0 +fi +echo 'Failed!' +echo "\"$EXPECTED\" != \"$ACTUAL\"" +exit 1 \ No newline at end of file From 6961e03a829ca59e6062fd85b6715b9ecb532303 Mon Sep 17 00:00:00 2001 From: Zach <34947245+kj4ezj@users.noreply.github.com> Date: Tue, 14 May 2019 19:13:49 -0400 Subject: [PATCH 2/2] Finish test purpose comment --- tests/version-label.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/version-label.sh b/tests/version-label.sh index 463122cf405..008c469d2b8 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -1,5 +1,5 @@ #!/bin/bash -# The purpose of this test is to ensure that the output of the "nodeos --version" command matches the +# 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 @@ -70,4 +70,4 @@ if [[ "$EXPECTED" == "$ACTUAL" ]]; then fi echo 'Failed!' echo "\"$EXPECTED\" != \"$ACTUAL\"" -exit 1 \ No newline at end of file +exit 1