-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathbasedir.test
242 lines (201 loc) · 6.95 KB
/
basedir.test
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
# Stariting the server with an --init-file which does shutdown does
# not appear to be working on windows
--source include/not_windows.inc
--echo #
--echo # Testing wl#10441: Add mysqld_safe-functionality to server
--echo #
let $MYSQLD_SOCKET= `SELECT @@socket`;
let $MYSQLD_PORT= `SELECT @@port`;
let $MTR_DATADIR= `SELECT @@datadir`;
let $PLUGIN_DIR= `SELECT @@plugin_dir`;
--echo # Shutdown mysqld which is started by mtr.
--let $_server_id= `SELECT @@server_id`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
--exec echo "wait" > $_expect_file_name
--shutdown_server
--source include/wait_until_disconnected.inc
let MYSQLD_LOG= $MYSQL_TMP_DIR/server.log;
let MYSQLD_OUT= $MYSQL_TMP_DIR/server.out;
let DDIR= $MYSQL_TMP_DIR/basedir_test;
let SHUTDOWN_SQL= $MYSQL_TMP_DIR/shutdown.sql;
# Need to save this as PWD env var is overriden when invoking perl
let BDIR= $PWD;
let DEFARGS= --no-defaults --plugin-dir=$PLUGIN_DIR --innodb_dedicated_server=OFF --explicit_defaults_for_timestamp --socket=$MYSQLD_SOCKET --port=$MYSQLD_PORT --tls-version= --secure-file-priv="" --datadir=$DDIR --skip-mysqlx;
let INIT_FILE_ARGS= $DEFARGS --log-error=$MYSQLD_LOG --init-file=$SHUTDOWN_SQL;
let INIT_FILE_ARGS_D= --no-defaults --plugin-dir=$PLUGIN_DIR --innodb_dedicated_server=OFF --explicit_defaults_for_timestamp --socket=$MYSQLD_SOCKET --port=$MYSQLD_PORT --skip-mysqlx --tls-version= --secure-file-priv="" --datadir=$MTR_DATADIR -D --log-error=$MYSQLD_LOG;
write_file $SHUTDOWN_SQL;
SHUTDOWN;
EOF
--echo # Run -I on a new datadir
--exec $MYSQLD $DEFARGS -I --log-error=$MYSQLD_LOG
--echo #
--echo # Deduce --basedir when using full path to mysqld
--exec $MYSQLD $INIT_FILE_ARGS
--perl
use strict;
my $mysqld_log= $ENV{'MYSQLD_LOG'};
open(MYSQLD_LOG, $mysqld_log) || die "Failed to open '$mysqld_log': $!";
print "# Look for [ERROR] in error log (there should be none):\n";
while(<MYSQLD_LOG>)
{
if (/ERROR/) { print; }
}
close(MYSQLD_LOG);
EOF
--remove_file $MYSQLD_LOG
--echo #
--echo # Deduce --basedir when using path relative to CWD
--perl
use strict;
my $bdir= $ENV{'BDIR'};
my $mysqld_log= $ENV{'MYSQLD_LOG'};
chdir $bdir;
my $binary= $ENV{'MYSQLD'};
$binary =~ s|$bdir/||;
my $init_file_args= $ENV{'INIT_FILE_ARGS'};
(system("$binary $init_file_args") == 0) ||
die "system failed on '$binary $init_file_args': $!";
open(MYSQLD_LOG, $ENV{'MYSQLD_LOG'}) ||
die "Failed to open '$mysqld_log': $!";
print "# Look for [ERROR] in error log (there should be none):\n";
while(<MYSQLD_LOG>)
{
if (/ERROR/) { print; }
}
close(MYSQLD_LOG);
EOF
--remove_file $MYSQLD_LOG
--echo #
--echo # Deduce --basedir when using bare executable name (PATH lookup)
--perl
use strict;
use File::Basename;
my $bdir= $ENV{'BDIR'};
chdir $bdir;
my $bindir= dirname($ENV{'MYSQLD'});
$ENV{'PATH'}="$bindir:$ENV{'PATH'}";
my $init_file_args= $ENV{'INIT_FILE_ARGS'};
my $binary= $ENV{'MYSQLD'};
$binary =~ s|$bdir/||;
(system("$binary $init_file_args") == 0) ||
die "system failed on 'mysqld $init_file_args': $!";
my $mysqld_log= $ENV{'MYSQLD_LOG'};
open(MYSQLD_LOG, $mysqld_log) || die "Failed to open '$mysqld_log': $!";
print "# Look for [ERROR] in error log (there should be none):\n";
while(<MYSQLD_LOG>)
{
if (/ERROR/) { print; }
}
close(MYSQLD_LOG);
EOF
--remove_file $MYSQLD_LOG
--echo #
--echo # Try invalid --log-error
--error 1,2
--exec $MYSQLD $DEFARGS --log-error=$MYSQL_TMP_DIR/no_such_dir/bad_err_log.err >$MYSQLD_OUT 2>&1
--echo # Look for expected error in output:
--perl
use strict;
my $mysqld_out= $ENV{'MYSQLD_OUT'};
open(MYSQLD_OUT, $mysqld_out) || die "Failed to open '$mysqld_out': $!";
my $found_expected_error= 0;
while(<MYSQLD_OUT>)
{
if (/\[ERROR\] \[[^]]*\] \[[^]]*\] Could not open .+ for error logging/)
{
print "# Found expected error\n";
$found_expected_error= 1;
}
}
if (!$found_expected_error) {
seek(MYSQLD_OUT, 0, 0) || die "Failed to rewind FH for '$mysqld_out': $!";
while(<MYSQLD_OUT>) { print; }
}
close(MYSQLD_OUT);
EOF
--echo #
--echo # Try -D as shortcut for --daemonize option with invalid --log-error
--error 1,2
--exec $MYSQLD $DEFARGS -D --log-error=$MYSQL_TMP_DIR/no_such_dir/bad_err_log.err >$MYSQLD_OUT 2>&1
--echo # Look for expected errors in output from launcher and daemon:
--perl
use strict;
my $mysqld_out= $ENV{'MYSQLD_OUT'};
open(MYSQLD_OUT, $mysqld_out) || die "Failed to open '$mysqld_out': $!";
my $found_expected_errors= 0;
while(<MYSQLD_OUT>)
{
if (/\[ERROR\] \[[^]]*\] \[[^]]*\] Could not open .+ for error logging/)
{
print "# Found expected error from launcher process\n";
++$found_expected_errors;
}
if (/\[ERROR\] \[[^]]*\] \[[^]]*\] Failed to start mysqld daemon\. Check mysqld error log\./)
{
print "# Found expected error from daemon process\n";
++$found_expected_errors;
}
}
if ($found_expected_errors < 2) {
seek(MYSQLD_OUT, 0, 0) || die "Failed to rewind FH for '$mysqld_out': $!";
}
close(MYSQLD_OUT);
EOF
--echo #
--echo # Try using -D with relative path
--perl
use strict;
use File::Basename;
my $mysqld= $ENV{'MYSQLD'};
my $mysql_tmp_dir= $ENV{'MYSQL_TMP_DIR'};
my $init_file_args_d= $ENV{'INIT_FILE_ARGS_D'};
my $mysqld_out= $ENV{'MYSQLD_OUT'};
chdir($mysql_tmp_dir) || die "# Could not chdir to '$mysql_tmp_dir': $!";
(system("$mysqld $init_file_args_d >$mysqld_out 2>&1") == 0) ||
die "system failed on '$mysqld $init_file_args_d': $!";
my $mysqld_log= $ENV{'MYSQLD_LOG'};
open(MYSQLD_LOG, $mysqld_log) || die "Failed to open '$mysqld_log': $!";
print "# Look for [ERROR] in error log (there should be none):\n";
while(<MYSQLD_LOG>)
{
if (/ERROR/) { print; }
}
close(MYSQLD_LOG);
open(MYSQLD_OUT, $mysqld_out) || die "Failed to open '$mysqld_out': $!";
print "# Look for output (there should be none):\n";
print "# Supressing output for initialize:\n";
print "# Supressing output for server shutdown\n";
while(<MYSQLD_OUT>)
{
if (!(/initializing of server has completed/) &&
!(/Invalid systemd notify socket, cannot send:/) &&
!(/MySQL Server - end./)) {
print;
}
}
close(MYSQLD_OUT);
EOF
--echo # Wait for daemon server to start
--source include/wait_until_connected_again.inc
--echo # Execute a query to see that it is running OK
SHOW DATABASES;
--echo # Shutdown daemon
--let $_daemon_id= `SELECT @@server_id`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_daemon_id.expect
--exec echo "wait" > $_expect_file_name
--shutdown_server
--echo # Wait until daemon is gone
--source include/wait_until_disconnected.inc
--echo #
--echo # Cleanup
--echo #
--remove_file $MYSQLD_OUT
--remove_file $MYSQLD_LOG
--remove_file $SHUTDOWN_SQL
--force-rmdir $DDIR
--echo #
--echo # Restart mysqld of mtr
--echo #
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/wait_until_connected_again.inc
--source include/xplugin_wait_for_interfaces.inc