Skip to content

Commit

Permalink
Add a script to help verify release checks
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsembwever committed Dec 9, 2022
1 parent 05a3817 commit 4b2f607
Showing 1 changed file with 266 additions and 0 deletions.
266 changes: 266 additions & 0 deletions cassandra-release/cassandra-check-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
#!/bin/bash

# Parameters
# $1 release
# $2 maven artefacts url (as specified in the vote email)
#
# Example use: `./cassandra-check-release.sh 4.0-beta3 https://repository.apache.org/content/repositories/orgapachecassandra-1224/org/apache/cassandra/cassandra-all/4.0-beta3/`
#
# This script is very basic and experimental. I beg of you to help improve it.
#

###################
# prerequisites

command -v wget >/dev/null 2>&1 || { echo >&2 "wget needs to be installed"; exit 1; }
command -v gpg >/dev/null 2>&1 || { echo >&2 "gpg needs to be installed"; exit 1; }
command -v sha1sum >/dev/null 2>&1 || { echo >&2 "sha1sum needs to be installed"; exit 1; }
command -v md5sum >/dev/null 2>&1 || { echo >&2 "md5sum needs to be installed"; exit 1; }
command -v sha256sum >/dev/null 2>&1 || { echo >&2 "sha256sum needs to be installed"; exit 1; }
command -v sha512sum >/dev/null 2>&1 || { echo >&2 "sha512sum needs to be installed"; exit 1; }
command -v tar >/dev/null 2>&1 || { echo >&2 "tar needs to be installed"; exit 1; }
command -v ant >/dev/null 2>&1 || { echo >&2 "ant needs to be installed"; exit 1; }
command -v timeout >/dev/null 2>&1 || { echo >&2 "timeout needs to be installed"; exit 1; }
command -v docker >/dev/null 2>&1 || { echo >&2 "docker needs to be installed"; exit 1; }
(docker info >/dev/null 2>&1) || { echo >&2 "docker needs to running"; exit 1; }
(java -version 2>&1 | grep -q "1.8") || { echo >&2 "Java 8 must be used"; exit 1; }
(java -version 2>&1 | grep -iq jdk ) || { echo >&2 "Java JDK must be used"; exit 1; }
(curl --output /dev/null --silent --head --fail "https://dist.apache.org/repos/dist/dev/cassandra/$1/") || { echo >&2 "Not Found: https://dist.apache.org/repos/dist/dev/cassandra/$1/"; exit 1; }
(curl --output /dev/null --silent --head --fail "$2") || { echo >&2 "Not Found: $2"; exit 1; }

###################

mkdir -p /tmp/$1
cd /tmp/$1
echo "Downloading KEYS"
wget -q https://downloads.apache.org/cassandra/KEYS
echo "Downloading $2"
wget -Nqnd -e robots=off --recursive --no-parent $2
echo "Downloading https://dist.apache.org/repos/dist/dev/cassandra/$1/"
wget -Nqe robots=off --recursive --no-parent https://dist.apache.org/repos/dist/dev/cassandra/$1/

echo
echo "====== CHECK RESULTS ======"
echo

gpg --import KEYS

(compgen -G "*.asc" >/dev/null) || { echo >&2 "No *.asc files found in $(pwd)"; exit 1; }
for f in *.asc ; do gpg --verify $f ; done
(compgen -G "*.pom" >/dev/null) || { echo >&2 "No *.pom files found in $(pwd)"; exit 1; }
(compgen -G "*.jar" >/dev/null) || { echo >&2 "No *.jar files found in $(pwd)"; exit 1; }
for f in *.pom *.jar *.asc ; do echo -n "sha1: " ; echo "$(cat $f.sha1) $f" | sha1sum -c ; echo -n "md5: " ; echo "$(cat $f.md5) $f" | md5sum -c ; done

cd dist.apache.org/repos/dist/dev/cassandra/$1
(compgen -G "*.asc" >/dev/null) || { echo >&2 "No *.asc files found in $(pwd)"; exit 1; }
for f in *.asc ; do gpg --verify $f ; done
(compgen -G "*.gz" >/dev/null) || { echo >&2 "No *.gz files found in $(pwd)"; exit 1; }
(compgen -G "*.sha256" >/dev/null) || { echo >&2 "No *.sha256 files found in $(pwd)"; exit 1; }
(compgen -G "*.sha512" >/dev/null) || { echo >&2 "No *.sha512 files found in $(pwd)"; exit 1; }
for f in *.gz ; do echo -n "sha256: " ; echo "$(cat $f.sha256) $f" | sha256sum -c ; echo -n "sha512:" ; echo "$(cat $f.sha512) $f" | sha512sum -c ; done

echo
rm -fR apache-cassandra-$1-src
tar -xzf apache-cassandra-$1-src.tar.gz
rm -fR apache-cassandra-$1
tar -xzf apache-cassandra-$1-bin.tar.gz

JDKS="8"
if ! [[ $1 =~ [23]\. ]] ; then
JDKS=("8" "11")
fi

for JDK in ${JDKS[@]} ; do

# test source tarball build

if [ "$JDK" == "11" ] ; then
BUILD_OPT="-Duse.jdk11=true"
fi
echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/apache-cassandra-$1-src:/apache-cassandra-$1-src openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
( apt -qq update;
apt -qq install -y ant build-essential git python procps ) 2>&1 >/dev/null;
cd apache-cassandra-$1-src ;
ant artifacts ${BUILD_OPT}" 2>&1 >procfifo &

