Skip to content

Commit 88e8e13

Browse files
Add a script to help verify release checks
1 parent 05a3817 commit 88e8e13

File tree

1 file changed

+265
-0
lines changed

1 file changed

+265
-0
lines changed
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
#!/bin/bash
2+
3+
# Parameters
4+
# $1 release
5+
# $2 maven artefacts url (as specified in the vote email)
6+
#
7+
# 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/`
8+
#
9+
# This script is very basic and experimental. I beg of you to help improve it.
10+
#
11+
12+
###################
13+
# prerequisites
14+
15+
command -v wget >/dev/null 2>&1 || { echo >&2 "wget needs to be installed"; exit 1; }
16+
command -v gpg >/dev/null 2>&1 || { echo >&2 "gpg needs to be installed"; exit 1; }
17+
command -v sha1sum >/dev/null 2>&1 || { echo >&2 "sha1sum needs to be installed"; exit 1; }
18+
command -v md5sum >/dev/null 2>&1 || { echo >&2 "md5sum needs to be installed"; exit 1; }
19+
command -v sha256sum >/dev/null 2>&1 || { echo >&2 "sha256sum needs to be installed"; exit 1; }
20+
command -v sha512sum >/dev/null 2>&1 || { echo >&2 "sha512sum needs to be installed"; exit 1; }
21+
command -v tar >/dev/null 2>&1 || { echo >&2 "tar needs to be installed"; exit 1; }
22+
command -v ant >/dev/null 2>&1 || { echo >&2 "ant needs to be installed"; exit 1; }
23+
command -v timeout >/dev/null 2>&1 || { echo >&2 "timeout needs to be installed"; exit 1; }
24+
command -v docker >/dev/null 2>&1 || { echo >&2 "docker needs to be installed"; exit 1; }
25+
(docker info >/dev/null 2>&1) || { echo >&2 "docker needs to running"; exit 1; }
26+
(java -version 2>&1 | grep -q "1.8") || { echo >&2 "Java 8 must be used"; exit 1; }
27+
(java -version 2>&1 | grep -iq jdk ) || { echo >&2 "Java JDK must be used"; exit 1; }
28+
(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; }
29+
(curl --output /dev/null --silent --head --fail "$2") || { echo >&2 "Not Found: $2"; exit 1; }
30+
31+
###################
32+
33+
mkdir -p /tmp/$1
34+
cd /tmp/$1
35+
echo "Downloading KEYS"
36+
wget -q https://downloads.apache.org/cassandra/KEYS
37+
echo "Downloading $2"
38+
wget -Nqnd -e robots=off --recursive --no-parent $2
39+
echo "Downloading https://dist.apache.org/repos/dist/dev/cassandra/$1/"
40+
wget -Nqe robots=off --recursive --no-parent https://dist.apache.org/repos/dist/dev/cassandra/$1/
41+
42+
echo
43+
echo "====== CHECK RESULTS ======"
44+
echo
45+
46+
gpg --import KEYS
47+
48+
(compgen -G "*.asc" >/dev/null) || { echo >&2 "No *.asc files found in $(pwd)"; exit 1; }
49+
for f in *.asc ; do gpg --verify $f ; done
50+
(compgen -G "*.pom" >/dev/null) || { echo >&2 "No *.pom files found in $(pwd)"; exit 1; }
51+
(compgen -G "*.jar" >/dev/null) || { echo >&2 "No *.jar files found in $(pwd)"; exit 1; }
52+
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
53+
54+
cd dist.apache.org/repos/dist/dev/cassandra/$1
55+
(compgen -G "*.asc" >/dev/null) || { echo >&2 "No *.asc files found in $(pwd)"; exit 1; }
56+
for f in *.asc ; do gpg --verify $f ; done
57+
(compgen -G "*.gz" >/dev/null) || { echo >&2 "No *.gz files found in $(pwd)"; exit 1; }
58+
(compgen -G "*.sha256" >/dev/null) || { echo >&2 "No *.sha256 files found in $(pwd)"; exit 1; }
59+
(compgen -G "*.sha512" >/dev/null) || { echo >&2 "No *.sha512 files found in $(pwd)"; exit 1; }
60+
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
61+
62+
echo
63+
rm -fR apache-cassandra-$1-src
64+
tar -xzf apache-cassandra-$1-src.tar.gz
65+
rm -fR apache-cassandra-$1
66+
tar -xzf apache-cassandra-$1-bin.tar.gz
67+
68+
JDKS="8"
69+
if ! [[ $1 =~ [23]\. ]] ; then
70+
JDKS=("8" "11")
71+
fi
72+
73+
for JDK in ${JDKS[@]} ; do
74+
75+
# test source tarball build
76+
77+
if [ "$JDK" == "11" ] ; then
78+
BUILD_OPT="-Duse.jdk11=true"
79+
fi
80+
echo
81+
rm -f procfifo
82+
mkfifo procfifo
83+
docker run -i -v `pwd`/apache-cassandra-$1-src:/apache-cassandra-$1-src openjdk:${JDK}-jdk-slim-buster timeout 1080 /bin/bash -c "
84+
( apt -qq update;
85+
apt -qq install -y ant build-essential git python procps ) 2>&1 >/dev/null;
86+
cd apache-cassandra-$1-src ;
87+
ant artifacts ${BUILD_OPT}" 2>&1 >procfifo &
88+
89+
PID=$!
90+
success=false
91+
while read LINE && ! $success ; do
92+
if [[ $LINE =~ 'BUILD SUCCESSFUL' ]] ; then
93+
echo "Source build (JDK ${JDK}) OK"
94+
kill "$PID"
95+
success=true
96+
fi
97+
done < procfifo
98+
rm -f procfifo
99+
wait "$PID"
100+
if ! $success ; then
101+
echo "Source build (JDK ${JDK}) FAILED"
102+
fi
103+
104+
# test binary tarball startup
105+
106+
echo
107+
rm -f procfifo
108+
mkfifo procfifo
109+
docker run -i -v `pwd`/apache-cassandra-$1:/apache-cassandra-$1 openjdk:${JDK}-jdk-slim-buster timeout 1080 /bin/bash -c "
110+
( apt -qq update;
111+
apt -qq install -y python python3 procps ) 2>&1 >/dev/null;
112+
apache-cassandra-$1/bin/cassandra -R -f" 2>&1 >procfifo &
113+
114+
PID=$!
115+
success=false
116+
while read LINE && ! $success ; do
117+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
118+
echo "Binary artefact (JDK ${JDK}) OK"
119+
kill "$PID"
120+
success=true
121+
fi
122+
done < procfifo
123+
rm -f procfifo
124+
wait "$PID"
125+
if ! $success ; then
126+
echo "Binary artefact (JDK ${JDK}) FAILED"
127+
fi
128+
129+
# test deb package startup
130+
131+
echo
132+
rm -f procfifo
133+
mkfifo procfifo
134+
docker run -i -v `pwd`/debian:/debian openjdk:${JDK}-jdk-slim-buster timeout 1080 /bin/bash -c "
135+
( apt -qq update ;
136+
apt -qq install -y python python3 procps ;
137+
dpkg --ignore-depends=java7-runtime --ignore-depends=java8-runtime -i debian/*.deb ) 2>&1 >/dev/null ;
138+
CASSANDRA_CONF=file:///etc/cassandra/ HEAP_NEWSIZE=500m MAX_HEAP_SIZE=1g cassandra -R -f" 2>&1 >procfifo &
139+
140+
PID=$!
141+
success=false
142+
while read LINE && ! $success ; do
143+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
144+
echo "Debian package (JDK ${JDK}) OK"
145+
kill "$PID"
146+
success=true
147+
fi
148+
done < procfifo
149+
rm -f procfifo
150+
wait "$PID"
151+
if ! $success ; then
152+
echo "Debian package (JDK ${JDK}) FAILED"
153+
fi
154+
155+
# test deb repository startup
156+
157+
idx=`expr index "$1" -`
158+
if [ $idx -eq 0 ]
159+
then
160+
release_short=${1}
161+
else
162+
release_short=${1:0:$((idx-1))}
163+
fi
164+
debian_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"
165+
166+
echo
167+
rm -f procfifo
168+
mkfifo procfifo
169+
docker run -i openjdk:${JDK}-jdk-slim-buster timeout 1080 /bin/bash -c "
170+
( 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 ;
171+
apt -qq update ;
172+
apt -qq install -y curl gnupg2 ;
173+
apt-key adv --keyserver keyserver.ubuntu.com --recv-key E91335D77E3E87CB ;
174+
curl https://downloads.apache.org/cassandra/KEYS | apt-key add - ;
175+
apt update ;
176+
apt-get install -y cassandra ) 2>&1 >/dev/null ;
177+
cassandra -R -f" 2>&1 >procfifo &
178+
179+
PID=$!
180+
success=false
181+
while read LINE && ! $success ; do
182+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
183+
echo "Debian repository (JDK ${JDK}) OK"
184+
kill "$PID"
185+
success=true
186+
fi
187+
done < procfifo
188+
rm -f procfifo
189+
wait "$PID"
190+
if ! $success ; then
191+
echo "Debian repository (JDK ${JDK}) FAILED"
192+
fi
193+
194+
if [ "$JDK" == "8" ] ; then
195+
JDK_RH="java-1.8.0-openjdk"
196+
elif [ "$JDK" == "11" ] ; then
197+
JDK_RH="java-11-openjdk-devel"
198+
fi
199+
200+
for RH_DIST in "almalinux" "centos:7" ; do
201+
202+
NOBOOLEAN_REPO=""
203+
if [ "$RH_DIST" == "centos:7" ] ; then
204+
NOBOOLEAN_REPO="/noboolean"
205+
fi
206+
207+
# test rpm package startup
208+
209+
echo
210+
rm -f procfifo
211+
mkfifo procfifo
212+
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat ${RH_DIST} timeout 1080 /bin/bash -c "
213+
( yum install -y ${JDK_RH} procps-ng python3-pip;
214+
rpm -i --nodeps redhat/*.rpm ) 2>&1 >/dev/null ;
215+
cassandra -R -f " 2>&1 >procfifo &
216+
217+
PID=$!
218+
success=false
219+
while read LINE && ! $success ; do
220+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
221+
echo "Redhat package (${RH_DIST} JDK ${JDK}) OK"
222+
kill "$PID"
223+
success=true
224+
fi
225+
done < procfifo
226+
rm -f procfifo
227+
wait "$PID"
228+
if ! $success ; then
229+
echo "Redhat package (${RH_DIST} JDK ${JDK}) FAILED"
230+
fi
231+
232+
# test redhat repository startup
233+
234+
echo
235+
rm -f procfifo
236+
mkfifo procfifo
237+
docker run -i ${RH_DIST} timeout 1080 /bin/bash -c "(
238+
echo '[cassandra]' >> /etc/yum.repos.d/cassandra.repo ;
239+
echo 'name=Apache Cassandra' >> /etc/yum.repos.d/cassandra.repo ;
240+
echo 'baseurl=https://dist.apache.org/repos/dist/dev/cassandra/${1}/redhat${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
241+
echo 'gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
242+
echo 'repo_gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
243+
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' >> /etc/yum.repos.d/cassandra.repo ;
244+
245+
yum install -y ${JDK_RH} ;
246+
yum install -y cassandra ) 2>&1 >/dev/null ;
247+
248+
cassandra -R -f" 2>&1 >procfifo &
249+
250+
PID=$!
251+
success=false
252+
while read LINE && ! $success ; do
253+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
254+
echo "Redhat repository (${RH_DIST} JDK ${JDK}) OK"
255+
kill "$PID"
256+
success=true
257+
fi
258+
done < procfifo
259+
rm -f procfifo
260+
wait "$PID"
261+
if ! $success ; then
262+
echo "Redhat repository (${RH_DIST} JDK ${JDK}) FAILED"
263+
fi
264+
done
265+
done

0 commit comments

Comments
 (0)