Permalink
Browse files

test: add CI tests against PostgreSQL 8.2 (#659)

  • Loading branch information...
vlsi committed Nov 14, 2016
1 parent a29ad80 commit 63ee60e2ad93441ff55dab08213cc09815b614e0
@@ -9,8 +9,8 @@ before_script:
- psql -U postgres -c "create user test with password 'test';"
- psql -c 'create database test owner test;' -U postgres
- echo "MAVEN_OPTS='-Xmx1g -Dgpg.skip=true'" > ~/.mavenrc
- test "x$PG_VERSION" == 'x' || test $PG_VERSION == '8.4' || test $PG_VERSION == '9.0' || psql test -c 'CREATE EXTENSION hstore;' -U postgres
- test "x$PG_VERSION" == 'x' || test $PG_VERSION != '8.4' || createlang -U postgres plpgsql test
- test "x$PG_VERSION" == 'x' || test "x$NO_HSTORE" == 'xY' || psql test -c 'CREATE EXTENSION hstore;' -U postgres
- test "x$PG_VERSION" == 'x' || test "x$CREATE_PLPGSQL" == 'x' || createlang -U postgres plpgsql test
- if [[ "x$JDK" == *'x9'* ]]; then remove_dir_from_path $JAVA_HOME/bin; export JAVA_HOME=/usr/lib/jvm/java-9-oracle; export PATH=$JAVA_HOME/bin:$PATH; java -Xmx32m -version; fi
env:
@@ -51,6 +51,13 @@ cache:
matrix:
fast_finish: true
allow_failures:
- env: # this has to match the environment for 8.2 below
- PG_VERSION=8.2
- XA=true
- COVERAGE=Y
- NO_HSTORE=Y
- CREATE_PLPGSQL=Y
include:
- env:
- FEDORA_CI=Y
@@ -79,6 +86,17 @@ matrix:
- PG_VERSION=8.4
- XA=true
- COVERAGE=Y
- NO_HSTORE=Y
- CREATE_PLPGSQL=Y
- jdk: oraclejdk8
sudo: required
dist: precise
env: # this has to match allow_failures above
- PG_VERSION=8.2
- XA=true
- COVERAGE=Y
- NO_HSTORE=Y
- CREATE_PLPGSQL=Y
- jdk: oraclejdk8
env: RUN_CHECKSTYLE=true
script: mvn checkstyle:check
@@ -9,6 +9,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.postgresql.core.ServerVersion;
import org.postgresql.jdbc.PreferQueryMode;
import org.postgresql.test.TestUtil;
import org.postgresql.test.jdbc2.BaseTest4;
@@ -38,6 +39,8 @@ public void setUp() throws Exception {
_conn = con;
Assume.assumeFalse("hstore is not supported in simple protocol only mode",
preferQueryMode == PreferQueryMode.SIMPLE);
Assume.assumeTrue("hstore requires PostgreSQL 8.3+",
TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_3));
}
@Override
@@ -9,6 +9,7 @@
import org.postgresql.PGProperty;
import org.postgresql.core.BaseConnection;
import org.postgresql.core.ResultHandler;
import org.postgresql.core.ServerVersion;
import org.postgresql.core.TransactionState;
import org.postgresql.jdbc.AutoSave;
import org.postgresql.jdbc.PgConnection;
@@ -17,6 +18,7 @@
import org.postgresql.util.PSQLState;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -98,6 +100,10 @@ public void setUp() throws Exception {
con.setAutoCommit(autoCommit == AutoCommit.YES);
BaseConnection baseConnection = con.unwrap(BaseConnection.class);
baseConnection.setFlushCacheOnDeallocate(flushCacheOnDeallocate);
Assume.assumeTrue("DEALLOCATE ALL requires PostgreSQL 8.3+",
failMode != FailMode.DEALLOCATE || TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_3));
Assume.assumeTrue("DISCARD ALL requires PostgreSQL 8.3+",
failMode != FailMode.DISCARD || TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_3));
}
@Override
@@ -11,6 +11,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.postgresql.core.ServerVersion;
import org.postgresql.test.TestUtil;
import org.junit.After;
@@ -50,7 +51,10 @@ public void setUp() throws Exception {
TestUtil.createTable(con, "intarraytable", "a int4[], b int4[][]");
TestUtil.createCompositeType(con, "custom", "i int");
TestUtil.createCompositeType(con, "_custom", "f float");
TestUtil.createTable(con, "customtable", "c1 custom, c2 _custom, c3 custom[], c4 _custom[]");
// 8.2 does not support _custom[]. ERROR: type "_custom[]" does not exist
TestUtil.createTable(con, "customtable", "c1 custom, c2 _custom, c3 custom[]"
+ (TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_3) ? ", c4 _custom[]" : ""));
Statement stmt = con.createStatement();
// we add the following comments to ensure the joins to the comments
@@ -70,8 +74,11 @@ public void setUp() throws Exception {
}
stmt.execute(
"CREATE OR REPLACE FUNCTION f4(int) RETURNS metadatatest AS 'SELECT 1, ''a''::text, now(), ''c''::text, ''q''::text' LANGUAGE SQL");
stmt.execute(
"CREATE OR REPLACE FUNCTION f5() RETURNS TABLE (i int) LANGUAGE sql AS 'SELECT 1'");
if (TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_4)) {
// RETURNS TABLE requires PostgreSQL 8.4+
stmt.execute(
"CREATE OR REPLACE FUNCTION f5() RETURNS TABLE (i int) LANGUAGE sql AS 'SELECT 1'");
}
if (TestUtil.haveMinimumServerVersion(con, "7.3")) {
TestUtil.createDomain(con, "nndom", "int not null");
@@ -150,8 +157,10 @@ public void testCustomArrayTypeInfo() throws SQLException {
assertEquals("_custom", res.getString("TYPE_NAME"));
assertTrue(res.next());
assertEquals("__custom", res.getString("TYPE_NAME"));
assertTrue(res.next());
assertEquals("___custom", res.getString("TYPE_NAME"));
if (TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_3)) {
assertTrue(res.next());
assertEquals("___custom", res.getString("TYPE_NAME"));
}
con.createArrayOf("custom", new Object[] {});
res = dbmd.getColumns(null, null, "customtable", null);
assertTrue(res.next());
@@ -160,8 +169,10 @@ public void testCustomArrayTypeInfo() throws SQLException {
assertEquals("_custom", res.getString("TYPE_NAME"));
assertTrue(res.next());
assertEquals("__custom", res.getString("TYPE_NAME"));
assertTrue(res.next());
assertEquals("___custom", res.getString("TYPE_NAME"));
if (TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_3)) {
assertTrue(res.next());
assertEquals("___custom", res.getString("TYPE_NAME"));
}
}
@Test
@@ -813,6 +824,9 @@ public void testFuncReturningComposite() throws SQLException {
@Test
public void testFuncReturningTable() throws Exception {
if (!TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_4)) {
return;
}
DatabaseMetaData dbmd = con.getMetaData();
ResultSet rs = dbmd.getProcedureColumns(null, null, "f5", null);
assertTrue(rs.next());
@@ -5,6 +5,7 @@
package org.postgresql.test.jdbc3;
import org.postgresql.core.ServerVersion;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
@@ -24,14 +25,18 @@ public StringTypeParameterTest(String name) {
super(name);
}
protected void setUp(String stringType) throws Exception {
protected boolean setUp(String stringType) throws Exception {
Properties props = new Properties();
if (stringType != null) {
props.put("stringtype", stringType);
}
_conn = TestUtil.openDB(props);
if (TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3)) {
return false;
}
TestUtil.createEnumType(_conn, "mood", "'happy', 'sad'");
TestUtil.createTable(_conn, "stringtypetest", "m mood");
return true;
}
protected void tearDown() throws SQLException {
@@ -57,7 +62,9 @@ public void testParameterStringTypeNotSet() throws Exception {
}
private void testParameterVarchar(String param) throws Exception {
setUp(param);
if (!setUp(param)) {
return;
}
PreparedStatement update = _conn.prepareStatement("insert into stringtypetest (m) values (?)");
update.setString(1, "sad");
@@ -115,7 +122,9 @@ private void testParameterVarchar(String param) throws Exception {
}
public void testParameterUnspecified() throws Exception {
setUp("unspecified");
if (!setUp("unspecified")) {
return;
}
PreparedStatement update = _conn.prepareStatement("insert into stringtypetest (m) values (?)");
update.setString(1, "happy");
@@ -5,6 +5,7 @@
package org.postgresql.test.jdbc4;
import org.postgresql.core.ServerVersion;
import org.postgresql.geometric.PGbox;
import org.postgresql.jdbc.PreferQueryMode;
import org.postgresql.test.TestUtil;
@@ -53,7 +54,9 @@ public void setUp() throws Exception {
_conn = con;
TestUtil.createTable(_conn, "arrtest",
"intarr int[], decarr decimal(2,1)[], strarr text[], uuidarr uuid[], floatarr float8[]"
"intarr int[], decarr decimal(2,1)[], strarr text[]"
+ (TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3) ? ", uuidarr uuid[]" : "")
+ ", floatarr float8[]"
+ ", intarr2 int4[][]");
TestUtil.createTable(_conn, "arrcompprnttest", "id serial, name character(10)");
TestUtil.createTable(_conn, "arrcompchldttest",
@@ -247,7 +250,8 @@ public void testCreatePrimitiveArray() throws SQLException {
public void testUUIDArray() throws SQLException {
Assume.assumeTrue("UUID is not supported in PreferQueryMode.SIMPLE",
preferQueryMode != PreferQueryMode.SIMPLE);
Assume.assumeTrue("UUID requires PostgreSQL 8.3+",
TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3));
UUID uuid1 = UUID.randomUUID();
UUID uuid2 = UUID.randomUUID();
UUID uuid3 = UUID.randomUUID();
@@ -94,11 +94,11 @@ public void setUp() throws Exception {
+ "circle_column circle,"
+ "money_column money,"
+ "interval_column interval,"
+ "uuid_column uuid,"
+ (TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3) ? "uuid_column uuid," : "")
+ "inet_column inet,"
+ "cidr_column cidr,"
+ "macaddr_column macaddr,"
+ "xml_column xml"
+ "macaddr_column macaddr"
+ (TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3) ? ",xml_column xml" : "")
);
}
@@ -608,6 +608,10 @@ public void testGetArray() throws SQLException {
*/
@Test
public void testGetXml() throws SQLException {
if (!TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3)) {
// XML column requires PostgreSQL 8.3+
return;
}
Statement stmt = _conn.createStatement();
String content = "<book><title>Manual</title></book>";
stmt.executeUpdate(TestUtil.insertSQL("table1","xml_column","XMLPARSE (DOCUMENT '<?xml version=\"1.0\"?><book><title>Manual</title></book>')"));
@@ -814,6 +818,10 @@ public void testGetInterval() throws SQLException {
*/
@Test
public void testGetUuid() throws SQLException {
if (!TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3)) {
// UUID requires PostgreSQL 8.3+
return;
}
Statement stmt = _conn.createStatement();
String expected = "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11";
stmt.executeUpdate(TestUtil.insertSQL("table1","uuid_column","'" + expected + "'"));

0 comments on commit 63ee60e

Please sign in to comment.