diff --git a/connector-example-socket/Test.java b/connector-example-socket/Test.java new file mode 100644 index 0000000..06d9df7 --- /dev/null +++ b/connector-example-socket/Test.java @@ -0,0 +1,44 @@ +// https://fedoraproject.org/wiki/MariaDB_JDBC_connector +import java.sql.*; + +public class Test { + public static void main(String[] args) throws Exception { + // create our mysql database connection + String socketFile = "/var/lib/mysql/mysql.sock"; + if (args.length == 1) { + socketFile = args[0]; + } + String host = "localhost"; + // use clearly different port to be sure we connect over socket + String port = "55556"; + String dbname = "information_schema"; + String url = "jdbc:mariadb://" + host + ":" + port + "/" + dbname + "?localSocket=" + socketFile; + String username = "root"; + String password = ""; + Connection conn = DriverManager.getConnection(url, username, password); + + // our SQL SELECT query. + // if you only need a few columns, specify them by name instead of using "*" + String query = "SELECT * FROM ENGINES"; + + // create the java statement + Statement st = conn.createStatement(); + + // execute the query, and get a java resultset + ResultSet rs = st.executeQuery(query); + + // iterate through the java resultset + while (rs.next()) { + String engine = rs.getString("ENGINE"); + String support = rs.getString("SUPPORT"); + String comment = rs.getString("COMMENT"); + String transactions = rs.getString("TRANSACTIONS"); + String xa = rs.getString("XA"); + String savepoints = rs.getString("SAVEPOINTS"); + + // print the results + System.out.format("%s, %s, %s, %s, %s, %s\n", engine, support, comment, transactions, xa, savepoints); + } + st.close(); + } +} diff --git a/connector-example-socket/main.fmf b/connector-example-socket/main.fmf new file mode 100644 index 0000000..78ebf2e --- /dev/null +++ b/connector-example-socket/main.fmf @@ -0,0 +1,15 @@ +summary: example connector usage with connection over socket +description: | + example connector usage with connection over socket +contact: Jakub Heger +component: [] +require: + - mariadb-java-client + - mariadb-server + - jna + - util-linux +duration: 5m +enabled: true +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1683112 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1697372 diff --git a/connector-example-socket/runtest.sh b/connector-example-socket/runtest.sh new file mode 100755 index 0000000..ea87965 --- /dev/null +++ b/connector-example-socket/runtest.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/mariadb-java-client/Sanity/JDBC-connector-example-socket +# Description: example connector usage with connection over socket +# Author: Jakub Janco +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="mariadb-java-client" +TestDir=$PWD + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlAssertRpm jna + rlAssertRpm mariadb-server + rlLogInfo "$(rpm -q --whatprovides java-devel)" + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp Test.java $TmpDir/." + rlRun "pushd $TmpDir" + + rlRun "mariadb-install-db --user=mysql --datadir=/var/lib/mysql" + rlRun "su -s /bin/bash mysql -c \"mariadbd --verbose --general-log=1 &\"" + # wait until the server is ready + rlRun "tail -f /var/log/mariadb/mariadb.log | grep -q 'mariadbd: ready for connections.'" + + rlAssertExists "/var/lib/mysql/mysql.sock" + rlPhaseEnd + + rlPhaseStartTest + rlRun "java -Djdbc.drivers=org.mariadb.jdbc.Driver -cp /usr/lib/java/mariadb-java-client.jar:/usr/lib/java/jna.jar:. Test.java > output.log" + rlAssertGrep "PERFORMANCE_SCHEMA" "output.log" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "killall mariadbd" + rlRun "rm -r /var/lib/mysql /var/log/mariadb/mariadb.log" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/connector-example/Test.java b/connector-example/Test.java new file mode 100644 index 0000000..9137bca --- /dev/null +++ b/connector-example/Test.java @@ -0,0 +1,38 @@ +// https://fedoraproject.org/wiki/MariaDB_JDBC_connector +import java.sql.*; + +public class Test { + public static void main(String[] args) throws Exception { + // create our mysql database connection + String host = "localhost"; + String dbname = "information_schema"; + String url = "jdbc:mariadb://" + host + "/" + dbname; + String username = "root"; + String password = ""; + Connection conn = DriverManager.getConnection(url, username, password); + + // our SQL SELECT query. + // if you only need a few columns, specify them by name instead of using "*" + String query = "SELECT * FROM ENGINES"; + + // create the java statement + Statement st = conn.createStatement(); + + // execute the query, and get a java resultset + ResultSet rs = st.executeQuery(query); + + // iterate through the java resultset + while (rs.next()) { + String engine = rs.getString("ENGINE"); + String support = rs.getString("SUPPORT"); + String comment = rs.getString("COMMENT"); + String transactions = rs.getString("TRANSACTIONS"); + String xa = rs.getString("XA"); + String savepoints = rs.getString("SAVEPOINTS"); + + // print the results + System.out.format("%s, %s, %s, %s, %s, %s\n", engine, support, comment, transactions, xa, savepoints); + } + st.close(); + } +} diff --git a/connector-example/main.fmf b/connector-example/main.fmf new file mode 100644 index 0000000..a74a285 --- /dev/null +++ b/connector-example/main.fmf @@ -0,0 +1,26 @@ +summary: example connector usage +description: | + example connector usage +contact: Jakub Heger +component: [] +require: + - mariadb-java-client + - mariadb-server + - util-linux +duration: 5m +enabled: true +tag: + - CI-Tier-1 + - TIPfail_Apps + - TIPpass + - Tier1 +tier: '1' +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1683112 +adjust: + - enabled: false + when: distro == rhel-7 and product != rhscl + continue: false + - enabled: false + when: distro == rhel-alt-7 and product != rhscl + continue: false diff --git a/connector-example/runtest.sh b/connector-example/runtest.sh new file mode 100755 index 0000000..aaea706 --- /dev/null +++ b/connector-example/runtest.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/mariadb-java-client/Sanity/JDBC-connector-example +# Description: example connector usage +# Author: Karel Volný +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="mariadb-java-client" +TestDir=$PWD + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlAssertRpm mariadb-server + rlLogInfo "$(rpm -q --whatprovides java-devel)" + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp Test.java $TmpDir/." + rlRun "pushd $TmpDir" + + rlRun "mariadb-install-db --user=mysql --datadir=/var/lib/mysql" + rlRun "su -s /bin/bash mysql -c \"mariadbd --verbose --general-log=1 &\"" + # wait until the server is ready + rlRun "tail -f /var/log/mariadb/mariadb.log | grep -q 'mariadbd: ready for connections.'" + # Set passwordless root + rlRun "mariadb -u root -e \"grant all privileges on *.* to 'root'@'localhost' identified by '';\"" + rlPhaseEnd + + rlPhaseStartTest + rlRun "java -Djdbc.drivers=org.mariadb.jdbc.Driver -cp /usr/lib/java/mariadb-java-client.jar:. Test.java > output.log" + rlAssertGrep "PERFORMANCE_SCHEMA" "output.log" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "killall mariadbd" + rlRun "rm -r /var/lib/mysql /var/log/mariadb/mariadb.log" + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/main.fmf b/main.fmf index a357a13..5bf60ff 100644 --- a/main.fmf +++ b/main.fmf @@ -1,3 +1,3 @@ -contact: Mikolaj Izdebski +contact: Marian Koncek framework: beakerlib test: ./runtest.sh diff --git a/upstream-testsuite/main.fmf b/upstream-testsuite/main.fmf new file mode 100644 index 0000000..41bd7f0 --- /dev/null +++ b/upstream-testsuite/main.fmf @@ -0,0 +1,32 @@ +summary: Runs upstream testsuite +description: | + Runs the compiled tests using junit5 +enabled: true +tag: + - Tier1 + - rhel-buildroot +tier: '1' +adjust: + - enabled: false + when: arch == s390x + continue: false + - enabled: false + when: distro < rhel-8 + continue: false + - enabled: false + when: distro > rhel-8 + continue: false +contact: Marian Koncek +component: + - mariadb-java-client +framework: beakerlib +require: + - mariadb-server + - mariadb-java-client + - mariadb-java-client-tests + - jna + - junit5 + - apache-commons-lang3 + - osgi-core + - osgi-compendium +duration: 35m diff --git a/upstream-testsuite/runtest.sh b/upstream-testsuite/runtest.sh new file mode 100755 index 0000000..c93e567 --- /dev/null +++ b/upstream-testsuite/runtest.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/postgresql-jdbc/Sanity/upstream-testsuite +# Description: Runs upstream testsuite +# Author: Zuzana Miklankova +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2022 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +REQUIRES="${REQUIRES:-mariadb-java-client}" + +JAVA="${JAVA:-java}" +JAVAC="${JAVAC:-javac}" + +rlJournalStart + rlPhaseStartSetup + rlLog "$(readlink -f $(which $JAVA))" + rlLog "$(readlink -f $(which $JAVAC))" + rlLog "$(rpm -qf /usr/lib/java/mariadb-java-client.jar)" + rlAssertRpm --all + rlRun "useradd mockbuild -m" + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "chmod a+rwx $TmpDir" 0 "fixing directory permissions" + rlRun "pushd $TmpDir" + + rlRun "JUNIT_CLASSPATH=/usr/share/java/mariadb-java-client-tests.jar:/usr/lib/java/mariadb-java-client.jar:" + rlRun "JUNIT_CLASSPATH+=$(cat /usr/share/mariadb-java-client-tests/classpath)" + for jar in ${JUNIT_CLASSPATH//:/ }; do + rlAssertExists "${jar}" + done + + rlRun "mariadb-install-db --user=mysql --datadir=/var/lib/mysql" + rlRun "su -s /bin/bash mysql -c \"mariadbd --general-log=1 --log_warnings=9 &\"" + # wait until the server is ready + rlRun "tail -f /var/log/mariadb/mariadb.log | grep -q 'mariadbd: ready for connections.'" + + # Set passwordless root + rlRun "mariadb -u root -e \"grant all privileges on *.* to 'root'@'localhost' identified by '';\"" + rlRun "mariadb -u root -e \"create database testj;\"" + rlRun "cat /var/log/mariadb/mariadb.log" + rlPhaseEnd + + rlPhaseStartTest + # -Djunit.jupiter.extensions.autodetection.enabled=true -- unneeded for now + rlRun "su mockbuild -c \"ADDITIONAL_FLAGS='-Djunit.jupiter.extensions.autodetection.enabled=true' \ + /usr/bin/junit-platform-console execute -cp ${JUNIT_CLASSPATH}\ + --details=verbose --disable-ansi-colors\ + --exclude-classname 'org.mariadb.jdbc.integration.PooledConnectionTest'\ + --exclude-classname 'org.mariadb.jdbc.integration.ConnectionTest'\ + --exclude-classname 'org.mariadb.jdbc.integration.PoolDataSourceTest'\ + --exclude-classname 'org.mariadb.jdbc.integration.DataSourceTest'\ + ;\"" + if ! rlGetPhaseState; then + rlRun "cat /var/log/mariadb/mariadb.log" + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "killall mariadbd" + rlRun "rm -r /var/lib/mysql /var/log/mariadb/mariadb.log" + rlBundleLogs *.log + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalEnd +rlJournalPrintText +