-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathinstall.sh
executable file
·283 lines (236 loc) · 9.66 KB
/
install.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/bash
# Installation script for MyTAP
SQLHOST='localhost';
SQLPORT=3306;
SQLSOCK=''
NOTESTS=0
NOINSTALL=0
FILTER=0
while [[ "${#}" > 0 ]]; do
case ${1} in
-u|--user)
SQLUSER="${2}";
shift
;;
-p|--password)
SQLPASS="${2}"
shift
;;
-h|--host)
SQLHOST="${2}"
shift
;;
-P|--port)
SQLPORT="${2}"
shift
;;
-S|--socket)
SQLSOCK="${2}"
shift
;;
-f|--filter)
NOFILTER=0
FILTER="${2}"
shift
;;
-t|--no-tests)
NOTESTS=1
;;
-i|--no-install)
NOINSTALL=1
;;
-?|--help)
cat << EOF
Usage:
install.sh [options]
Options:
-u, --user string MySQL username
-p, --password string MySQL password
-h, --host name or IP MySQL host
-P, --port name MySQL port
-S, --socket filename MySQL host
-t, --no-tests Don't run the test suite when the install is completed
-i, --no-install Don't perform the installation, i.e. just run the test suite
-f, --filter string Perform the action on one class of objects <matching|eq|moretap|todo|utils|charset|collation|column|constraint|engine|event|index|partition|privilege|role|routines|table|trigger|schemata|user|view>
EOF
exit 1
;;
*)
exit 1
;;
esac;
shift;
done
MYSQLOPTS="--disable-pager --batch --raw --skip-column-names --unbuffered"
if [[ ${SQLUSER} != '' ]] && [[ ${SQLPASS} != '' ]]; then
MYSQLOPTS="${MYSQLOPTS} -u${SQLUSER} -p${SQLPASS}";
fi
if [[ ${SQLSOCK} != '' ]]; then
MYSQLOPTS="${MYSQLOPTS} --socket=${SQLSOCK}";
fi
if [[ ${SQLHOST} != 'localhost' ]]; then
MYSQLOPTS="${MYSQLOPTS} --host=${SQLHOST}";
fi
if [[ ${SQLPORT} != '3306' ]]; then
MYSQLOPTS="${MYSQLOPTS} --port=${SQLPORT}"
fi
MYVER=$(mysql ${MYSQLOPTS} --execute "
SELECT (SUBSTRING_INDEX(VERSION(), '.', 1) * 100000)
+ (SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '.', 2), '.', -1) * 1000)
+ CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1),'.', 3), '.', -1) AS UNSIGNED);
")
MYVARIANT=$(mysql ${MYSQLOPTS} --execute "
SELECT
CASE
WHEN version() REGEXP 'MariaDB' = 1 THEN 'MariaDB'
WHEN version() REGEXP 'Percona' = 1 THEN 'Percona'
ELSE 'MySQL'
END;
")
# checking thread_stack settings. See #44 for reference.
thread_stack=$(mysql ${MYSQLOPTS} --execute "SELECT @@thread_stack" --skip_column_names)
if [[ ${thread_stack} -lt 262144 ]]; then
echo "Your thread_stack variable is set to ${thread_stack} bytes and will"
echo "be too low to use myTAP. You should change the thread_stack variable to"
echo "at least 262144 bytes (add thread_stack=256k to your mysql conf file)."
exit 1
fi
# import the full package before running the tests
# you can't use a wildcard with the source command so all version specific files need
# to be separately listed
if [[ ${NOINSTALL} -eq 0 ]]; then
echo "============= installing myTAP ============="
echo "Importing myTAP base"
mysql ${MYSQLOPTS} --execute 'source ./mytap.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-schemata.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-engine.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-collation.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-charset.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-timezone.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-user.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-event.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-table.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-view.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-column.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-trigger.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-role.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-routines.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-constraint.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-index.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-partition.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-privilege.sql';
if [[ ${MYVER} -ge 506004 ]]; then
echo "Importing Version 5.6.4 patches";
mysql ${MYSQLOPTS} --execute 'source ./mytap-table-564.sql';
fi
if [[ ${MYVER} -ge 507006 ]]; then
echo "Importing Version 5.7.6 patches";
mysql ${MYSQLOPTS} --execute 'source ./mytap-table-576.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-global-576.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-user-576.sql';
fi
if [[ ${MYVER} -ge 800011 ]]; then
echo "Importing Version 8.0.11 patches";
mysql ${MYSQLOPTS} --execute 'source ./mytap-role-8011.sql';
mysql ${MYSQLOPTS} --execute 'source ./mytap-table-8011.sql';
fi
echo "Importing cross-variant compatibility layer";
if [ "${MYVARIANT}" == "MariaDB" ]; then
mysql ${MYSQLOPTS} --execute 'source ./mytap-compat-mariadb.sql';
else
mysql ${MYSQLOPTS} --execute 'source ./mytap-compat-mysql.sql';
fi
fi
if [[ ${NOTESTS} -eq 0 ]]; then
if [[ ${FILTER} != 0 ]]; then
echo "Running test suite with filter: ${FILTER}";
else
echo "Running Full test suite, this will take a couple of minutes to complete."
fi
sleep 2;
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "matching" ]]; then
echo "============= matching ============="
mysql ${MYSQLOPTS} --database tap --execute 'source tests/matching.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "eq" ]]; then
echo "============= eq ============="
mysql ${MYSQLOPTS} --database tap --execute 'source tests/eq.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "moretap" ]]; then
echo "============= moretap ============="
mysql ${MYSQLOPTS} --database tap --execute 'source tests/moretap.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "todotap" ]]; then
echo "============= todotap ============="
mysql ${MYSQLOPTS} --database tap --execute 'source tests/todotap.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "utils" ]]; then
echo "============= utils ============="
mysql ${MYSQLOPTS} --database tap --execute 'source tests/utils.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "charset" ]]; then
echo "============= character sets ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-charset.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "collation" ]]; then
echo "============= collations ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-collation.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "column" ]]; then
echo "============= columns ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-column.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "constraint" ]]; then
echo "============= constraints ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-constraint.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "engine" ]]; then
echo "============= engines ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-engine.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "event" ]]; then
echo "============= events ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-event.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "index" ]]; then
echo "============= indexes ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-index.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "partition" ]]; then
echo "============= partitions ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-partition.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "privilege" ]]; then
echo "============= privileges ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-privilege.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "role" ]]; then
echo "============= role ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-role.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "routines" ]]; then
echo "============= routines ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-routines.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "schemata" ]]; then
echo "============= schemas ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-schemata.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "table" ]]; then
echo "============= tables ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-table.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "trigger" ]]; then
echo "============= triggers ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-trigger.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "user" ]]; then
echo "============= users ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-user.my'
fi
if [[ ${FILTER} == 0 ]] || [[ ${FILTER} =~ "view" ]]; then
echo "============= views ============"
mysql ${MYSQLOPTS} --database tap --execute 'source tests/test-mytap-view.my'
fi
fi
echo "Finished"