Skip to content

Commit 74f2e6c

Browse files
vaintroubvuvova
authored andcommitted
MDEV-26713 Add test for mysql_install_db creating service, with i18
1 parent 57d5265 commit 74f2e6c

File tree

7 files changed

+117
-0
lines changed

7 files changed

+117
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Check if current user is Windows admin
2+
# Used for testing services with mysql_install_db.exe
3+
# Actual value is set by suite.pm

mysql-test/main/winservice.inc

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
source include/check_windows_admin.inc;
2+
3+
# The test uses return code from sc.exe utility, which are as follows
4+
let $ERROR_SERVICE_DOES_NOT_EXIST= 1060;
5+
let $ERROR_SERVICE_CANNOT_ACCEPT_CTRL=1061;# intermediate, during start or stop
6+
let $ERROR_SERVICE_NOT_ACTIVE=1062;# service stopped
7+
8+
let $sc_exe= C:\Windows\System32\sc.exe;
9+
let $ddir= $MYSQLTEST_VARDIR/tmp/$datadir_name;
10+
let $service_name=$service_name_prefix$MASTER_MYPORT;
11+
12+
13+
error 0,1;
14+
rmdir $ddir;
15+
16+
--disable_result_log
17+
error 0,$ERROR_SERVICE_DOES_NOT_EXIST;
18+
exec $sc_exe delete $service_name;
19+
--enable_result_log
20+
21+
source include/kill_mysqld.inc;
22+
echo # run mysql_install_db with --service parameter;
23+
--disable_result_log
24+
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --port=$MASTER_MYPORT --password=$password --service=$service_name -R;
25+
--enable_result_log
26+
27+
echo # Start service;
28+
--disable_result_log
29+
exec $sc_exe start $service_name;
30+
--enable_result_log
31+
32+
enable_reconnect;
33+
source include/wait_until_connected_again.inc;
34+
disable_reconnect;
35+
36+
echo # Connect with root user password=$password;
37+
connect (con1,localhost,root,$password,mysql);
38+
39+
# Smoke test - check that we're actually using datadir
40+
# we've created (i.e restart_parameters worked)
41+
replace_result $ddir DATADIR;
42+
select @@datadir;
43+
44+
echo # Stop service and wait until it is down;
45+
46+
# stop service
47+
--disable_result_log
48+
exec $sc_exe stop $service_name;
49+
# Wait until stopped
50+
let $sys_errno=0;
51+
while($sys_errno != $ERROR_SERVICE_NOT_ACTIVE)
52+
{
53+
--error 0,$ERROR_SERVICE_CANNOT_ACCEPT_CTRL,$ERROR_SERVICE_NOT_ACTIVE
54+
exec $sc_exe stop $service_name;
55+
if($sys_errno != $ERROR_SERVICE_NOT_ACTIVE)
56+
{
57+
--real_sleep 0.1
58+
}
59+
}
60+
--enable_result_log
61+
62+
echo # Delete service;
63+
let $sys_errno=0;
64+
--disable_result_log
65+
exec $sc_exe delete $service_name;
66+
--enable_result_log
67+
68+
# Cleanup
69+
source include/wait_until_disconnected.inc;
70+
rmdir $ddir;
71+
72+
#restart original server
73+
connection default;
74+
source include/start_mysqld.inc;
75+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Kill the server
2+
# run mysql_install_db with --service parameter
3+
# Start service
4+
# Connect with root user password=password
5+
connect con1,localhost,root,$password,mysql;
6+
select @@datadir;
7+
@@datadir
8+
DATADIR/
9+
# Stop service and wait until it is down
10+
# Delete service
11+
connection default;
12+
# restart

mysql-test/main/winservice_basic.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source include/windows.inc;
2+
let $datadir_name=data;
3+
let $service_name_prefix=mariadb;
4+
let $password=password;
5+
source winservice.inc;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Kill the server
2+
# run mysql_install_db with --service parameter
3+
# Start service
4+
# Connect with root user password=パスワード
5+
connect con1,localhost,root,$password,mysql;
6+
select @@datadir;
7+
@@datadir
8+
DATADIR/
9+
# Stop service and wait until it is down
10+
# Delete service
11+
connection default;
12+
# restart

mysql-test/main/winservice_i18n.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source include/windows.inc;
2+
source include/check_utf8_cli.inc;
3+
4+
let $datadir_name=датадир;
5+
let $service_name_prefix=mariadb_sörvis;
6+
let $password=パスワード;
7+
source winservice.inc;

mysql-test/suite.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ sub skip_combinations {
109109

110110
$skip{'include/no_utf8_cli.inc'} = 'Not tested with utf8 command line support'
111111
unless !utf8_command_line_ok();
112+
113+
$skip{'include/check_windows_admin.inc'} = 'Requires admin privileges'
114+
unless IS_WINDOWS and Win32::IsAdminUser();
112115

113116
%skip;
114117
}

0 commit comments

Comments
 (0)