From 219fd20d5ed86029c83fe2488b74ec5cd4f497d8 Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Mon, 16 Oct 2023 15:19:27 +0200 Subject: [PATCH] 5.001 bump (rhbz#2242077) --- .gitignore | 1 + DBD-mysql-5.001-Fix-version-tests.patch | 24 ++++ perl-DBD-MySQL.spec | 143 ++++++++++++++++++++---- sources | 2 +- test-clean.t | 16 +++ test-env.sh | 14 +++ test-setup.t | 48 ++++++++ testrules.yml | 11 ++ 8 files changed, 239 insertions(+), 20 deletions(-) create mode 100644 DBD-mysql-5.001-Fix-version-tests.patch create mode 100755 test-clean.t create mode 100755 test-env.sh create mode 100755 test-setup.t create mode 100644 testrules.yml diff --git a/.gitignore b/.gitignore index 8d46690..79aac15 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ DBD-mysql-4.017.tar.gz /DBD-mysql-4.048.tar.gz /DBD-mysql-4.049.tar.gz /DBD-mysql-4.050.tar.gz +/DBD-mysql-5.001.tar.gz diff --git a/DBD-mysql-5.001-Fix-version-tests.patch b/DBD-mysql-5.001-Fix-version-tests.patch new file mode 100644 index 0000000..48f175a --- /dev/null +++ b/DBD-mysql-5.001-Fix-version-tests.patch @@ -0,0 +1,24 @@ +diff -up DBD-mysql-5.001/t/10connect.t.orig DBD-mysql-5.001/t/10connect.t +--- DBD-mysql-5.001/t/10connect.t.orig 2023-10-12 17:14:01.117134826 +0200 ++++ DBD-mysql-5.001/t/10connect.t 2023-10-12 17:14:46.482494421 +0200 +@@ -46,7 +46,7 @@ like( + 'get_info SQL_DRIVER_VER like dd.dd.dddd' + ); + +-like($driver_ver, qr/^04\./, 'SQL_DRIVER_VER starts with "04." (update for 5.x)'); ++like($driver_ver, qr/^05\./, 'SQL_DRIVER_VER starts with "05." (update for 6.x)'); + + # storage engine function is @@storage_engine in up to 5.5.03 + # at that version, @@default_storage_engine is introduced +diff -up DBD-mysql-5.001/t/version.t.orig DBD-mysql-5.001/t/version.t +--- DBD-mysql-5.001/t/version.t.orig 2023-10-12 17:14:16.136253877 +0200 ++++ DBD-mysql-5.001/t/version.t 2023-10-12 17:15:13.153705834 +0200 +@@ -7,7 +7,7 @@ use Bundle::DBD::mysql; + use Test::More; + + like($DBD::mysql::VERSION, qr/^\d\.\d{2,3}(|_\d\d)$/, 'version format'); +-like($DBD::mysql::VERSION, qr/^4\./, 'version starts with "4." (update for 5.x)'); ++like($DBD::mysql::VERSION, qr/^5\./, 'version starts with "5." (update for 6.x)'); + is( + $DBD::mysql::VERSION, + $Bundle::DBD::mysql::VERSION, diff --git a/perl-DBD-MySQL.spec b/perl-DBD-MySQL.spec index a072761..5ed75ee 100644 --- a/perl-DBD-MySQL.spec +++ b/perl-DBD-MySQL.spec @@ -1,30 +1,36 @@ +%global cpan_name DBD-mysql + +# Disable leak tests +%bcond_with perl_DBD_MySQL_enables_leak_test + Name: perl-DBD-MySQL -Version: 4.050 -Release: 18%{?dist} +Version: 5.001 +Release: 1%{?dist} Summary: A MySQL interface for Perl License: GPL-1.0-or-later OR Artistic-1.0-Perl -URL: https://metacpan.org/release/DBD-mysql -Source0: https://cpan.metacpan.org/authors/id/D/DV/DVEEDEN/DBD-mysql-%{version}.tar.gz -# Remove a useless shebang, bug #1813195, -# -Patch0: DBD-mysql-4.050-Remove-a-useless-shebang-from-DBD-mysql.patch -BuildRequires: make +URL: https://metacpan.org/release/%{cpan_name} +Source0: https://cpan.metacpan.org/authors/id/D/DV/DVEEDEN/%{cpan_name}-%{version}.tar.gz +Source1: test-setup.t +Source2: test-clean.t +Source3: testrules.yml +Source4: test-env.sh + +Patch0: DBD-mysql-5.001-Fix-version-tests.patch + BuildRequires: coreutils BuildRequires: findutils BuildRequires: gcc -BuildRequires: mariadb-connector-c -BuildRequires: mariadb-connector-c-devel +BuildRequires: make +# DBD::mysql v5.x requires MySQL 8.x client libraries for building +BuildRequires: %{?fedora:community-}mysql-devel >= 8 BuildRequires: openssl-devel BuildRequires: perl-devel BuildRequires: perl-generators BuildRequires: perl-interpreter -BuildRequires: perl(Carp) BuildRequires: perl(Config) BuildRequires: perl(Data::Dumper) -BuildRequires: perl(DBI) >= 1.609 BuildRequires: perl(DBI::DBD) BuildRequires: perl(Devel::CheckLib) >= 1.09 -BuildRequires: perl(DynaLoader) BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 BuildRequires: perl(File::Basename) BuildRequires: perl(File::Copy) @@ -35,26 +41,89 @@ BuildRequires: perl(strict) BuildRequires: perl(utf8) BuildRequires: perl(warnings) BuildRequires: zlib-devel +# Run-time +BuildRequires: perl(Carp) +BuildRequires: perl(DBI) >= 1.609 +BuildRequires: perl(DBI::Const::GetInfoType) +BuildRequires: perl(DynaLoader) +# Tests +BuildRequires: %{?fedora:community-}mysql >= 8 +BuildRequires: %{?fedora:community-}mysql-server >= 8 +BuildRequires: perl(B) +BuildRequires: perl(bigint) +# Required to process t/testrules.yml +BuildRequires: perl(CPAN::Meta::YAML) +BuildRequires: perl(Encode) +BuildRequires: perl(lib) +BuildRequires: perl(Test::Deep) +BuildRequires: perl(Test::More) +BuildRequires: perl(Time::HiRes) +BuildRequires: perl(vars) +# Optional tests +%if %{with perl_DBD_MySQL_enables_leak_test} +BuildRequires: perl(Proc::ProcessTable) +BuildRequires: perl(Storable) +%endif + Provides: perl-DBD-mysql = %{version}-%{release} %{?perl_default_filter} +# Filter modules bundled for tests +%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(Bundle::DBD::mysql\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(.*lib.pl\\) + %description DBD::mysql is the Perl5 Database Interface driver for the MySQL database. In other words: DBD::mysql is an interface between the Perl programming language and the MySQL programming API that comes with the MySQL relational database management system. +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness +#Requires: hostname +Requires: %{?fedora:community-}mysql >= 8 +Requires: %{?fedora:community-}mysql-server >= 8 +# Required to process t/testrules.yml +Requires: perl(CPAN::Meta::YAML) +# Optional tests +%if %{with perl_DBD_MariaDB_enables_leak_test} +Requires: perl(Proc::ProcessTable) +Requires: perl(Storable) +%endif + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep -%setup -q -n DBD-mysql-%{version} -%patch0 -p1 +%setup -q -n %{cpan_name}-%{version} +%patch -P0 -p1 # Correct file permissions find . -type f | xargs chmod -x +cp %{SOURCE1} %{SOURCE2} %{SOURCE3} t/ +cp %{SOURCE4} . + +# Help file to recognise the Perl scripts and normalize shebangs +for F in t/*.t t/*.pl; do + perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!.*perl\b}{$Config{startperl}}' "$F" + chmod +x "$F" +done + %build +. %{SOURCE4} perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" \ - NO_PACKLIST=1 NO_PERLLOCAL=1 + NO_PACKLIST=1 NO_PERLLOCAL=1 \ + --testdb=$DBD_MYSQL_TESTDB \ + --testuser=$DBD_MYSQL_TESTUSER \ + --testpassword=$DBD_MYSQL_TESTPASSWORD \ + --testhost=$DBD_MYSQL_TESTHOST \ + --testsocket=$DBD_MYSQL_TESTSOCKET %{make_build} %install @@ -62,9 +131,36 @@ perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" \ find %{buildroot} -type f -name '*.bs' -empty -delete %{_fixperms} %{buildroot}/* +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a t %{buildroot}%{_libexecdir}/%{name} +cp %{SOURCE4} %{buildroot}%{_libexecdir}/%{name} +# Replace build dir by template +perl -i -pe 's{%{_builddir}/.*mysql.sock}{_TEST_SOCKET_}' %{buildroot}%{_libexecdir}/%{name}/t/mysql.mtest +# Remove release tests +rm %{buildroot}%{_libexecdir}/%{name}/t/manifest.t +rm %{buildroot}%{_libexecdir}/%{name}/t/pod.t +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/usr/bin/bash +set -e +# The tests write to temporary database which is placed in $DIR/t/testdb +DIR=$(mktemp -d) +pushd "$DIR" +cp -a %{_libexecdir}/%{name}/* ./ +. $DIR/$(basename %{SOURCE4}) +%{!?with_perl_DBD_MySQL_enables_leak_test:unset EXTENDED_TESTING} +perl -i -pe "s{_TEST_SOCKET_}{$DBD_MYSQL_TESTSOCKET}" $DIR/t/mysql.mtest +prove -I . -j "$(getconf _NPROCESSORS_ONLN)" +popd +rm -rf "$DIR" +EOF +chmod +x %{buildroot}%{_libexecdir}/%{name}/test + %check -# Full test coverage requires a live MySQL database -#make test +# Set MySQL and DBD::mysql test environment +. %{SOURCE4} +unset RELEASE_TESTING +make test %{?with_perl_DBD_MySQL_enables_leak_test:EXTENDED_TESTING=1} %files %license LICENSE @@ -72,9 +168,18 @@ find %{buildroot} -type f -name '*.bs' -empty -delete %{perl_vendorarch}/Bundle/ %{perl_vendorarch}/DBD/ %{perl_vendorarch}/auto/DBD/ -%{_mandir}/man3/*.3* +%{_mandir}/man3/Bundle*.3* +%{_mandir}/man3/DBD::mysql*.3* + +%files tests +%{_libexecdir}/%{name} %changelog +* Wed Oct 04 2023 Jitka Plesnikova - 5.001-1 +- 5.001 bump (rhbz#2242077) + Since this version, MySQL 8.x has to be used for build +- Package tests + * Thu Jul 20 2023 Fedora Release Engineering - 4.050-18 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild diff --git a/sources b/sources index 8cfecdf..50442a0 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (DBD-mysql-4.050.tar.gz) = 910f5b4ba7a7890d50a79f37d04ec8971a4f62acd0fe30bf3ab634f66e3128f0cd6513e5c9da8c807a0f4477d0cc766682ea8dd0d8072d02821b78df51f37879 +SHA512 (DBD-mysql-5.001.tar.gz) = 1aea86bba76f371ed11eb22e9fe1f99dfaefafd83dea69ee0ac5ea175c1328ff324934ad45bfa73851463931656471ca890b3d7656e9db3861a8465d6130d5c0 diff --git a/test-clean.t b/test-clean.t new file mode 100755 index 0000000..a8c52df --- /dev/null +++ b/test-clean.t @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use File::Path; +use Test::More tests => 2; + +my $MYSQL_DIR = $ENV{'MYSQL_DIR'}; +my $MYSQL_UNIX_PORT = $ENV{'MYSQL_UNIX_PORT'}; +my $MYSQL_PIDFILE = $ENV{'MYSQL_PIDFILE'}; + +ok(system("/usr/bin/mysqladmin --user=root --socket=$MYSQL_UNIX_PORT shutdown 2>&1 || [ ! -s \"$MYSQL_PIDFILE\" ] || /bin/kill `cat \"$MYSQL_PIDFILE\"`") == 0); +my $removed_count = rmtree($MYSQL_DIR, 1, 1); +ok($removed_count > 0); + diff --git a/test-env.sh b/test-env.sh new file mode 100755 index 0000000..2a10623 --- /dev/null +++ b/test-env.sh @@ -0,0 +1,14 @@ +#!/usr/bin/bash + +# MariaDB setup +export MYSQL_DIR=$PWD/t/testdb +export MYSQL_UNIX_PORT=$MYSQL_DIR/mysql.sock +export MYSQL_PIDFILE=$MYSQL_DIR/mysql.pid + +# DBD::mysql test setup +export DBD_MYSQL_TESTDB=test +export DBD_MYSQL_TESTHOST=localhost +export DBD_MYSQL_TESTSOCKET=$MYSQL_UNIX_PORT +export DBD_MYSQL_TESTUSER=testuser +export DBD_MYSQL_TESTPASSWORD=testpassword + diff --git a/test-setup.t b/test-setup.t new file mode 100755 index 0000000..bf6553c --- /dev/null +++ b/test-setup.t @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 7; + +# MySQL setup +my $MYSQL_DIR = $ENV{'MYSQL_DIR'}; +my $MYSQL_UNIX_PORT = $ENV{'MYSQL_UNIX_PORT'}; +my $MYSQL_PIDFILE = $ENV{'MYSQL_PIDFILE'}; + +# DBD::MariaDB test setup +my $DBD_MYSQL_TESTDB = $ENV{'DBD_MYSQL_TESTDB'}; +my $DBD_MYSQL_TESTHOST = $ENV{'DBD_MYSQL_TESTHOST'}; +my $DBD_MYSQL_TESTSOCKET = $ENV{'DBD_MYSQL_TESTSOCKET'}; +my $DBD_MYSQL_TESTUSER = $ENV{'DBD_MYSQL_TESTUSER'}; +my $DBD_MYSQL_TESTPASSWORD = $ENV{'DBD_MYSQL_TESTPASSWORD'}; + +my $MYSQLD = '/usr/sbin/mysqld'; +system("$MYSQLD --no-defaults --initialize-insecure --datadir=$MYSQL_DIR --explicit_defaults_for_timestamp >/dev/null 2>&1"); +is($?, 0); + +my $cmd = "$MYSQLD --no-defaults --socket=$MYSQL_UNIX_PORT --datadir=$MYSQL_DIR --pid-file=$MYSQL_PIDFILE --explicit_defaults_for_timestamp --skip-networking >/dev/null 2>&1 &"; +system($cmd); +is($?, 0); + +my $attempts = 0; +while (system("/usr/bin/mysqladmin --user=root --socket=$MYSQL_UNIX_PORT ping >/dev/null 2>&1") != 0) { + sleep 3; + $attempts++; + if ($attempts > 10) { + fail("skipping test, mariadb/mysql server could not be contacted after 30 seconds\n"); + } +} +ok(1); + +system("mysql -u root --skip-password --execute \"CREATE DATABASE IF NOT EXISTS $DBD_MYSQL_TESTDB CHARACTER SET='utf8mb4';\" 2>&1"); +is($?, 0); + +# The test user has to have the proper privileges that these tests require +system("mysql -u root --skip-password --execute \"CREATE USER '$DBD_MYSQL_TESTUSER'\@'localhost' IDENTIFIED BY '$DBD_MYSQL_TESTPASSWORD'; \" 2>&1"); +is($?, 0); +system("mysql -u root --skip-password --execute \"GRANT ALL PRIVILEGES ON $DBD_MYSQL_TESTDB.* TO '$DBD_MYSQL_TESTUSER'\@'localhost';\" 2>&1"); +is($?, 0); + +system("/usr/bin/mysqladmin --user=$DBD_MYSQL_TESTUSER --password=$DBD_MYSQL_TESTPASSWORD --socket=$DBD_MYSQL_TESTSOCKET ping >/dev/null 2>&1"); +is($?, 0); diff --git a/testrules.yml b/testrules.yml new file mode 100644 index 0000000..b03a5b6 --- /dev/null +++ b/testrules.yml @@ -0,0 +1,11 @@ +seq: + - seq: t/test-setup.t + - seq: t/00base.t + - seq: t/05dbcreate.t + - seq: t/10connect.t + - seq: t/87async.t + - seq: t/rt75353-innodb-lock-timeout.t + - seq: t/rt85919-fetch-lost-connection.t + - par: + - par: ** + - seq: t/test-clean.t