Skip to content

[Backport main] Create 2.x branch and update accordingly #42

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

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 0 additions & 5 deletions TODOs.txt

This file was deleted.

125 changes: 45 additions & 80 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform


buildscript {
Expand All @@ -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'
Expand All @@ -47,49 +46,29 @@ 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) {
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
}

static def getShadowPath(String path) {
return 'org.opensearch.sql.jdbc.shadow.' + path
return 'com.amazonaws.opensearch.sql.jdbc.shadow.' + path
}

shadowJar {
Expand All @@ -107,14 +86,18 @@ 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')
relocate 'software.amazon', getShadowPath('software.amazon')
}

test {
systemProperty("opensearch_jdbc_version", version);
useJUnitPlatform()
}

Expand All @@ -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:[email protected]:opensearch-project/sql.git"
developerConnection = "scm:[email protected]:opensearch-project/sql.git"
url = "[email protected]: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:[email protected]:opensearch-project/sql.git"
developerConnection = "scm:[email protected]:opensearch-project/sql.git"
url = "[email protected]: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:[email protected]:opensearch-project/sql.git"
developerConnection = "scm:[email protected]:opensearch-project/sql.git"
url = "[email protected]: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"
Expand All @@ -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
Expand Down Expand Up @@ -234,6 +201,4 @@ jacocoTestCoverageVerification {
}
}



check.dependsOn jacocoTestCoverageVerification
2 changes: 1 addition & 1 deletion src/main/java/org/opensearch/jdbc/ConnectionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/opensearch/jdbc/internal/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
}
}
6 changes: 2 additions & 4 deletions src/test/java/org/opensearch/jdbc/test/TLSServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -132,8 +132,6 @@ private static ServerConnector createServerConnector(
connectionFactories
);
connector.setPort(port);
connector.setStopTimeout(0);
connector.getSelectorManager().setStopTimeout(0);
connector.setHost(bindAddress);

return connector;
Expand Down