PID=$!
success=false
while read LINE && ! $success ; do
if [[ $LINE =~ 'BUILD SUCCESSFUL' ]] ; then
echo "Source build (JDK ${JDK}) OK"
kill "$PID"
success=true
fi
done < procfifo
rm -f procfifo
wait "$PID"
if ! $success ; then
echo "Source build (JDK ${JDK}) FAILED"
fi

# test binary tarball startup

echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/apache-cassandra-$1:/apache-cassandra-$1 openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
( apt -qq update;
apt -qq install -y python python3 procps ) 2>&1 >/dev/null;
apache-cassandra-$1/bin/cassandra -R -f" 2>&1 >procfifo &

PID=$!
success=false
while read LINE && ! $success ; do
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
echo "Binary artefact (JDK ${JDK}) OK"
kill "$PID"
success=true
fi
done < procfifo
rm -f procfifo
wait "$PID"
if ! $success ; then
echo "Binary artefact (JDK ${JDK}) FAILED"
fi

# test deb package startup

echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/debian:/debian openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
( apt -qq update ;
apt -qq install -y python python3 procps ;
dpkg --ignore-depends=java7-runtime --ignore-depends=java8-runtime -i debian/*.deb ) 2>&1 >/dev/null ;
CASSANDRA_CONF=file:///etc/cassandra/ HEAP_NEWSIZE=500m MAX_HEAP_SIZE=1g cassandra -R -f" 2>&1 >procfifo &

PID=$!
success=false
while read LINE && ! $success ; do
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
echo "Debian package (JDK ${JDK}) OK"
kill "$PID"
success=true
fi
done < procfifo
rm -f procfifo
wait "$PID"
if ! $success ; then
echo "Debian package (JDK ${JDK}) FAILED"
fi

# test deb repository startup

idx=`expr index "$1" -`
if [ $idx -eq 0 ]
then
release_short=${1}
else
release_short=${1:0:$((idx-1))}
fi
debian_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"

echo
rm -f procfifo
mkfifo procfifo
docker run -i openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
( echo 'deb https://dist.apache.org/repos/dist/dev/cassandra/${1}/debian ${debian_series} main' | tee -a /etc/apt/sources.list.d/cassandra.sources.list ;
apt -qq update ;
apt -qq install -y curl gnupg2 ;
apt-key adv --keyserver keyserver.ubuntu.com --recv-key E91335D77E3E87CB ;
curl https://downloads.apache.org/cassandra/KEYS | apt-key add - ;
apt update ;
apt-get install -y cassandra ) 2>&1 >/dev/null ;
cassandra -R -f" 2>&1 >procfifo &

PID=$!
success=false
while read LINE && ! $success ; do
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
echo "Debian repository (JDK ${JDK}) OK"
kill "$PID"
success=true
fi
done < procfifo
rm -f procfifo
wait "$PID"
if ! $success ; then
echo "Debian repository (JDK ${JDK}) FAILED"
fi

if [ "$JDK" == "8" ] ; then
JDK_RH="java-1.8.0-openjdk"
elif [ "$JDK" == "11" ] ; then
JDK_RH="java-11-openjdk-devel"
fi

for RH_DIST in "almalinux" "centos:7" ; do

NOBOOLEAN_REPO=""
if [ "$RH_DIST" == "centos:7" ] ; then
NOBOOLEAN_REPO="/noboolean"
fi

# test rpm package startup

echo
rm -f procfifo
mkfifo procfifo
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat ${RH_DIST} timeout 2160 /bin/bash -c "
( yum install -y ${JDK_RH} procps-ng python3-pip;
rpm -i --nodeps redhat/*.rpm ) 2>&1 >/dev/null ;
cassandra -R -f " 2>&1 >procfifo &

PID=$!
success=false
while read LINE && ! $success ; do
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
echo "Redhat package (${RH_DIST} JDK ${JDK}) OK"
kill "$PID"
success=true
fi
done < procfifo
rm -f procfifo
wait "$PID"
if ! $success ; then
echo "Redhat package (${RH_DIST} JDK ${JDK}) FAILED"
fi

# test redhat repository startup

echo
rm -f procfifo
mkfifo procfifo
docker run -i ${RH_DIST} timeout 2160 /bin/bash -c "(
echo '[cassandra]' >> /etc/yum.repos.d/cassandra.repo ;
echo 'name=Apache Cassandra' >> /etc/yum.repos.d/cassandra.repo ;
echo 'baseurl=https://dist.apache.org/repos/dist/dev/cassandra/${1}/redhat${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
echo 'gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
echo 'repo_gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' >> /etc/yum.repos.d/cassandra.repo ;
yum install -y ${JDK_RH} ;
yum install -y cassandra ) 2>&1 >/dev/null ;
cassandra -R -f" 2>&1 >procfifo &

PID=$!
success=false
while read LINE && ! $success ; do
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
echo "Redhat repository (${RH_DIST} JDK ${JDK}) OK"
kill "$PID"
success=true
fi
done < procfifo
rm -f procfifo
wait "$PID"
if ! $success ; then
echo "Redhat repository (${RH_DIST} JDK ${JDK}) FAILED"
fi
done
done
echo "Done."

0 comments on commit 4b2f607

Please sign in to comment.