diff --git a/macros.mariadb-test b/macros.mariadb-test new file mode 100644 index 0000000..caecef6 --- /dev/null +++ b/macros.mariadb-test @@ -0,0 +1,99 @@ +%__mysql_test_run_dir /tmp/mysql +%__mysql_test_user abuild +%__mysql_test_pass abuildpw +%__mysql_test_cconf abuild-myclient.cnf +%__mysql_test_port 63306 + +# +# macro: mysql_testserver_start -- start a test mysqld instance +# +# usage: %mysql_test_start -u -p -t +# + +%mysql_testserver_start(u:p:t:) \ +TEST_RUN_DIR=%{__mysql_test_run_dir} \ +TEST_USER="%{-u:%{-u*}}" \ +if [ -z "$TEST_USER" ]; then \ + TEST_USER='%{__mysql_test_user}' \ +fi \ +TEST_PASS="%{-p:%{-p*}}" \ +if [ -z "$TEST_PASS" ]; then \ + TEST_PASS='%{__mysql_test_pass}' \ +fi \ +TEST_PORT="%{-t:%{-t*}}" \ +if [ -z "$TEST_PORT" ]; then \ + TEST_PORT='%{__mysql_test_port}' \ +fi \ +\ +[ -d $TEST_RUN_DIR ] && rm -r $TEST_RUN_DIR \ +mkdir -p $TEST_RUN_DIR/datadir{,-private} \ +\ +cat << EOF > $TEST_RUN_DIR/my.cnf \ +[client] \ +socket = $TEST_RUN_DIR/mysql.sock \ +port = $TEST_PORT \ +[mysqld] \ +user = $TEST_USER \ +log-error = $TEST_RUN_DIR/mysqld.log \ +secure_file_priv = $TEST_RUN_DIR/datadir-private \ +datadir = $TEST_RUN_DIR/datadir \ +server-id = 1 \ +socket = $TEST_RUN_DIR/mysql.sock \ +port = $TEST_PORT \ +sql_mode = '' \ +EOF\ +\ +echo '>>> Initializing databases' \ +mysql_install_db --defaults-file=$TEST_RUN_DIR/my.cnf \ +\ +echo '>>> Invoking mysqld' \ +/usr/sbin/mysqld --defaults-file=$TEST_RUN_DIR/my.cnf& \ +sleep 2 \ +\ +echo '>>> Creating authentication database' \ +mysqladmin --defaults-file=$TEST_RUN_DIR/my.cnf --user root password 'roots_secret' \ +mysqladmin --defaults-file=$TEST_RUN_DIR/my.cnf --user root --password='roots_secret' create testhat \ +mysql --defaults-file=$TEST_RUN_DIR/my.cnf --user root --password='roots_secret' -e "CREATE USER '$TEST_USER'@'localhost' IDENTIFIED BY '$TEST_PASS'" \ +mysql --defaults-file=$TEST_RUN_DIR/my.cnf --user root --password='roots_secret' -e "GRANT ALL PRIVILEGES ON * . * TO '$TEST_USER'@'localhost'" \ +mysql --defaults-file=$TEST_RUN_DIR/my.cnf --user root --password='roots_secret' -e "FLUSH PRIVILEGES" \ +%nil + +# +# macro mysql_testserver_cconf -- generate client access conf +# + +%mysql_testserver_cconf(n:t:) \ +TEST_RUN_DIR=%{__mysql_test_run_dir} \ +TEST_CCONF="%{-n:%{-n*}}" \ +if [ -z "$TEST_CCONF" ]; then \ + TEST_CCONF='%{__mysql_test_cconf}' \ +fi \ +TEST_PORT="%{-t:%{-t*}}" \ +if [ -z "$TEST_PORT" ]; then \ + TEST_PORT='%{__mysql_test_port}' \ +fi \ +cat << EOF > $TEST_CCONF \ +[client] \ +user = abuild \ +password = abuildpw \ +database = test \ +socket = $TEST_RUN_DIR/mysql.sock \ +port = $TEST_PORT \ +EOF\ +%nil + +# +# macro: mysql_testserver_stop -- start a test mysqld instance +# +# usage: %mysql_test_stop +# + +%mysql_testserver_stop() \ +TEST_RUN_DIR=%{__mysql_test_run_dir} \ +echo '>>> Shutting the mysql server down' \ +cat << EOF > $TEST_RUN_DIR/shutdown.sql \ +SHUTDOWN; \ +EOF\ +mysql --defaults-file=$TEST_RUN_DIR/my.cnf --user root --password='roots_secret' < $TEST_RUN_DIR/shutdown.sql \ +%nil + diff --git a/mariadb.changes b/mariadb.changes index d0618e0..334d2c9 100644 --- a/mariadb.changes +++ b/mariadb.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Dec 5 10:41:56 UTC 2019 - pgajdos@suse.com + +- added rpm test macros: %mysql_testserver_start, + %mysql_testserver_cconf, %mysql_testserver_stop + First two consuments are python-sortinghat and python-mysqlclient. + ------------------------------------------------------------------- Tue Nov 19 17:16:49 UTC 2019 - Kristyna Streitova diff --git a/mariadb.spec b/mariadb.spec index 2cc885e..64860ad 100644 --- a/mariadb.spec +++ b/mariadb.spec @@ -71,6 +71,7 @@ Source15: mariadb.service Source16: mariadb.target Source17: mysql-systemd-helper Source18: mariadb@.service +Source19: macros.mariadb-test Source50: suse_skipped_tests.list Patch1: mariadb-10.2.4-logrotate.patch Patch3: mariadb-10.1.1-mysqld_multi-features.patch @@ -214,6 +215,13 @@ Obsoletes: libmysqld-devel < %{version}-%{release} This package contains the development header files and libraries for developing applications that embed the MariaDB. +%package rpm-macros +Summary: MariaDB RPM macros +Requires: %{name} + +%description rpm-macros +Provides macros usable in rpm spec files. + %package client Summary: Client for MariaDB Group: Productivity/Databases/Clients @@ -651,6 +659,11 @@ rm -rf '%{buildroot}'%{_datadir}/mysql/{solaris,SELinux} # Create the directory specified in 'secure-file-priv' option mkdir -p '%{buildroot}'%{_localstatedir}/lib/mysql-files +# install rpm macros file +mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d +install -m 644 %{SOURCE19} %{buildroot}%{_rpmconfigdir}/macros.d + + %check cd build @@ -815,6 +828,10 @@ exit 0 %{_datadir}/mysql/systemd/mariadb.service %{_datadir}/mysql/systemd/mariadb@.service +%files rpm-macros +%dir %{_rpmconfigdir}/macros.d +%{_rpmconfigdir}/macros.d/macros.mariadb-test + %files -n libmariadbd%{soname} %{_libdir}/libmariadbd.so.*