Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions x-pack/plugin/sql/qa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ dependencies {

// CLI testing dependencies
compile project(path: xpackModule('sql:sql-cli'), configuration: 'nodeps')
compile "org.orbisgis:h2gis-ext:1.3.2"


// H2GIS testing dependencies
compile ("org.orbisgis:h2gis:1.5.0") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opt for externalizing h2gis (and h2 while at it) versions into a central place (like jlineVersion), namely build.gradleundersql`:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I will do that in master first and then make corresponding changes in the branch after merging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #40551 to address this in master. I will fix it for h2gis when I merge master into geosql branch.

exclude group: "org.locationtech.jts"
}

// select just the parts of JLine that are needed
compile("org.jline:jline-terminal-jna:${jlineVersion}") {
exclude group: "net.java.dev.jna"
Expand All @@ -41,12 +45,8 @@ forbiddenApisMain {
replaceSignatureFiles 'es-all-signatures', 'es-test-signatures'
}


thirdPartyAudit.ignoreMissingClasses (
// TODO: Temporary solution until core removes JTS as a dependency
'org.h2gis.functions.factory.H2GISFunctions',
'org.h2gis.network.functions.NetworkFunctions',
)
// just a test fixture: we aren't using this jars in releases and H2GIS requires disabling a lot of checks
thirdPartyAudit.enabled = false

subprojects {
apply plugin: 'elasticsearch.standalone-rest-test'
Expand All @@ -63,8 +63,13 @@ subprojects {

// JDBC testing dependencies
testRuntime "net.sourceforge.csvjdbc:csvjdbc:1.0.34"
testRuntime "com.h2database:h2:1.4.196"
testRuntime "org.orbisgis:h2gis-ext:1.3.2"
testRuntime "com.h2database:h2:1.4.197"

// H2GIS testing dependencies
testRuntime ("org.orbisgis:h2gis:1.5.0") {
exclude group: "org.locationtech.jts"
}

testRuntime project(path: xpackModule('sql:jdbc'), configuration: 'nodeps')
testRuntime xpackProject('plugin:sql:sql-client')

Expand All @@ -89,16 +94,6 @@ subprojects {
testRuntime "org.elasticsearch:jna:${versions.jna}"
}

// TODO: Temporary solution until core removes JTS as a dependency
configurations {
testRuntime {
exclude group: 'org.locationtech.jts', module: 'jts-core'
}
testCompile {
exclude group: 'org.locationtech.jts', module: 'jts-core'
}
}

if (project.name != 'security') {
// The security project just configures its subprojects
apply plugin: 'elasticsearch.rest-test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.elasticsearch.xpack.sql.qa.jdbc.LocalH2;
import org.elasticsearch.xpack.sql.qa.jdbc.SpecBaseIntegrationTestCase;
import org.elasticsearch.xpack.sql.jdbc.JdbcConfiguration;
import org.h2gis.ext.H2GISExtension;
import org.h2gis.functions.factory.H2GISFunctions;
import org.junit.Before;
import org.junit.ClassRule;

Expand All @@ -32,7 +32,7 @@ public abstract class GeoSqlSpecTestCase extends SpecBaseIntegrationTestCase {
@ClassRule
public static LocalH2 H2 = new LocalH2((c) -> {
// Load GIS extensions
H2GISExtension.load(c);
H2GISFunctions.load(c);
c.createStatement().execute("RUNSCRIPT FROM 'classpath:/ogc/sqltsch.sql'");
c.createStatement().execute("RUNSCRIPT FROM 'classpath:/geo/setup_test_geo.sql'");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,7 @@ private static void doAssertResultSetData(ResultSet expected, ResultSet actual,
}
// then timestamp
else if (type == Types.TIMESTAMP || type == Types.TIMESTAMP_WITH_TIMEZONE) {
if (expected.getClass().getName().equals("org.h2.jdbc.JdbcResultSet")) {
// TODO: This is a hack to work around no support for getTimestamp in H2 v1.4.196
// I will remove it before merging when I can upgrade the branch to 1.4.197
assertEquals(msg, expected.getTime(column, UTC_CALENDAR).getTime(),
actual.getTime(column, UTC_CALENDAR).getTime());
} else {
assertEquals(msg, expected.getTimestamp(column), actual.getTimestamp(column));
}
assertEquals(msg, expected.getTimestamp(column), actual.getTimestamp(column));
}
// and floats/doubles
else if (type == Types.DOUBLE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@
*/
package org.elasticsearch.xpack.sql.qa.jdbc;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.CheckedConsumer;
import org.elasticsearch.common.CheckedSupplier;
import org.elasticsearch.common.SuppressForbidden;
import org.junit.rules.ExternalResource;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Locale;
import java.util.Properties;

public class LocalH2 extends ExternalResource implements CheckedSupplier<Connection, SQLException> {
private final Logger logger = LogManager.getLogger(getClass());

/*
* The syntax on the connection string is fairly particular:
Expand Down Expand Up @@ -60,7 +54,6 @@ public static Connection anonymousDb() throws SQLException {
private final String url;
// H2 in-memory will keep the db alive as long as this connection is opened
private Connection keepAlive;
Locale locale;

private CheckedConsumer<Connection, SQLException> initializer;

Expand All @@ -70,14 +63,7 @@ public LocalH2(CheckedConsumer<Connection, SQLException> initializer) {
}

@Override
@SuppressForbidden(reason = "H2 gets really confused with non Gregorian calendars")
protected void before() throws Throwable {
if ("japanese".equals(Calendar.getInstance().getCalendarType())) {
logger.info("Japanese calendar is detected. Overriding locale.");
locale = Locale.getDefault();
Locale.setDefault(locale.stripExtensions()); // removes the calendar setting
assert "gregory".equals(Calendar.getInstance().getCalendarType());
}
keepAlive = get();
initializer.accept(keepAlive);
}
Expand All @@ -89,11 +75,6 @@ protected void after() {
} catch (SQLException ex) {
// close
}
if (locale != null) {
logger.info("Restoring locale.");
Locale.setDefault(locale);
locale = null;
}
}

@Override
Expand Down