Import tests
This commit is contained in:
parent
ab85669e95
commit
18b88dc477
8 changed files with 365 additions and 1 deletions
98
Sanity/basic-sanity/Test.java
Normal file
98
Sanity/basic-sanity/Test.java
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Test.java of /CoreOS/postgresql-jdbc/Sanity/basic-sanity
|
||||
// Description: Runs basic sanity - select, insert, update, delete
|
||||
// Author: Lukas Zachar <lzachar@redhat.com>
|
||||
//
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2013 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.
|
||||
//
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String jdbs_connection = "jdbc:postgresql://127.0.0.1/mydbtest";
|
||||
String user = "dbuser";
|
||||
|
||||
ResultSet rs = null;
|
||||
|
||||
System.out.println("Test:: Begin");
|
||||
try {
|
||||
Connection connection = DriverManager.getConnection(jdbs_connection, user, null);
|
||||
|
||||
Statement stmt = connection.createStatement();
|
||||
|
||||
if (stmt.execute("SELECT VERSION()")) {
|
||||
rs = stmt.getResultSet();
|
||||
while (rs.next()) {
|
||||
System.out.println("SELECT VERSION: " + rs.getString(1));
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Test:: Create table");
|
||||
stmt.execute("CREATE TABLE Writers(Id SERIAL, Name VARCHAR(25))");
|
||||
stmt.execute("INSERT INTO Writers(Name) VALUES('Jack London')");
|
||||
stmt.execute("INSERT INTO Writers(Name) VALUES('Honore de Balzac')");
|
||||
stmt.execute("INSERT INTO Writers(Name) VALUES('Lion Feuchtwanger')");
|
||||
|
||||
System.out.println("Test:: Read newly created table");
|
||||
if (stmt.execute("SELECT * FROM Writers")) {
|
||||
rs = stmt.getResultSet();
|
||||
while (rs.next()) {
|
||||
int myId = rs.getInt("id");
|
||||
String myName = rs.getString("Name");
|
||||
System.out.println(myId + ": " + myName);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Test:: Update row (2-> Maupasant)");
|
||||
if (stmt.executeUpdate("UPDATE Writers SET Name = 'Guy de Maupasant' WHERE Id = 2") != 1 ) {
|
||||
System.out.println("Test:: update count was not 1");
|
||||
}
|
||||
|
||||
System.out.println("Test:: Delete row (1-> London)");
|
||||
if (stmt.executeUpdate("DELETE FROM Writers WHERE Id = 1") != 1) {
|
||||
System.out.println("Test:: delete count was not 1");
|
||||
}
|
||||
|
||||
System.out.println("Test:: Read modified table");
|
||||
if (stmt.execute("SELECT * FROM Writers")) {
|
||||
rs = stmt.getResultSet();
|
||||
while (rs.next()) {
|
||||
int myId = rs.getInt("id");
|
||||
String myName = rs.getString("Name");
|
||||
System.out.println(myId + ": " + myName);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Test:: Drop table");
|
||||
stmt.execute("DROP TABLE Writers");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
System.out.println("Test:: End");
|
||||
}
|
||||
}
|
||||
14
Sanity/basic-sanity/expected.out
Normal file
14
Sanity/basic-sanity/expected.out
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Test:: Begin
|
||||
SELECT VERSION: #REMOVED#
|
||||
Test:: Create table
|
||||
Test:: Read newly created table
|
||||
1: Jack London
|
||||
2: Honore de Balzac
|
||||
3: Lion Feuchtwanger
|
||||
Test:: Update row (2-> Maupasant)
|
||||
Test:: Delete row (1-> London)
|
||||
Test:: Read modified table
|
||||
3: Lion Feuchtwanger
|
||||
2: Guy de Maupasant
|
||||
Test:: Drop table
|
||||
Test:: End
|
||||
18
Sanity/basic-sanity/main.fmf
Normal file
18
Sanity/basic-sanity/main.fmf
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
summary: Runs basic sanity - select, insert, update, delete
|
||||
description: |
|
||||
Runs basic sanity - select, insert, update, delete
|
||||
contact: Lukas Zachar <lzachar@redhat.com>
|
||||
component:
|
||||
- postgresql-jdbc
|
||||
path: /Sanity/basic-sanity
|
||||
framework: beakerlib
|
||||
require:
|
||||
- postgresql-jdbc
|
||||
- postgresql-server
|
||||
- postgresql
|
||||
duration: 25m
|
||||
tag:
|
||||
- Tier1
|
||||
- DBconnectors1
|
||||
- DBconnectors2
|
||||
tier: '1'
|
||||
75
Sanity/basic-sanity/runtest.sh
Executable file
75
Sanity/basic-sanity/runtest.sh
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/postgresql-jdbc/Sanity/basic-sanity
|
||||
# Description: Runs basic sanity - select, insert, update, delete
|
||||
# Author: Lukas Zachar <lzachar@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2013 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:-postgresql-jdbc}"
|
||||
|
||||
# Options for java test
|
||||
CONNECTOR_JAR="${CONNECTOR_JAR:-/usr/share/java/postgresql-jdbc.jar}"
|
||||
|
||||
JAVA="${JAVA:-java}"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlLog "$(readlink -f $(which $JAVA))"
|
||||
rlLog "$(rpm -qf $CONNECTOR_JAR)"
|
||||
rlAssertRpm --all
|
||||
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||
rlRun "chmod 777 $TmpDir" 0 "fixing directory permissions"
|
||||
rlRun "cp expected.out Test.java $TmpDir/."
|
||||
rlRun "pushd $TmpDir"
|
||||
|
||||
rlRun "su - postgres -c 'initdb --auth trust --auth-host trust -D /var/lib/pgsql/data'"
|
||||
rlRun "mkdir /var/run/postgresql/"
|
||||
rlRun "chown postgres /var/run/postgresql/"
|
||||
rlRun "su - postgres -c 'pg_ctl -D /var/lib/pgsql/data -l logfile start'"
|
||||
|
||||
rlRun "su postgres -c 'createuser -d dbuser'"
|
||||
rlRun "su postgres -c 'createdb -O dbuser mydbtest'"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "$JAVA -Djdbc.drivers=org.postgresql.Driver -cp $CONNECTOR_JAR:. Test.java > output.log"
|
||||
rlLog "$(grep 'SELECT VERSION' output.log)"
|
||||
# version will change, so we should remove it
|
||||
sed 's/SELECT VERSION:.*/SELECT VERSION: #REMOVED#/' output.log > removed_version.log
|
||||
rlRun "diff removed_version.log expected.out" 0 "Got expected output"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "su - postgres -c 'pg_ctl stop'"
|
||||
rlRun "rm -r /var/lib/pgsql/data"
|
||||
rlRun "rm -r /var/run/postgresql/"
|
||||
rlBundleLogs "outputs" *.log
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalEnd
|
||||
rlJournalPrintText
|
||||
39
Sanity/upstream-testsuite/main.fmf
Normal file
39
Sanity/upstream-testsuite/main.fmf
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
summary: Runs upstream testsuite
|
||||
description: |
|
||||
Runs the compiled tests using junit5
|
||||
enabled: true
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=2030646
|
||||
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
|
||||
- enabled: false
|
||||
when: distro == Fedora
|
||||
continue: false
|
||||
contact: Vaclav Danek <vdanek@redhat.com>
|
||||
component:
|
||||
- postgresql-jdbc
|
||||
framework: beakerlib
|
||||
require:
|
||||
- postgresql
|
||||
- postgresql-server
|
||||
- postgresql-contrib
|
||||
- postgresql-test-rpm-macros
|
||||
- postgresql-jdbc
|
||||
- postgresql-jdbc-tests
|
||||
- junit5
|
||||
- classloader-leak-test-framework
|
||||
- bcel
|
||||
- apache-commons-lang3
|
||||
duration: 35m
|
||||
64
Sanity/upstream-testsuite/runtest.sh
Executable file
64
Sanity/upstream-testsuite/runtest.sh
Executable 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/postgresql-jdbc/Sanity/upstream-testsuite
|
||||
# Description: Runs upstream testsuite
|
||||
# Author: Zuzana Miklankova <zmiklank@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# 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:-postgresql-jdbc}"
|
||||
|
||||
# Options for java test
|
||||
CONNECTOR_JAR="${CONNECTOR_JAR:-/usr/share/java/postgresql-jdbc.jar}"
|
||||
|
||||
JAVA="${JAVA:-java}"
|
||||
JAVAC="${JAVAC:-javac}"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlLog "$(readlink -f $(which $JAVA))"
|
||||
rlLog "$(readlink -f $(which $JAVAC))"
|
||||
rlLog "$(rpm -qf $CONNECTOR_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"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "su mockbuild $OLDPWD/usertest.sh"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlBundleLogs *.log
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalEnd
|
||||
rlJournalPrintText
|
||||
|
||||
55
Sanity/upstream-testsuite/usertest.sh
Executable file
55
Sanity/upstream-testsuite/usertest.sh
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
exitcode=0
|
||||
|
||||
. /usr/share/postgresql-setup/postgresql_pkg_tests.sh
|
||||
|
||||
PGTESTS_LOCALE=C.UTF-8
|
||||
echo "\
|
||||
server=localhost
|
||||
port=$PGTESTS_PORT
|
||||
database=test
|
||||
username=test
|
||||
password=test
|
||||
privilegedUser=$PGTESTS_ADMIN
|
||||
privilegedPassword=$PGTESTS_ADMINPASS
|
||||
preparethreshold=5
|
||||
loglevel=0
|
||||
protocolVersion=0
|
||||
" > build.local.properties
|
||||
|
||||
ln -s /usr/share/postgresql-jdbc-tests/build.properties .
|
||||
cat build.properties
|
||||
ln -s /usr/share/postgresql-jdbc-tests/ssltest.properties .
|
||||
cat ssltest.properties
|
||||
ln -s /usr/share/postgresql-jdbc-tests/certdir .
|
||||
|
||||
JUNIT_CLASSPATH=/usr/share/java/postgresql-jdbc-tests.jar:/usr/share/java/postgresql-jdbc.jar:
|
||||
JUNIT_CLASSPATH+=$(cat /usr/share/postgresql-jdbc-tests/classpath)
|
||||
for jar in ${JUNIT_CLASSPATH//:/ }; do
|
||||
if ! [ -f "${jar}" ]; then
|
||||
echo "file ${jar} does not exist"
|
||||
exitcode=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $exitcode = 1 ]; then
|
||||
exit $exitcode
|
||||
fi
|
||||
|
||||
pgtests_start
|
||||
|
||||
# -Xmx1536m -- from pom.xml
|
||||
# -ea -- one test uses assert statement, we need to enable it on runtime
|
||||
# -Dbuild.properties.relative.path=. -- from pom.xml
|
||||
# -Djunit.jupiter.extensions.autodetection.enabled=true -- from the debug build logs of a Maven build
|
||||
ADDITIONAL_FLAGS="-Xmx1536m -ea -Dbuild.properties.relative.path=. -Djunit.jupiter.extensions.autodetection.enabled=true" \
|
||||
/usr/bin/junit-platform-console execute -cp "${JUNIT_CLASSPATH}" --select-package org.postgresql\
|
||||
--details=verbose --disable-ansi-colors\
|
||||
--exclude-classname org.postgresql.test.jdbc2.ConnectTimeoutTest\
|
||||
;
|
||||
|
||||
pgtests_stop
|
||||
pgtests_cleanup
|
||||
3
main.fmf
3
main.fmf
|
|
@ -1,3 +1,4 @@
|
|||
contact: Mikolaj Izdebski <mizdebsk@redhat.com>
|
||||
contact: Marian Koncek <mkoncek@redhat.com>
|
||||
framework: beakerlib
|
||||
test: ./runtest.sh
|
||||
component: postgresql-jdbc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue