From 750949ff8826ff11e43cd3053d8d718843b9996b Mon Sep 17 00:00:00 2001 From: YANGDB Date: Thu, 15 Dec 2022 16:41:40 -0800 Subject: [PATCH] Create 2.x branch and update accordingly (#38) Create 2.x branch and update accordingly (#38) Signed-off-by: YANGDB --- TODOs.txt | 5 - build.gradle | 125 +++++++----------- .../org/opensearch/jdbc/ConnectionImpl.java | 2 +- .../org/opensearch/jdbc/internal/Version.java | 4 +- .../jdbc/internal/VersionMatchTest.java | 17 +++ .../org/opensearch/jdbc/test/TLSServer.java | 6 +- 6 files changed, 67 insertions(+), 92 deletions(-) delete mode 100644 TODOs.txt create mode 100644 src/test/java/org/opensearch/jdbc/internal/VersionMatchTest.java diff --git a/TODOs.txt b/TODOs.txt deleted file mode 100644 index 9087bc7..0000000 --- a/TODOs.txt +++ /dev/null @@ -1,5 +0,0 @@ -add maven jdbc publish workflow: - https://github.com/opensearch-project/sql/pull/957 - https://github.com/opensearch-project/opensearch-build/issues/2505 - https://github.com/opensearch-project/opensearch-build/issues/2692 - diff --git a/build.gradle b/build.gradle index dba2ea8..1aa135a 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,6 @@ * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform buildscript { @@ -22,7 +21,7 @@ plugins { id 'signing' } -group 'org.opensearch.driver' +group 'org.opensearch.client' // keep version in sync with version in Driver source version '2.0.0.0' @@ -47,41 +46,21 @@ repositories { dependencies { implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13' - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.13.3" + implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.13.4.2" implementation group: 'com.amazonaws', name: 'aws-java-sdk-core', version: '1.11.452' testImplementation('org.junit.jupiter:junit-jupiter-api:5.3.1') testImplementation('org.junit.jupiter:junit-jupiter-params:5.3.1') - testImplementation('com.github.tomakehurst:wiremock:2.27.2') + testImplementation('com.github.tomakehurst:wiremock-jre8-standalone:2.34.0') testImplementation('org.mockito:mockito-core:2.23.0') testImplementation('org.junit.jupiter:junit-jupiter-engine:5.3.1') testImplementation('org.junit-pioneer:junit-pioneer:0.3.0') - testImplementation('org.eclipse.jetty:jetty-server:9.2.24.v20180105') + testImplementation('org.eclipse.jetty:jetty-server:9.4.48.v20220622') - // Enforce wiremock to use latest guava and json-smart + // Enforce wiremock to use latest guava testImplementation('com.google.guava:guava:31.1-jre') - testImplementation('net.minidev:json-smart:2.4.8') testRuntimeOnly('org.slf4j:slf4j-simple:1.7.25') // capture WireMock logging - - // JDBC drivers for comparison test. Somehow Apache Derby throws security permission exception. - testImplementation fileTree('/build/libs') { - include '*.jar' - builtBy 'compileJdbc' - } - testImplementation group: 'com.h2database', name: 'h2', version: '2.1.210' - testImplementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.28.0' - testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9' -} - -task compileJdbc(type: Exec) { - if (DefaultNativePlatform.getCurrentOperatingSystem().isWindows()) { - commandLine './gradlew.bat', 'build' - commandLine './gradlew.bat', 'shadowJar' - } else { - commandLine './gradlew', 'build' - commandLine './gradlew', 'shadowJar' - } } tasks.withType(JavaCompile) { @@ -89,7 +68,7 @@ tasks.withType(JavaCompile) { } static def getShadowPath(String path) { - return 'org.opensearch.sql.jdbc.shadow.' + path + return 'com.amazonaws.opensearch.sql.jdbc.shadow.' + path } shadowJar { @@ -107,7 +86,10 @@ shadowJar { exclude 'META-INF/NOTICE*' exclude 'META-INF/DEPENDENCIES' - relocate 'com.amazonaws', getShadowPath('com.amazonaws') + relocate('com.amazonaws', getShadowPath('com.amazonaws')) { + exclude 'com.amazonaws.opensearch.*/**' + } + relocate 'org.apache', getShadowPath('org.apache') relocate 'org.joda', getShadowPath('org.joda') relocate 'com.fasterxml', getShadowPath('com.fasterxml') @@ -115,6 +97,7 @@ shadowJar { } test { + systemProperty("opensearch_jdbc_version", version); useJUnitPlatform() } @@ -136,59 +119,47 @@ publishing { artifact javadocJar pom { - name = "OpenSearch SQL JDBC Driver" - packaging = "jar" - url = "https://github.com/opensearch-project/sql/sql-jdbc" - description = "OpenSearch SQL JDBC driver" - scm { - connection = "scm:git@github.com:opensearch-project/sql.git" - developerConnection = "scm:git@github.com:opensearch-project/sql.git" - url = "git@github.com:opensearch-project/sql.git" - } - licenses { - license { - name = "The Apache License, Version 2.0" - url = "http://www.apache.org/licenses/LICENSE-2.0.txt" - } + name = "OpenSearch SQL JDBC Driver" + packaging = "jar" + url = "https://github.com/opensearch-project/sql" + description = "OpenSearch SQL JDBC driver" + scm { + connection = "scm:git@github.com:opensearch-project/sql.git" + developerConnection = "scm:git@github.com:opensearch-project/sql.git" + url = "git@github.com:opensearch-project/sql.git" + } + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" } - developers { - developer { - name = 'OpenSearch' - url = 'https://github.com/opensearch-project/sql' - } - } - } - } - publishMaven(MavenPublication) { publication -> - from components.java - - pom { - name = "OpenSearch SQL JDBC Driver" - packaging = "jar" - url = "https://github.com/opensearch-project/sql/sql-jdbc" - description = "OpenSearch SQL JDBC driver" - scm { - connection = "scm:git@github.com:opensearch-project/sql.git" - developerConnection = "scm:git@github.com:opensearch-project/sql.git" - url = "git@github.com:opensearch-project/sql.git" - } - licenses { - license { - name = "The Apache License, Version 2.0" - url = "http://www.apache.org/licenses/LICENSE-2.0.txt" - } - } - developers { - developer { - name = 'OpenSearch' - url = 'https://github.com/opensearch-project/sql' - } + } + developers { + developer { + id = "amazonwebservices" + organization = "Amazon Web Services" + organizationUrl = "https://aws.amazon.com" } + } } } } repositories { + maven { + name = "internal-snapshots" + url = "s3://snapshots.opendistroforelasticsearch.amazon.com/maven" + authentication { + awsIm(AwsImAuthentication) // load from EC2 role or env var + } + } + maven { + name = "internal-releases" + url = "s3://artifacts.opendistroforelasticsearch.amazon.com/maven" + authentication { + awsIm(AwsImAuthentication) // load from EC2 role or env var + } + } maven { name = "sonatype-staging" url "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2" @@ -197,10 +168,6 @@ publishing { password project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : '' } } - maven { - name = "localRepo" - url "${project.buildDir}/repository" - } } // TODO - enabled debug logging for the time being, remove this eventually @@ -234,6 +201,4 @@ jacocoTestCoverageVerification { } } - - check.dependsOn jacocoTestCoverageVerification diff --git a/src/main/java/org/opensearch/jdbc/ConnectionImpl.java b/src/main/java/org/opensearch/jdbc/ConnectionImpl.java index e6a8587..337365e 100644 --- a/src/main/java/org/opensearch/jdbc/ConnectionImpl.java +++ b/src/main/java/org/opensearch/jdbc/ConnectionImpl.java @@ -507,7 +507,7 @@ public Logger getLog() { } private String getUserAgent() { - return String.format("openes-jdbc/%s (Java %s)", + return String.format("opensearch-jdbc/%s (Java %s)", Version.Current.getFullVersion(), JavaUtil.getJavaVersion()); } } diff --git a/src/main/java/org/opensearch/jdbc/internal/Version.java b/src/main/java/org/opensearch/jdbc/internal/Version.java index 977e743..006f0b6 100644 --- a/src/main/java/org/opensearch/jdbc/internal/Version.java +++ b/src/main/java/org/opensearch/jdbc/internal/Version.java @@ -8,8 +8,8 @@ public enum Version { - // keep this in sync with the gradle version - Current(1, 0, 0, 0); + // keep this in sync with the sql-jdbc/build.gradle file + Current(2, 0, 0, 0); private int major; private int minor; diff --git a/src/test/java/org/opensearch/jdbc/internal/VersionMatchTest.java b/src/test/java/org/opensearch/jdbc/internal/VersionMatchTest.java new file mode 100644 index 0000000..4826227 --- /dev/null +++ b/src/test/java/org/opensearch/jdbc/internal/VersionMatchTest.java @@ -0,0 +1,17 @@ +package org.opensearch.jdbc.internal; +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import org.junit.jupiter.api.Test; +import org.opensearch.jdbc.internal.Version; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class VersionMatchTest { + + @Test + void testVersionMatchesBuildGradleVersion() { + assertEquals(Version.Current.getFullVersion(), System.getProperty("opensearch_jdbc_version")); + } +} diff --git a/src/test/java/org/opensearch/jdbc/test/TLSServer.java b/src/test/java/org/opensearch/jdbc/test/TLSServer.java index cb57fdb..0bc5f6d 100644 --- a/src/test/java/org/opensearch/jdbc/test/TLSServer.java +++ b/src/test/java/org/opensearch/jdbc/test/TLSServer.java @@ -20,9 +20,9 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletException; import java.io.IOException; public class TLSServer { @@ -70,7 +70,7 @@ public static Server startSecureServer( ServerConnector httpsConnector = null; // setup ssl - SslContextFactory sslContextFactory = new SslContextFactory(); + SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); sslContextFactory.setKeyStorePath(keyStorePath); sslContextFactory.setKeyStorePassword(keyStorePassword); sslContextFactory.setKeyStoreType(keyStoreType); @@ -132,8 +132,6 @@ private static ServerConnector createServerConnector( connectionFactories ); connector.setPort(port); - connector.setStopTimeout(0); - connector.getSelectorManager().setStopTimeout(0); connector.setHost(bindAddress); return connector;