forked from Percona-QA/package-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_check.sh
executable file
·250 lines (232 loc) · 8.25 KB
/
version_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "This script requires product parameter: ps56, ps57 or ps80!"
echo "Usage: ./version_check.sh <prod>"
exit 1
fi
SCRIPT_PWD=$(cd $(dirname "$0") && pwd)
source "${SCRIPT_PWD}"/VERSIONS
if [ "$1" = "ps56" ]; then
version=${PS56_VER}
release=${PS56_VER#*-}
revision=${PS56_REV}
elif [ "$1" = "ps57" ]; then
version=${PS57_VER}
release=${PS57_VER#*-}
revision=${PS57_REV}
elif [ "$1" = "ps80" ]; then
version=${PS80_VER}
release=${PS80_VER#*-}
revision=${PS80_REV}
elif [ "$1" = "pxc56" ]; then
version=${PXC56_VER%-*}
release=${PXC56_VER#*-}
revision=${PXC56_REV}
innodb_ver=${PXC56_INNODB}
wsrep=${PXC56_WSREP}
elif [ "$1" = "pxc57" ]; then
version=${PXC57_VER%-*}
release=${PXC57_VER#*-}
revision=${PXC57_REV}
innodb_ver=${PXC57_INNODB}
wsrep=${PXC57_WSREP}
elif [ "$1" = "pxc80" ]; then
version=${PXC80_VER%-*}
release=${PXC80_VER#*-}
revision=${PXC80_REV}
innodb_ver=${PXC80_INNODB}
wsrep=${PXC80_WSREP}
elif [ "$1" = "pt" ]; then
version=${PT_VER}
elif [ "$1" = "pxb23" ]; then
version=${PXB23_VER}
elif [ "$1" = "pxb24" ]; then
version=${PXB24_VER}
elif [ "$1" = "pxb80" ]; then
version=${PXB80_VER}
elif [ "$1" = "pmm" ]; then
version=${PMM_VER}
elif [ "$1" = "pmm2" ]; then
version=${PMM2_VER}
elif [ "$1" = "pmm2-rc" ]; then
version=${PMM2_RC_VER}
elif [ "$1" = "proxysql" ]; then
version=${PROXYSQL_VER}
elif [ "$1" = "proxysql2" ]; then
version=${PROXYSQL2_VER}
elif [ "$1" = "sysbench" ]; then
version=${SYSBENCH_VER}
elif [ "$1" = "pbm" ]; then
version=${PBM_VER}
revision=${PBM_REV}
elif [ "$1" = "psmdb34" ]; then
version=${PSMDB34_VER}
elif [ "$1" = "psmdb36" ]; then
version=${PSMDB36_VER}
elif [ "$1" = "psmdb40" ]; then
version=${PSMDB40_VER}
elif [ "$1" = "psmdb42" ]; then
version=${PSMDB42_VER}
elif [ "$1" = "psmdb44" ]; then
version=${PSMDB44_VER}
elif [ "$1" = "psmdb50" ]; then
version=${PSMDB50_VER}
else
echo "Illegal product selected!"
exit 1
fi
product=$1
log="/tmp/${product}_version_check.log"
echo -n > "${log}"
if [ "${product}" = "ps56" -o "${product}" = "ps57" -o "${product}" = "ps80" ]; then
for i in @@INNODB_VERSION @@VERSION; do
if [ "$(mysql -e "SELECT ${i}; "| grep -c "${version}")" = 1 ]; then
echo "${i} is correct" >> "${log}"
else
echo "${i} is incorrect it shows $(mysql -e "SELECT ${i};")"
exit 1
fi
done
if [ "${product}" = "ps56" -o "${product}" = "ps57" ]; then
if [ "$(mysql -e "SELECT @@TOKUDB_VERSION; "| grep -c "${version}")" = 1 ]; then
echo "@@TOKUDB_VERSION is correct" >> "${log}"
else
echo "@@TOKUDB_VERSION is incorrect it shows $(mysql -e "SELECT @@TOKUDB_VERSION;")"
fi
fi
if [ "$(mysql -e "SELECT @@VERSION_COMMENT;" | grep ${revision} | grep -c ${release})" = 1 ]; then
echo "@@VERSION COMMENT is correct" >> "${log}"
else
echo "@@VERSION_COMMENT is incorrect"
exit 1
fi
if [ ${product} = "ps80" ]; then
if [ "$(mysqlsh --version | grep -c ${version})" = 1 ]; then
echo "mysql-shell version is correct" >> "${log}"
else
echo "ERROR: mysql-shell version is incorrect"
exit 1
fi
fi
elif [ ${product} = "pxc56" -o ${product} = "pxc57" -o ${product} = "pxc80" ]; then
for i in @@INNODB_VERSION @@VERSION; do
if [ "$(mysql -e "SELECT ${i}; "| grep -c ${version}-${innodb_ver})" = 1 ]; then
echo "${i} is correct" >> "${log}"
else
echo "${i} is incorrect"
exit 1
fi
done
if [ "$(mysql -e "SELECT @@VERSION_COMMENT;" | grep ${revision} | grep rel${innodb_ver} | grep -c ${release})" = 1 ]; then
echo "@@VERSION COMMENT is correct" >> "${log}"
else
echo "@@VERSION_COMMENT is incorrect"
mysql -e "SELECT @@VERSION_COMMENT;"
exit 1
fi
if [ "$(mysql -e "SHOW STATUS LIKE 'wsrep_provider_version';" | grep -c ${wsrep})" = 1 ]; then
echo "wsrep_provider_version is correct" >> "${log}"
else
echo "wsrep_provider_version is incorrect"
exit 1
fi
elif [ ${product} = "pt" ]; then
for i in `cat /package-testing/pt`; do
version_check=$(${i} --version|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${i} version is not good!"
exit 1
else
echo "${i} version is correct and ${version}" >> "${log}"
fi
done
elif [ ${product} = "pmm" ]; then
version_check=$(pmm-admin --version 2>&1|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
elif [ ${product} = "pmm2" ]; then
version_check=$(pmm-admin --version 2>&1|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
bash -xe ./check_pmm2_client_upgrade.sh ${version}
elif [ ${product} = "pmm2-rc" ]; then
version_check=$(pmm-admin --version 2>&1|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
bash -xe ./check_pmm2_client_upgrade.sh ${version}
elif [ "${product}" = "pxb24" -o "${product}" = "pxb80" ]; then
for binary in xtrabackup xbstream xbcloud xbcrypt; do
version_check=$($binary --version 2>&1| grep -c "${version}")
installed_version=$($binary --version 2>&1|tail -1|awk '{print $3}')
if [ "${version_check}" -eq 0 ]; then
echo "${binary} version is incorrect! Expected version: ${version} Installed version: ${installed_version}"
exit 1
else
echo "${binary} version is correctly displayed as: ${version}" >> "${log}"
fi
done
elif [ ${product} = "proxysql" -o ${product} = "proxysql2" ]; then
version_check=$(proxysql --version 2>&1|grep -c ${version})
installed_version=$(proxysql --version)
if [ ${version_check} -eq 0 ]; then
echo "${product} version ${version} is not good!. Installed version: ${installed_version}"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
elif [ ${product} = "sysbench" ]; then
version_check=$(sysbench --version 2>&1|grep -c ${version})
if [ ${version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
elif [ ${product} = "pbm" ]; then
agent_version_check=$(pbm-coordinator --version 2>&1|grep -oE "Version .*$"|grep -c ${version})
agent_revision_check=$(pbm-coordinator --version 2>&1|grep -oE "Commit .*$"|grep -c ${revision})
coordinator_version_check=$(pbm-coordinator --version 2>&1|grep -oE "Version .*$"|grep -c ${version})
coordinator_revision_check=$(pbm-coordinator --version 2>&1|grep -oE "Commit .*$"|grep -c ${revision})
control_version_check=$(pbmctl version 2>&1|grep -oE "Version .*$"|grep -c ${version})
control_revision_check=$(pbmctl version 2>&1|grep -oE "Commit .*$"|grep -c ${revision})
if [ ${agent_version_check} -eq 0 -o ${coordinator_version_check} -eq 0 -o ${control_version_check} -eq 0 ]; then
echo "${product} version is not good!"
exit 1
else
echo "${product} version is correct and ${version}" >> "${log}"
fi
if [ ${agent_revision_check} -eq 0 -o ${coordinator_revision_check} -eq 0 -o ${control_revision_check} -eq 0 ]; then
echo "${product} revision is not good!"
exit 1
else
echo "${product} revision is correct and ${revision}" >> "${log}"
fi
elif [ ${product} = "psmdb34" -o ${product} = "psmdb36" -o ${product} = "psmdb40" -o ${product} = "psmdb42" -o ${product} = "psmdb44" ]; then
##PSMDB-544
declare -A new_bin_version=(["3.6"]="21" ["4.0"]="22" ["4.2"]="11" ["4.4"]="2")
ver="${version%-*}"; major_ver="${ver%.*}"; minor_ver="${ver##*.}"
binary=(mongo mongod mongos bsondump mongoexport mongofiles mongoimport mongorestore mongotop mongostat)
if (( $minor_ver >= "${new_bin_version[$major_ver]}" )); then
binary+=(mongobridge perconadecrypt)
fi
for binary in ${binary[@]}; do
binary_version_check=$(${binary} --version|head -n1|grep -c "${version}")
if [ ${binary_version_check} -eq 0 ]; then
echo "${product} version is not good for binary ${binary}!"
exit 1
fi
done
fi
echo "${product} versions are OK"