Import tests

This commit is contained in:
Marian Koncek 2025-03-06 20:54:43 +01:00
commit 7e9050edf5
9 changed files with 375 additions and 1 deletions

View file

@ -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();
}
}

View file

@ -0,0 +1,26 @@
summary: example connector usage
description: |
example connector usage
contact: Jakub Heger <jheger@redhat.com>
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

64
connector-example/runtest.sh Executable file
View file

@ -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ý <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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