Skip to content

Commit bed5d51

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

File tree

1 file changed

+274
-0
lines changed

1 file changed

+274
-0
lines changed
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
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 =~ [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 2160 /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 2160 /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 2160 /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 2160 /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+
RH_DISTS="almalinux"
201+
if ! [[ $1 =~ [23]\. ]] ; then
202+
RH_DISTS=("almalinux" "centos:7")
203+
fi
204+
for RH_DIST in ${RH_DISTS[@]} ; do
205+
206+
NOBOOLEAN_REPO=""
207+
if [ "$RH_DIST" == "centos:7" ] ; then
208+
NOBOOLEAN_REPO="/noboolean"
209+
fi
210+
211+
# test rpm package startup
212+
213+
echo
214+
rm -f procfifo
215+
mkfifo procfifo
216+
docker run -i -v `pwd`/redhat${NOBOOLEAN_REPO}:/redhat ${RH_DIST} timeout 2160 /bin/bash -c "
217+
( yum install -y ${JDK_RH} procps-ng python3-pip;
218+
rpm -i --nodeps redhat/*.rpm ) 2>&1 >/dev/null ;
219+
cassandra -R -f " 2>&1 >procfifo &
220+
221+
PID=$!
222+
success=false
223+
while read LINE && ! $success ; do
224+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
225+
echo "Redhat package (${RH_DIST} JDK ${JDK}) OK"
226+
kill "$PID"
227+
success=true
228+
fi
229+
done < procfifo
230+
rm -f procfifo
231+
wait "$PID"
232+
if ! $success ; then
233+
echo "Redhat package (${RH_DIST} JDK ${JDK}) FAILED"
234+
fi
235+
236+
# test redhat repository startup
237+
238+
echo
239+
rm -f procfifo
240+
mkfifo procfifo
241+
# 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.
242+
docker run -i ${RH_DIST} timeout 2160 /bin/bash -c "(
243+
echo '[cassandra]' >> /etc/yum.repos.d/cassandra.repo ;
244+
echo 'name=Apache Cassandra' >> /etc/yum.repos.d/cassandra.repo ;
245+
echo 'baseurl=https://dist.apache.org/repos/dist/dev/cassandra/${1}/redhat${NOBOOLEAN_REPO}' >> /etc/yum.repos.d/cassandra.repo ;
246+
echo 'gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
247+
echo 'repo_gpgcheck=1' >> /etc/yum.repos.d/cassandra.repo ;
248+
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' >> /etc/yum.repos.d/cassandra.repo ;
249+
250+
update-crypto-policies --set LEGACY ;
251+
252+
yum install -y ${JDK_RH} ;
253+
yum install -y cassandra ;
254+
255+
cassandra -R -f" 2>&1 >procfifo &
256+
257+
PID=$!
258+
success=false
259+
while read LINE && ! $success ; do
260+
if [[ $LINE =~ "Starting listening for CQL clients on" ]] ; then
261+
echo "Redhat repository (${RH_DIST} JDK ${JDK}) OK"
262+
kill "$PID"
263+
success=true
264+
fi
265+
done < procfifo
266+
rm -f procfifo
267+
wait "$PID"
268+
if ! $success ; then
269+
echo "Redhat repository (${RH_DIST} JDK ${JDK}) FAILED"
270+
fi
271+
done
272+
done
273+
274+
echo "Done."

0 commit comments

Comments
 (0)