Skip to content

Added CI tests for MySQL 9.x #492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions example/db_setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ DELIMITER ;

-- User
DROP USER IF EXISTS 'example_user'@'%';
CREATE USER 'example_user'@'%' IDENTIFIED WITH 'mysql_native_password';
ALTER USER 'example_user'@'%' IDENTIFIED BY 'example_password';
CREATE USER 'example_user'@'%' IDENTIFIED BY 'example_password';
GRANT ALL PRIVILEGES ON boost_mysql_examples.* TO 'example_user'@'%';
FLUSH PRIVILEGES;
13 changes: 1 addition & 12 deletions test/integration/db_setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -492,20 +492,9 @@ INSERT INTO types_flags VALUES

-- Users
DROP USER IF EXISTS 'integ_user'@'%';
CREATE USER 'integ_user'@'%' IDENTIFIED WITH 'mysql_native_password';
ALTER USER 'integ_user'@'%' IDENTIFIED BY 'integ_password';
CREATE USER 'integ_user'@'%' IDENTIFIED BY 'integ_password';
GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'integ_user'@'%';

DROP USER IF EXISTS 'mysqlnp_user'@'%';
CREATE USER 'mysqlnp_user'@'%' IDENTIFIED WITH 'mysql_native_password';
ALTER USER 'mysqlnp_user'@'%' IDENTIFIED BY 'mysqlnp_password';
GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_user'@'%';

DROP USER IF EXISTS 'mysqlnp_empty_password_user'@'%';
CREATE USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED WITH 'mysql_native_password';
ALTER USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_empty_password_user'@'%';

-- Some containers don't allow remote root access. Enable it.
CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Expand Down
21 changes: 21 additions & 0 deletions test/integration/db_setup_mnp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--
-- Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
--
-- Distributed under the Boost Software License, Version 1.0. (See accompanying
-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
--

USE boost_mysql_integtests;

-- Setup that requires the presence of the mysql_native_password functionality
DROP USER IF EXISTS 'mysqlnp_user'@'%';
CREATE USER 'mysqlnp_user'@'%' IDENTIFIED WITH 'mysql_native_password';
ALTER USER 'mysqlnp_user'@'%' IDENTIFIED BY 'mysqlnp_password';
GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_user'@'%';

DROP USER IF EXISTS 'mysqlnp_empty_password_user'@'%';
CREATE USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED WITH 'mysql_native_password';
ALTER USER 'mysqlnp_empty_password_user'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON boost_mysql_integtests.* TO 'mysqlnp_empty_password_user'@'%';

FLUSH PRIVILEGES;
3 changes: 3 additions & 0 deletions test/integration/include/test_integration/server_features.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct server_features
// Includes caching_sha2_password and sha256_password
bool sha256{true};

// Does the server support the mysql_native_password authentication method?
bool mnp{true};

// Does the server support the dedicated JSON type?
bool json_type{true};

Expand Down
1 change: 1 addition & 0 deletions test/integration/src/server_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static test::server_features do_get_server_features()
{"json-type", &test::server_features::json_type },
{"regex-error-codes", &test::server_features::regex_error_codes },
{"dup-query-error-codes", &test::server_features::dup_query_error_codes},
{"mnp", &test::server_features::mnp },
};

// Match disabled features against the possible set
Expand Down
1 change: 1 addition & 0 deletions test/integration/test/handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void check_ssl(Conn& conn, bool expected, boost::source_location loc = BOOST_MYS
}

// mysql_native_password
BOOST_TEST_DECORATOR(*run_if(&server_features::mnp))
BOOST_AUTO_TEST_SUITE(mysql_native_password)

constexpr const char* regular_user = "mysqlnp_user";
Expand Down
16 changes: 13 additions & 3 deletions tools/ci/ci_util/db_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
class _DbSystemType(Enum):
mysql5 = 1
mysql8 = 2
mariadb = 3
mysql9 = 3
mariadb = 4


def _run_piped_stdin(args: List[str], fname: Path) -> None:
Expand Down Expand Up @@ -54,8 +55,12 @@ def _parse_db_version(db: str) -> _DbSystemType:
# Perform the matching
if is_mariadb:
return _DbSystemType.mariadb
elif vmaj == 8:
return _DbSystemType.mysql8
elif vmaj >= 9:
return _DbSystemType.mysql9
else:
return _DbSystemType.mysql8 if vmaj >= 8 else _DbSystemType.mysql5
return _DbSystemType.mysql5


def _compute_disabled_features(db: _DbSystemType) -> Dict[str, bool]:
Expand All @@ -73,7 +78,10 @@ def _compute_disabled_features(db: _DbSystemType) -> Dict[str, bool]:
'regex-error-codes': db in (_DbSystemType.mysql5, _DbSystemType.mariadb),

# dup-query-error-codes. Disabled in mysql systems
'dup-query-error-codes': db in (_DbSystemType.mysql5, _DbSystemType.mysql8),
'dup-query-error-codes': db in (_DbSystemType.mysql5, _DbSystemType.mysql8, _DbSystemType.mysql9),

# mysql_native_password. Disabled in mysql9
'mnp': db == _DbSystemType.mysql9,
}


Expand All @@ -96,6 +104,8 @@ def db_setup(
_run_sql_file(source_dir.joinpath('test', 'integration', 'db_setup.sql'))
if not disabled_features['sha256']:
_run_sql_file(source_dir.joinpath('test', 'integration', 'db_setup_sha256.sql'))
if not disabled_features['mnp']:
_run_sql_file(source_dir.joinpath('test', 'integration', 'db_setup_mnp.sql'))

# Setup environment variables
os.environ['BOOST_MYSQL_SERVER_HOST'] = server_host
Expand Down
Loading