MDEV-36127 Add MTR test for mariadb-upgrade-service on Windows
Added a test to verify mariadb-upgrade-service functionality on Windows. The test runs mariadb-install-db.exe to create a Windows service, then executes mariadb-upgrade-service.exe while the service is online or offline. There is no real cross-version upgrade in this test(not possible with MTR), the actual goal is just to run smoke-test. Last times mariadb-upgrade-service was broken (CONC-760, MDEV-30639) there were problems with named pipe connections, which could be detected and prevented by smoke-test alone.
This commit is contained in:
parent
fc60b89d0c
commit
a632a69386
@ -633,7 +633,7 @@ IF(NOT WITHOUT_SERVER)
|
||||
perror
|
||||
replace)
|
||||
IF(WIN32)
|
||||
ADD_DEPENDENCIES(minbuild echo mariadb-install-db my_safe_kill)
|
||||
ADD_DEPENDENCIES(minbuild echo mariadb-install-db my_safe_kill mariadb-upgrade-service)
|
||||
ENDIF()
|
||||
ADD_CUSTOM_TARGET(smoketest
|
||||
COMMAND perl ./mysql-test-run.pl main.1st
|
||||
|
35
mysql-test/main/mariadb-upgrade-service.result
Normal file
35
mysql-test/main/mariadb-upgrade-service.result
Normal file
@ -0,0 +1,35 @@
|
||||
use mysql;
|
||||
# run mysql_install_db with --service parameter
|
||||
# Start service
|
||||
# -- Upgrade service (online) --
|
||||
Phase 1/10: Stopping service
|
||||
Phase 2/10: Start and stop server in the old version, to avoid crash recovery (skipped)
|
||||
Phase 3/10: Fixing server config file
|
||||
Phase 4/10: Starting mysqld for upgrade
|
||||
Phase 5/10: Waiting for startup to complete
|
||||
Phase 6/10: Running mysql_upgrade
|
||||
Phase 7/10: Changing service configuration
|
||||
Phase 8/10: Initiating server shutdown
|
||||
Phase 9/10: Waiting for shutdown to complete
|
||||
Phase 10/10: Starting service
|
||||
Service 'SERVICE_NAME' successfully upgraded.
|
||||
Log file is written to UPGRADE_LOG
|
||||
# upgrade_success(online)=1
|
||||
# Service stopped
|
||||
# -- Upgrade service (offline) --
|
||||
Phase 1/10: Stopping service
|
||||
Phase 2/10: Start and stop server in the old version, to avoid crash recovery ,this can take some time
|
||||
Phase 3/10: Fixing server config file
|
||||
Phase 4/10: Starting mysqld for upgrade
|
||||
Phase 5/10: Waiting for startup to complete
|
||||
Phase 6/10: Running mysql_upgrade
|
||||
Phase 7/10: Changing service configuration
|
||||
Phase 8/10: Initiating server shutdown
|
||||
Phase 9/10: Waiting for shutdown to complete
|
||||
Phase 10/10: Starting service (skipped)
|
||||
Service 'SERVICE_NAME' successfully upgraded.
|
||||
Log file is written to UPGRADE_LOG
|
||||
# upgrade_success(offline)=1
|
||||
# Delete service
|
||||
connection default;
|
||||
# restart
|
113
mysql-test/main/mariadb-upgrade-service.test
Normal file
113
mysql-test/main/mariadb-upgrade-service.test
Normal file
@ -0,0 +1,113 @@
|
||||
source include/windows.inc;
|
||||
let $datadir_name=data;
|
||||
let $service_name_prefix=mariadb;
|
||||
let $password=password;
|
||||
|
||||
source include/check_windows_admin.inc;
|
||||
|
||||
# The test uses return code from sc.exe utility, which are as follows
|
||||
let $ERROR_SERVICE_DOES_NOT_EXIST= 1060;
|
||||
let $ERROR_SERVICE_CANNOT_ACCEPT_CTRL=1061;# intermediate, during start or stop
|
||||
let $ERROR_SERVICE_NOT_ACTIVE=1062;# service stopped
|
||||
let $ERROR_INVALID_SERVICE_CONTROL=1052; # The requested control is not valid for this service
|
||||
|
||||
let $sc_exe= C:\Windows\System32\sc.exe;
|
||||
let $ddir= $MYSQLTEST_VARDIR/tmp/$datadir_name;
|
||||
let $service_name=$service_name_prefix$MASTER_MYPORT;
|
||||
let TMP= $MYSQLTEST_VARDIR/tmp;
|
||||
let $upgrade_log=$TMP/mysql_upgrade_service.$service_name.log;
|
||||
|
||||
use mysql;
|
||||
error 0,1;
|
||||
rmdir $ddir;
|
||||
|
||||
--disable_result_log
|
||||
error 0,$ERROR_SERVICE_DOES_NOT_EXIST;
|
||||
exec $sc_exe delete $service_name;
|
||||
--enable_result_log
|
||||
|
||||
source include/shutdown_mysqld.inc;
|
||||
echo # run mysql_install_db with --service parameter;
|
||||
--disable_result_log
|
||||
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --port=$MASTER_MYPORT --password=$password --service=$service_name --verbose-bootstrap -R;
|
||||
--enable_result_log
|
||||
|
||||
echo # Start service;
|
||||
--disable_result_log
|
||||
exec $sc_exe start $service_name;
|
||||
--enable_result_log
|
||||
|
||||
enable_reconnect;
|
||||
source include/wait_until_connected_again.inc;
|
||||
disable_reconnect;
|
||||
|
||||
echo # -- Upgrade service (online) --;
|
||||
--replace_result $upgrade_log UPGRADE_LOG $service_name SERVICE_NAME
|
||||
let $sys_errno=0;
|
||||
let $upgrade_success = 1;
|
||||
error 0,1;
|
||||
exec $MARIADB_UPGRADE_SERVICE_EXE --service=$service_name;
|
||||
|
||||
if($sys_errno != 0)
|
||||
{
|
||||
let $upgrade_success = 0;
|
||||
}
|
||||
|
||||
echo # upgrade_success(online)=$upgrade_success;
|
||||
file_exists $upgrade_log;
|
||||
if ($upgrade_success == 0)
|
||||
{
|
||||
echo --detailed error(online upgrade)--;
|
||||
cat_file $upgrade_log;
|
||||
}
|
||||
# stop service
|
||||
--disable_result_log
|
||||
# Wait until stopped
|
||||
let $sys_errno=0;
|
||||
while($sys_errno != $ERROR_SERVICE_NOT_ACTIVE)
|
||||
{
|
||||
--error 0,$ERROR_SERVICE_CANNOT_ACCEPT_CTRL,$ERROR_SERVICE_NOT_ACTIVE, $ERROR_INVALID_SERVICE_CONTROL
|
||||
exec $sc_exe stop $service_name;
|
||||
if($sys_errno != $ERROR_SERVICE_NOT_ACTIVE)
|
||||
{
|
||||
--real_sleep 0.1
|
||||
}
|
||||
}
|
||||
--enable_result_log
|
||||
echo # Service stopped;
|
||||
|
||||
echo # -- Upgrade service (offline) --;
|
||||
--replace_result $upgrade_log UPGRADE_LOG $service_name SERVICE_NAME
|
||||
let $sys_errno=0;
|
||||
let $upgrade_success = 1;
|
||||
error 0,1;
|
||||
exec $MARIADB_UPGRADE_SERVICE_EXE --service=$service_name;
|
||||
|
||||
if($sys_errno != 0)
|
||||
{
|
||||
let $upgrade_success = 0;
|
||||
}
|
||||
|
||||
echo # upgrade_success(offline)=$upgrade_success;
|
||||
file_exists $upgrade_log;
|
||||
if ($upgrade_success == 0)
|
||||
{
|
||||
echo --detailed error(online upgrade)--;
|
||||
cat_file $upgrade_log;
|
||||
}
|
||||
|
||||
echo # Delete service;
|
||||
let $sys_errno=0;
|
||||
--disable_result_log
|
||||
exec $sc_exe delete $service_name;
|
||||
--enable_result_log
|
||||
|
||||
# Cleanup
|
||||
source include/wait_until_disconnected.inc;
|
||||
rmdir $ddir;
|
||||
remove_file $upgrade_log;
|
||||
let TEMP=$old_temp;
|
||||
|
||||
#restart original server
|
||||
connection default;
|
||||
source include/start_mysqld.inc;
|
@ -2226,6 +2226,9 @@ sub environment_setup {
|
||||
{
|
||||
$ENV{'MYSQL_INSTALL_DB_EXE'}= mtr_exe_exists("$bindir/sql$multiconfig/mariadb-install-db",
|
||||
"$bindir/bin/mariadb-install-db");
|
||||
$ENV{'MARIADB_UPGRADE_SERVICE_EXE'}= mtr_exe_exists("$bindir/sql$multiconfig/mariadb-upgrade-service",
|
||||
"$bindir/bin/mariadb-upgrade-service");
|
||||
$ENV{'MARIADB_UPGRADE_EXE'}= mtr_exe_exists("$path_client_bindir/mariadb-upgrade");
|
||||
}
|
||||
|
||||
my $client_config_exe=
|
||||
|
@ -45,7 +45,6 @@ extern int upgrade_config_file(const char *myini_path);
|
||||
"OPTIONS:"
|
||||
|
||||
static char mysqld_path[MAX_PATH];
|
||||
static char mysqladmin_path[MAX_PATH];
|
||||
static char mysqlupgrade_path[MAX_PATH];
|
||||
|
||||
static char defaults_file_param[MAX_PATH + 16]; /*--defaults-file=<path> */
|
||||
@ -455,8 +454,9 @@ int main(int argc, char **argv)
|
||||
|
||||
/*
|
||||
Get full path to mysqld, we need it when changing service configuration.
|
||||
Assume installation layout, i.e mysqld.exe, mysqladmin.exe, mysqlupgrade.exe
|
||||
and mysql_upgrade_service.exe are in the same directory.
|
||||
Assume mysqld.exe in the same directory as this program.
|
||||
mysql_upgrade.exe is either in the same directory, or pointed to by
|
||||
MARIADB_UPGRADE_EXE environment variable (in case of MTR running it)
|
||||
*/
|
||||
GetModuleFileName(NULL, bindir, FN_REFLEN);
|
||||
p= strrchr(bindir, FN_LIBCHAR);
|
||||
@ -465,15 +465,19 @@ int main(int argc, char **argv)
|
||||
*p= 0;
|
||||
}
|
||||
sprintf_s(mysqld_path, "%s\\mysqld.exe", bindir);
|
||||
sprintf_s(mysqladmin_path, "%s\\mysqladmin.exe", bindir);
|
||||
sprintf_s(mysqlupgrade_path, "%s\\mysql_upgrade.exe", bindir);
|
||||
|
||||
char *paths[]= {mysqld_path, mysqladmin_path, mysqlupgrade_path};
|
||||
for(int i= 0; i< 3;i++)
|
||||
if (access(mysqld_path, 0))
|
||||
die("File %s does not exist", mysqld_path);
|
||||
if (access(mysqlupgrade_path, 0))
|
||||
{
|
||||
if(GetFileAttributes(paths[i]) == INVALID_FILE_ATTRIBUTES)
|
||||
die("File %s does not exist", paths[i]);
|
||||
/* Try to get path from environment variable, set by MTR */
|
||||
char *alt_mysqlupgrade_path= getenv("MARIADB_UPGRADE_EXE");
|
||||
if (alt_mysqlupgrade_path)
|
||||
sprintf_s(mysqlupgrade_path, "%s", alt_mysqlupgrade_path);
|
||||
}
|
||||
if (access(mysqlupgrade_path, 0))
|
||||
die("File %s does not exist", mysqld_path);
|
||||
|
||||
/*
|
||||
Messages written on stdout should not be buffered, GUI upgrade program
|
||||
|
Loading…
x
Reference in New Issue
Block a user