-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add integration JDBC tests for cursor/fetch_size feature. #208
Add integration JDBC tests for cursor/fetch_size feature. #208
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
What's the difference between small table and big table?
calcs: 17 lines |
This comment was marked as spam.
This comment was marked as spam.
@AfterClass | ||
@SneakyThrows | ||
public static void closeConnection() { | ||
// TODO should we close Statement and ResultSet? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this answered or was this left on purpose for us to see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not answered
I suppose we can leave things unclosed in tests.
file("sql-jdbc").deleteDir() | ||
} | ||
|
||
task cloneJdbcDriverRepo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
task cloneJdbcDriverRepo { | |
task jdbcShadowJarFromRepo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or better yet, separate clone from build so that we don't need to delete/download the JDBC driver from repo each and every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was your requirement to run tests on in-development JDBC driver. Note, this executed in :integ-test:integDevJdbcTest
gradle task only if jdbcFile
parameter not given. This gradle task is not a part of build
or :integ-test:integTest
tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I just think those two tasks could be split into separate tasks rather than having to download + build... in case the build fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly a suggestion I think at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0b817f4
integ-test/build.gradle
Outdated
|
||
exec { | ||
// clone the sql-jdbc repo locally | ||
commandLine 'git', 'clone', System.getProperty('jdbcRepo', 'https://github.com/opensearch-project/sql-jdbc.git') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also get a system property for sql-jdbc branch (System.getProperty("jdbcBranch", 'main'))?
That being said... don't default to main
, you are assuming that main
is the default branch in the repo, but that's defined by the repo and will download the default branch for you if you don't include --branch
git clone --branch <branchname> <remote-repo-url>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 482da6b
integ-test/build.gradle
Outdated
} | ||
exec { | ||
workingDir 'sql-jdbc' | ||
commandLine 'git', 'switch', System.getProperty("jdbcBranch", 'main') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove to just clone the appropriate branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 482da6b
integ-test/build.gradle
Outdated
} | ||
|
||
filter { | ||
includeTestsMatching '*.devJdbc.*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this just one or two files...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one file as of now, but I assume there would be more files in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should specify a project, like org.opensearch.sql.devJdbc.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in d847404
integ-test/build.gradle
Outdated
@@ -406,4 +528,6 @@ task integTestRemote(type: RestIntegTestTask) { | |||
exclude 'org/opensearch/sql/legacy/TermQueryExplainIT.class' | |||
exclude 'org/opensearch/sql/legacy/QueryAnalysisIT.class' | |||
exclude 'org/opensearch/sql/legacy/OrderIT.class' | |||
exclude '**/jdbc/**' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd include the root directory structure... like
org/opensearch/sql/jdbc/**
org/opensearch/sql/devJdbc/**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 482da6b
integ-test/build.gradle
Outdated
@@ -214,6 +326,10 @@ task comparisonTest(type: RestIntegTestTask) { | |||
exclude 'org/opensearch/sql/ppl/**/*IT.class' | |||
exclude 'org/opensearch/sql/legacy/**/*IT.class' | |||
|
|||
// Exclude JDBC related tests | |||
exclude '**/jdbc/**' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd include the root directory structure... like
org/opensearch/sql/jdbc/**
org/opensearch/sql/devJdbc/**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 482da6b
integ-test/build.gradle
Outdated
@@ -192,10 +297,17 @@ integTest { | |||
|
|||
// Skip this IT because all assertions are against explain output | |||
exclude 'org/opensearch/sql/legacy/OrderIT.class' | |||
|
|||
// Exclude JDBC related tests | |||
exclude '**/jdbc/**' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd include the root directory structure... like
org/opensearch/sql/jdbc/**
org/opensearch/sql/devJdbc/**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 482da6b
@BeforeEach | ||
@SneakyThrows | ||
public void init() { | ||
if (!initialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this under the @BeforeAll below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I call initClient
from init
, which can't be called from a static method. @BeforeAll
requires method to be static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also do
if (client() == null) {
initClient();
}
like the other classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initClient
doesn't work in a static context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yury-Fridlyand Could you split the integration tests from the build changes?
The integration tests look good, but support for a custom JDBC driver can be done in more standard way.
After applying the diffs below, you'll be able to use a custom JDBC driver by building it with ./gradlew publishToMavenLocal -Pversion=1.13.0-MAXSPECIAL
and then using 1.13.0-MAXSPECIAL
in integration tests by running ./gradlew :integTest:build -Pjdbc_driver_version=1.99.0-MAXSPECIAL
This would also support snapshot builds of JDBC driver if OpenSearch project ever provides them.
The above requires this change to sqj-jdbc
:
diff --git a/build.gradle b/build.gradle
index 436cad3..b91f7de 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,9 +24,6 @@ plugins {
group 'org.opensearch.driver'
-// keep version in sync with version in Driver source
-version '1.2.0.0'
-
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "false"));
if (snapshot) {
version += "-SNAPSHOT"
and this change to sql
:
diff --git a/gradle.properties b/gradle.properties
index 5cf428415..81338cd21 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,4 +3,5 @@
# SPDX-License-Identifier: Apache-2.0
version=1.13.0
+jdbc_driver_version=1.2.0.0
org.gradle.jvmargs=-Duser.language=en -Duser.country=US
diff --git a/integ-test/build.gradle b/integ-test/build.gradle
index c948dc77c..fc04f66f8 100644
--- a/integ-test/build.gradle
+++ b/integ-test/build.gradle
@@ -80,7 +80,7 @@ dependencies {
testImplementation group: 'org.opensearch.test', name: 'framework', version: "${opensearch_version}"
testImplementation group: 'org.opensearch.client', name: 'opensearch-rest-high-level-client', version: "${opensearch_version}"
testImplementation group: 'org.opensearch.client', name: 'opensearch-rest-client', version: "${opensearch_version}"
- testImplementation group: 'org.opensearch.driver', name: 'opensearch-sql-jdbc', version: '1.2.0.0'
+ testImplementation group: 'org.opensearch.driver', name: 'opensearch-sql-jdbc', version: "${jdbc_driver_version}"
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.17.1'
testImplementation project(':opensearch-sql-plugin')
Signed-off-by: Yury-Fridlyand <[email protected]>
…pment JDBC driver. Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
482da6b
to
e9df987
Compare
Fixed in e9df987. |
file("sql-jdbc").deleteDir() | ||
} | ||
|
||
task cloneJdbcDriverRepo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I just think those two tasks could be split into separate tasks rather than having to download + build... in case the build fails.
file("sql-jdbc").deleteDir() | ||
} | ||
|
||
task cloneJdbcDriverRepo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly a suggestion I think at this point.
integ-test/build.gradle
Outdated
} | ||
|
||
filter { | ||
includeTestsMatching '*.devJdbc.*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should specify a project, like org.opensearch.sql.devJdbc.*
@BeforeEach | ||
@SneakyThrows | ||
public void init() { | ||
if (!initialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also do
if (client() == null) {
initClient();
}
like the other classes.
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
* Add integration JDBC tests for cursor/fetch_size feature. Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand [email protected]
Description
Add new IT suite which uses JDBC to issue queries with and without
fetch_size
set.fetch_size
parameter invokes pagination feature (cursor
) which is currently supported by legacy engine only.New
:integ-test
tasks:integJdbcTest
Run ITs from
**/jdbc/*.java
. Existing tests inCursorIT
create and use DB connection using JDBC driver from maven artifact.Optional parameters:
-Dtest.debug
Enabled test debug.
--tests '<test_filter>
Filter test using wildcard, could be specified multiple times.
-DjdbcDriverVersion=<version>
Maven artifact version for JDBC driver to use; optional, defaulted to
1.2.0.0
.Test cluster log located in
integ-test/build/testclusters/integJdbcTest-0/logs/integJdbcTest.log
Test report saved in
integ-test/build/reports/tests/integJdbcTest
integDevJdbcTest
Run ITs from
**/devJdbc/*.java
. Existing tests inCursorIT
create and use DB connection using JDBC driver from source code or existing binary.Optional parameters:
-Dtest.debug
Enabled test debug.
--tests '<test_filter>
Filter test using wildcard, could be specified multiple times.
-DjdbcFile=<file>
JDBC driver compiled binary (*.jar); if given, workflow uses it and ignores
jdbcRepo
andjdbcBranch
parameters described below.-DjdbcRepo=<repo_path>
JDBC driver repo to checkout and build from; uses
https://github.com/opensearch-project/sql
by default.-DjdbcBranch=<branch>
Repository branch to pick code from; uses
main
by default.Test cluster log located in
integ-test/build/testclusters/integDevJdbcTest-0/logs/integDevJdbcTest.log
Test report saved in
integ-test/build/reports/tests/integDevJdbcTest
Examples:
Output sample:
Notes
Test filter in gradle
opensearch-project-sql/integ-test/build.gradle
Lines 204 to 206 in 24de6ff
requires
opensearch-project-sql/integ-test/build.gradle
Line 177 in 24de6ff
and doesn't work with JUnit 4. All IT framework uses Junit 4.
So,
init()
method of test classed isn't being called from superclasses automatically.@BeforeAll
/@BeforeClass
require a static method, so I can't callinitClient()
there. I have to moveinitClient()
to@BeforeEach
withinitialized
flag.New gradle tasks are not included into CI workflow.
Issues Resolved
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.