[packages/python3-mysql-connector] Enable the test suite and make it use our own mysql server

arekm arekm at pld-linux.org
Tue Sep 1 13:02:22 CEST 2026


commit 53e6e6257bb0f299a9ad70fad02b4955eeb989d4
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Sep 1 11:19:14 2026 +0200

    Enable the test suite and make it use our own mysql server

 python3-mysql-connector.spec | 16 ++++++++++++----
 tests-config-leak.patch      | 28 ++++++++++++++++++++++++++++
 tests.patch                  | 25 ++++++++++++++++++++++---
 3 files changed, 62 insertions(+), 7 deletions(-)
---
diff --git a/python3-mysql-connector.spec b/python3-mysql-connector.spec
index 4e6fbae..1b242f3 100644
--- a/python3-mysql-connector.spec
+++ b/python3-mysql-connector.spec
@@ -2,7 +2,7 @@
 # - c extension build is done in install phase (http://bugs.mysql.com/bug.php?id=78621)
 #
 # Conditional build:
-%bcond_with	tests		# build with tests (requires mysql server)
+%bcond_without	tests		# build with tests (requires mysql server)
 
 %ifarch %{x8664}
 %define		mysql_ver	9.7
@@ -26,6 +26,7 @@ Source0:	http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-
 Patch0:		force-capi.patch
 Patch1:		tests.patch
 Patch2:		plugin-dir.patch
+Patch3:		tests-config-leak.patch
 URL:		http://dev.mysql.com/doc/connector-python/en/
 BuildRequires:	mysql%{mysql_ver}-devel
 BuildRequires:	protobuf-devel >= 3.0.0
@@ -35,7 +36,8 @@ BuildRequires:	python3-setuptools
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.714
 %if %{with tests}
-BuildRequires:	mysql
+BuildRequires:	mysql%{mysql_ver}
+BuildRequires:	openssl-tools
 %endif
 Requires:	python3-modules
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -52,6 +54,7 @@ MySQL Connector/Python to protokół klient-serwer MySQL-a.
 %patch -P0 -p1
 %patch -P1 -p1
 %patch -P2 -p1
+%patch -P3 -p1
 
 %build
 export MYSQL_CAPI=%{_bindir}/mysql_config%{mysql_ver}
@@ -61,12 +64,17 @@ cd mysql-connector-python
 %py3_build
 %if %{with tests}
 export PYTHONPATH="$(pwd)/$(echo build-3/lib*)"
+export MYSQLD_EXEC=mysqld%{mysql_ver}
+# test certs are issued for a year, so any older tarball ships expired ones
+sh tests/data/ssl/generate.sh tests/data/ssl
 %{__python3} unittests.py \
 	--verbosity 1 \
-	--keep --stats \
+	--force --stats \
+	--port=33306 \
 	--skip-install \
 	--with-mysql=%{_prefix} \
-	--with-mysql-share=%{_datadir}/mysql
+	--unix-socket=%{tmpdir} \
+	--with-mysql-share=%{_datadir}/mysql%{mysql_ver}
 %endif
 
 cd ..
diff --git a/tests-config-leak.patch b/tests-config-leak.patch
new file mode 100644
index 0000000..ab6d8f7
--- /dev/null
+++ b/tests-config-leak.patch
@@ -0,0 +1,28 @@
+The testcases all do "config = self.config" and then mutate it, so the last
+read_timeout set by a testcase leaks into the connection tearDown opens. Its
+DROP TABLE then runs under that timeout, on a table the write_timeout cases
+fill with 9MB blobs, and fails whenever the machine is loaded enough for the
+drop to outlast it. Hand out a copy instead.
+
+--- a/mysql-connector-python/tests/qa/test_qa_timeout.py
++++ b/mysql-connector-python/tests/qa/test_qa_timeout.py
+@@ -59,10 +59,17 @@
+         self.table_name = "test_timeouts"
+         self.stmt_for_write_TLE = f"INSERT INTO {self.table_name} (my_blob) VALUES ('{self.test_values[0]}')"
+         self.multi_stmt_write_TLE = f"SELECT 'abcd';SELECT 123;INSERT INTO {self.table_name} (my_blob) VALUES ('{self.test_values[0]}')"
+-        self.config = tests.get_mysql_config()
+-        self.config["unix_socket"] = None
++        self._config = tests.get_mysql_config()
++        self._config["unix_socket"] = None
+         super().__init__(methodName)
+ 
++    @property
++    def config(self):
++        # every testcase mutates what it gets back, so hand out a copy;
++        # otherwise per-test options such as read_timeout leak into the
++        # connections setUp/tearDown make
++        return dict(self._config)
++
+     def setUp(self):
+         config = self.config
+         config["use_pure"] = True
diff --git a/tests.patch b/tests.patch
index c1aba1c..b526ae6 100644
--- a/tests.patch
+++ b/tests.patch
@@ -1,6 +1,25 @@
---- mysql-connector-python-8.0.33-src/mysql-connector-python/tests/mysqld.py~	2023-03-30 12:58:04.000000000 +0200
-+++ mysql-connector-python-8.0.33-src/mysql-connector-python/tests/mysqld.py	2024-03-21 13:15:47.909993896 +0100
-@@ -181,30 +181,7 @@ class MySQLServerBase:
+Do not walk the whole basedir looking for mysqld - the location is known, and
+PLD installs the server under a versioned name (/usr/sbin/mysqld9.7 and such),
+which the upstream search would not match anyway. The spec passes the exact
+name via MYSQLD_EXEC so the suite runs against the same server line the
+connector is built for.
+
+--- a/mysql-connector-python/tests/mysqld.py
++++ b/mysql-connector-python/tests/mysqld.py
+@@ -56,8 +56,10 @@
+ 
+ LOGGER = logging.getLogger(tests.LOGGER_NAME)
+ 
+-# MySQL Server executable name
+-EXEC_MYSQLD = "mysqld.exe" if os.name == "nt" else "mysqld"
++# MySQL Server executable name, overridable where it is installed versioned
++EXEC_MYSQLD = os.environ.get("MYSQLD_EXEC") or (
++    "mysqld.exe" if os.name == "nt" else "mysqld"
++)
+ 
+ # MySQL client executable name
+ EXEC_MYSQL = "mysql.exe" if os.name == "nt" else "mysql"
+@@ -181,30 +183,7 @@
          Raises MySQLBootstrapError when something fails.
          """
  
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python3-mysql-connector.git/commitdiff/53e6e6257bb0f299a9ad70fad02b4955eeb989d4



More information about the pld-cvs-commit mailing list