Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/release/common/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ then
exit 1
fi

cd go-algorand
COMMIT_HASH=$(git rev-parse "${BRANCH}")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capture the commit hash which we'll use later in the test utility to check against the stdout of algod -v.

export DEBIAN_FRONTEND=noninteractive

# Install latest go.1.12.9.
Expand Down Expand Up @@ -130,6 +133,7 @@ PLATFORM_SPLIT=(${PLATFORM//\// })
cat << EOF > "${HOME}"/build_env
export BRANCH=${BRANCH}
export CHANNEL=$("${GOPATH}"/src/github.com/algorand/go-algorand/scripts/compute_branch_channel.sh "${BRANCH}")
export COMMIT_HASH=${COMMIT_HASH}
export DEFAULTNETWORK=$(PATH=${PATH} "${REPO_ROOT}"/scripts/compute_branch_network.sh)
export DC_IP=$(curl --silent http://169.254.169.254/latest/meta-data/local-ipv4)
export FULLVERSION=$("${GOPATH}"/src/github.com/algorand/go-algorand/scripts/compute_build_number.sh -f)
Expand Down
7 changes: 7 additions & 0 deletions scripts/release/test/stage/test/task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ date "+build_release done testing ubuntu %Y%m%d_%H%M%S"
"${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/test/rpm/run_centos.sh
date "+build_release done testing centos %Y%m%d_%H%M%S"

echo Use Docker to perform a smoke test.
pushd "${HOME}"/go/src/github.com/algorand/go-algorand/scripts/release/test/util
# Copy all packages to the same directory where the Dockerfile will reside.
cp "${HOME}"/node_pkg/* .
./test_package.sh
popd

echo
date "+build_release end TEST stage %Y%m%d_%H%M%S"
echo
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/usr/bin/env bash

set -ex

# This is currently used by `test_package.sh`.
# It is copied into a docker image at build time and then invoked at run time.

GREEN_FG=$(tput setaf 2 2>/dev/null)
RED_FG=$(tput setaf 1 2>/dev/null)
YELLOW_FG=$(tput setaf 3 2>/dev/null)
END_FG_COLOR=$(tput sgr0 2>/dev/null)

BRANCH=
CHANNEL=stable
HASH=
RELEASE=
CHANNEL=
COMMIT_HASH=
FULLVERSION=

while [ "$1" != "" ]; do
case "$1" in
Expand All @@ -25,11 +22,11 @@ while [ "$1" != "" ]; do
;;
-h)
shift
HASH="$1"
COMMIT_HASH="$1"
;;
-r)
shift
RELEASE="$1"
FULLVERSION="$1"
;;
*)
echo "Unknown option" "$1"
Expand All @@ -39,9 +36,9 @@ while [ "$1" != "" ]; do
shift
done

if [ -z "$BRANCH" ] || [ -z "$HASH" ] || [ -z "$RELEASE" ]
if [ -z "$BRANCH" ] || [ -z "$CHANNEL" ] || [ -z "$COMMIT_HASH" ] || [ -z "$FULLVERSION" ]
then
echo "$YELLOW_FG[Usage]$END_FG_COLOR $0 -b BRANCH -c CHANNEL -h HASH -r RELEASE"
echo "[ERROR] $0 -b $BRANCH -c $CHANNEL -h $COMMIT_HASH -r $FULLVERSION"
exit 1
fi

Expand All @@ -54,20 +51,20 @@ else
fi

STR=$(algod -v)
SHORT_HASH=${HASH:0:8}
SHORT_HASH=${COMMIT_HASH:0:8}

# We're looking for a line that looks like the following:
#
# 2.0.4.stable [rel/stable] (commit #729b125a)
#
# Since we're passing in the full hash, we won't using the closing paren.
# Use a regex over the multi-line string.
if [[ "$STR" =~ .*"$RELEASE.$CHANNEL [$BRANCH] (commit #$SHORT_HASH)".* ]]
if [[ "$STR" =~ .*"$FULLVERSION.$CHANNEL [$BRANCH] (commit #$SHORT_HASH)".* ]]
then
echo -e "$GREEN_FG[$0]$END_FG_COLOR The result of \`algod -v\` is a correct match.\n$STR"
echo -e "[$0] The result of \`algod -v\` is a correct match.\n$STR"
exit 0
fi

echo "$RED_FG[$0]$END_FG_COLOR The result of \`algod -v\` is an incorrect match."
echo "[$0] The result of \`algod -v\` is an incorrect match."
exit 1

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env bash
# shellcheck disable=1090

# TODO: use `trap` instead of cleanup function?

GREEN_FG=$(tput setaf 2 2>/dev/null)
RED_FG=$(tput setaf 1 2>/dev/null)
TEAL_FG=$(tput setaf 6 2>/dev/null)
YELLOW_FG=$(tput setaf 3 2>/dev/null)
END_FG_COLOR=$(tput sgr0 2>/dev/null)
set -ex

. "${HOME}"/build_env

# TODO: The following error happens on centos:8
#
Expand All @@ -24,41 +23,11 @@ OS_LIST=(
ubuntu:18.04
)

BRANCH=
CHANNEL=stable
HASH=
RELEASE=
FAILED=()

while [ "$1" != "" ]; do
case "$1" in
-b)
shift
BRANCH="$1"
;;
-c)
shift
CHANNEL="$1"
;;
-h)
shift
HASH="$1"
;;
-r)
shift
RELEASE="$1"
;;
*)
echo "$RED_FG[$0]$END_FG_COLOR Unknown option $1"
exit 1
;;
esac
shift
done

if [ -z "$BRANCH" ] || [ -z "$HASH" ] || [ -z "$RELEASE" ]
if [ -z "$BRANCH" ] || [ -z "$CHANNEL" ] || [ -z "$COMMIT_HASH" ] || [ -z "$FULLVERSION" ]
then
echo "$YELLOW_FG[Usage]$END_FG_COLOR $0 -b BRANCH -c CHANNEL -h HASH -r RELEASE"
echo "[ERROR] $0 was not provided with BRANCH, CHANNEL, COMMIT_HASH or FULLVERSION!"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the CHANNEL still need to be here ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's needed to check the result of algod -v:

if [[ "$STR" =~ .*"$FULLVERSION.$CHANNEL [$BRANCH] (commit #$SHORT_HASH)".* ]]
then
    echo -e "[$0] The result of \`algod -v\` is a correct match.\n$STR"
    exit 0
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that's the case, why you're not testing for it's existence on the if line ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. I had a default value set before that I since removed. I'll add the CHANNEL to the if conditional.

exit 1
fi

Expand All @@ -69,8 +38,8 @@ build_images () {
FROM {{OS}}

WORKDIR /root
COPY pkg/* /root/
COPY smoke_test.sh .
# It's easier just to copy all contents into the container.
COPY . .
CMD ["/bin/bash"]
EOF

Expand All @@ -91,8 +60,8 @@ EOF
run_images () {
for item in ${OS_LIST[*]}
do
echo "$TEAL_FG[$0]$END_FG_COLOR Running ${item}-test..."
if ! docker run --rm --name algorand -t "${item}-smoke-test" bash smoke_test.sh -b "$BRANCH" -c "$CHANNEL" -h "$HASH" -r "$RELEASE"
echo "[$0] Running ${item}-test..."
if ! docker run --rm --name algorand -t "${item}-smoke-test" bash smoke_test.sh -b "$BRANCH" -c "$CHANNEL" -h "$COMMIT_HASH" -r "$FULLVERSION"
then
FAILED+=("$item")
fi
Expand All @@ -106,7 +75,7 @@ cleanup() {
check_failures() {
if [ "${#FAILED[@]}" -gt 0 ]
then
echo -e "\n$RED_FG[$0]$END_FG_COLOR The following images could not be $1:"
echo -e "\n[$0] The following images could not be $1:"

for failed in ${FAILED[*]}
do
Expand All @@ -122,11 +91,11 @@ check_failures() {

build_images
check_failures built
echo "$GREEN_FG[$0]$END_FG_COLOR All builds completed with no failures."
echo "[$0] All builds completed with no failures."

run_images
check_failures verified
echo "$GREEN_FG[$0]$END_FG_COLOR All runs completed with no failures."
echo "[$0] All runs completed with no failures."

cleanup