Skip to content

Commit 5996107

Browse files
Add a script to help verify release checks
1 parent 666bd35 commit 5996107

File tree

1 file changed

+283
-0
lines changed

1 file changed

+283
-0
lines changed
Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
#!/bin/bash
2+
3+
# Parameters
4+
# $1 release
5+
# $2 maven artefacts url number (as specified in the vote email)
6+
#
7+
# Example use: `./cassandra-check-release.sh 4.0-beta3 1224
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 "https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1") || { echo >&2 "Not Found: https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1"; 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 https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1"
38+
wget -Nqnd -e robots=off --recursive --no-parent https://repository.apache.org/content/repositories/orgapachecassandra-$2/org/apache/cassandra/cassandra-all/$1
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 =~ [4]\. ]] ; then
70+
JDKS=("8" "11")
71+
elif [[ $1 =~ [5]\. ]] ; then
72+
JDKS=("11" "17")
73+
fi
74+
75+
for JDK in ${JDKS[@]} ; do
76+
77+
# test source tarball build
78+
79+
if [ "$JDK" == "11" ] ; then
80+
BUILD_OPT="-Duse.jdk11=true"
81+
fi
82+
echo
83+
rm -f procfifo
84+
mkfifo procfifo
85+
docker run -i -v `pwd`/apache-cassandra-$1-src:/apache-cassandra-$1-src openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
86+
( apt -qq update;
87+
apt -qq install -y ant build-essential git python procps ) 2>&1 >/dev/null;
88+
cd apache-cassandra-$1-src ;
89+
ant artifacts ${BUILD_OPT}" 2>&1 >procfifo &
90+
91+
PID=$!
92+
success=false
93+
while read LINE && ! $success ; do
94+
if [[ $LINE =~ 'BUILD SUCCESSFUL' ]] ; then
95+
echo "Source build (JDK ${JDK}) OK"
96+
kill "$PID"
97+
success=true
98+
fi
99+
done < procfifo
100+
rm -f procfifo
101+
wait "$PID"
102+
if ! $success ; then
103+
echo "Source build (JDK ${JDK}) FAILED"
104+
fi
105+
106+
# test binary tarball startup
107+
108+
echo
109+
rm -f procfifo
110+
mkfifo procfifo
111+
docker run -i -v `pwd`/apache-cassandra-$1:/apache-cassandra-$1 openjdk:${JDK}-jdk-slim-buster timeout 2160 /bin/bash -c "
112+
( apt -qq update;
113+
apt -qq install -y python python3 procps ) 2>&1 >/dev/null;
114+
apache-cassandra-$1/bin/cassandra -R -f" 2>&1 >procfifo &
115+
116+
PID=$!
117+
success=false
118+
while read LINE && ! $success ; do
119+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
120+
echo "Binary artefact (JDK ${JDK}) OK"
121+
kill "$PID"
122+
success=true
123+
fi
124+
done < procfifo
125+
rm -f procfifo
126+
wait "$PID"
127+
if ! $success ; then
128+
echo "Binary artefact (JDK ${JDK}) FAILED"
129+
fi
130+
131+
# test deb package startup
132+
if [ "$JDK" == "8" ] ; then
133+
DEBIAN_IMAGE="openjdk:8-jdk-slim-buster"
134+
else
135+
DEBIAN_IMAGE="debian:bullseye-slim"
136+
fi
137+
138+
echo
139+
rm -f procfifo
140+
mkfifo procfifo
141+
docker run -i -v `pwd`/debian:/debian ${DEBIAN_IMAGE} timeout 2160 /bin/bash -c "
142+
( apt -qq update ;
143+
apt -qq install -y python ; # will silently fail on debian latest
144+
apt -qq install -y python3 procps ;
145+
apt -qq install -y openjdk-${JDK}-jre-headless ; # will silently fail on *jdk-slim-buster
146+
dpkg --ignore-depends=java7-runtime --ignore-depends=java8-runtime -i debian/*.deb ) 2>&1 >/dev/null ;
147+
CASSANDRA_CONF=file:///etc/cassandra/ HEAP_NEWSIZE=500m MAX_HEAP_SIZE=1g cassandra -R -f" 2>&1 >procfifo &
148+
149+
PID=$!
150+
success=false
151+
while read LINE && ! $success ; do
152+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
153+
echo "Debian package (JDK ${JDK}) OK"
154+
kill "$PID"
155+
success=true
156+
fi
157+
done < procfifo
158+
rm -f procfifo
159+
wait "$PID"
160+
if ! $success ; then
161+
echo "Debian package (JDK ${JDK}) FAILED"
162+
fi
163+
164+
# test deb repository startup
165+
166+
idx=`expr index "$1" -`
167+
if [ $idx -eq 0 ]
168+
then
169+
release_short=${1}
170+
else
171+
release_short=${1:0:$((idx-1))}
172+
fi
173+
debian_series="$(echo ${release_short} | cut -d '.' -f 1)$(echo ${release_short} | cut -d '.' -f 2)x"
174+
175+
echo
176+
rm -f procfifo
177+
mkfifo procfifo
178+
docker run -i ${DEBIAN_IMAGE} timeout 2160 /bin/bash -c "
179+
( 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 ;
180+
apt -qq update ;
181+
apt -qq install -y curl gnupg2 ;
182+
apt-key adv --keyserver keyserver.ubuntu.com --recv-key E91335D77E3E87CB ;
183+
curl https://downloads.apache.org/cassandra/KEYS | apt-key add - ;
184+
apt update ;
185+
apt-get install -y cassandra ) 2>&1 >/dev/null ;
186+
cassandra -R -f" 2>&1 >procfifo &
187+
188+
PID=$!
189+
success=false
190+
while read LINE && ! $success ; do
191+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
192+
echo "Debian repository (JDK ${JDK}) OK"
193+
kill "$PID"
194+
success=true
195+
fi
196+
done < procfifo
197+
rm -f procfifo
198+
wait "$PID"
199+
if ! $success ; then
200+
echo "Debian repository (JDK ${JDK}) FAILED"
201+
fi
202+
203+
if [ "$JDK" == "8" ] ; then
204+
JDK_RH="java-1.8.0-openjdk"
205+
else
206+
JDK_RH="java-${JDK}-openjdk-devel"
207+
fi
208+
209+
RH_DISTS="almalinux"
210+
if ! [[ $1 =~ [23]\. ]] ; then
211+
RH_DISTS=("almalinux" "centos:7")
212+
fi
213+
for RH_DIST in ${RH_DISTS[@]} ; do
214+
215+
NOBOOLEAN_REPO=""
216+
if [ "$RH_DIST" == "centos:7" ] ; then
217+
NOBOOLEAN_REPO="/noboolean"
218+
fi
219+
220+
# test rpm package startup
221+
222+
echo
223+
rm -f procfifo
224+
mkfifo procfifo
225+
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat ${RH_DIST} timeout 2160 /bin/bash -c "
226+
( yum install -y ${JDK_RH} procps-ng python3-pip;
227+
rpm -i --nodeps redhat/*.rpm ) 2>&1 >/dev/null ;
228+
cassandra -R -f " 2>&1 >procfifo &
229+
230+
PID=$!
231+
success=false
232+
while read LINE && ! $success ; do
233+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
234+
echo "Redhat package (${RH_DIST} JDK ${JDK}) OK"
235+
kill "$PID"
236+
success=true
237+
fi
238+
done < procfifo
239+
rm -f procfifo
240+
wait "$PID"
241+
if ! $success ; then
242+
echo "Redhat package (${RH_DIST} JDK ${JDK}) FAILED"
243+
fi
244+
245+
# test redhat repository startup
246+
247+
echo
248+
rm -f procfifo
249+
mkfifo procfifo
250+
# yum repo installation failing due to a legacy (SHA1) third-party sig in our KEYS file, hence use of update-crypto-policies. Impacts all rhel9+ users.
251+
docker run -i ${RH_DIST} timeout 2160 /bin/bash -c "(
252+
echo '[cassandra]' >> /etc/yum.repos.d/cassandra.repo ;
253+
echo 'name=Apache Cassandra' >> /etc/yum.repos.d/cassandra.repo ;
254+
echo 'baseurl=https://dist.apache.org/repos/dist/dev/cassandra/${1}/redhat${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
255+
echo 'gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
256+
echo 'repo_gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
257+
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' >> /etc/yum.repos.d/cassandra.repo ;
258+
259+
update-crypto-policies --set LEGACY ;
260+
261+
yum install -y ${JDK_RH} ;
262+
yum install -y cassandra ) 2>&1 >/dev/null ;
263+
264+
cassandra -R -f" 2>&1 >procfifo &
265+
266+
PID=$!
267+
success=false
268+
while read LINE && ! $success ; do
269+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
270+
echo "Redhat repository (${RH_DIST} JDK ${JDK}) OK"
271+
kill "$PID"
272+
success=true
273+
fi
274+
done < procfifo
275+
rm -f procfifo
276+
wait "$PID"
277+
if ! $success ; then
278+
echo "Redhat repository (${RH_DIST} JDK ${JDK}) FAILED"
279+
fi
280+
done
281+
done
282+
283+
echo "Done."

0 commit comments

Comments
 (0)