Skip to content
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

Version 2.0 #507

Merged
merged 2 commits into from
Mar 24, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/draft-release-notes-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
with:
config-name: draft-release-notes-config.yml
tag: (None)
version: 1.3.0.0
version: 2.0.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/sql-odbc-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
ODBC_BUILD_PATH: "./build/odbc/build"
AWS_SDK_INSTALL_PATH: "./build/aws-sdk/install"
PLUGIN_NAME: opensearch-sql-odbc
OD_VERSION: 1.3.0.0
OD_VERSION: 2.0.0.0

jobs:
build-mac:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- rename*

env:
OD_VERSION: 1.3.0.0
OD_VERSION: 2.0.0.0

jobs:
upload-odbc:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/sql-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: SQL Java CI
on: [push, pull_request]

env:
OPENSEARCH_VERSION: '1.3.0-SNAPSHOT'
OPENSEARCH_VERSION: '2.0.0-SNAPSHOT'

jobs:
build:
strategy:
matrix:
java:
- 8
- 11
- 14
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sql-workbench-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:

env:
PLUGIN_NAME: query-workbench-dashboards
OPENSEARCH_VERSION: '1.x'
OPENSEARCH_PLUGIN_VERSION: 1.3.0.0
OPENSEARCH_VERSION: 'main'
OPENSEARCH_PLUGIN_VERSION: 2.0.0.0

jobs:

Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '10.24.1'
node-version: '14.18.2'

- name: Move Workbench to Plugins Dir
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sql-workbench-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on: [pull_request, push]

env:
PLUGIN_NAME: query-workbench-dashboards
OPENSEARCH_VERSION: '1.x'
OPENSEARCH_PLUGIN_VERSION: 1.3.0.0
OPENSEARCH_VERSION: 'main'
OPENSEARCH_PLUGIN_VERSION: 2.0.0.0

jobs:

Expand All @@ -27,7 +27,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '10.24.1'
node-version: '14.18.2'

- name: Move Workbench to Plugins Dir
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ gen
*/.venv
*/__pycache__
*.iml
.DS_Store
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>

<connector-plugin class='opensearch_jdbc' superclass='jdbc' plugin-version='1.3.0.0' name='OpenSearch' version='18.1' min-version-tableau='2021.1'>
<connector-plugin class='opensearch_jdbc' superclass='jdbc' plugin-version='2.0.0.0' name='OpenSearch' version='18.1' min-version-tableau='2021.1'>
<vendor-information>
<company name="OpenSearch Project"/>
<support-link url="https:/opensearch-project/sql"/>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "1.3.0-SNAPSHOT")
opensearch_version = System.getProperty("opensearch.version", "2.0.0-SNAPSHOT")
}

repositories {
Expand Down
12 changes: 12 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apply plugin: 'groovy'
apply plugin: 'java'


repositories {
mavenCentral()
}

dependencies {
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this change is required by all plugin? if so, could you add related issue/pr.

Copy link
Member Author

Choose a reason for hiding this comment

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

We are using a third party plugin to spawn and kill process in doctest module. The plugin is around 5 years old and there is no active development. As part of Gradle 7 upgrade spawn plugin is throwing errors. As part of fix, imported the plugin code to buildSrc and upgraded to Gradle 7.[The only way for upgrading unmaintained third party plugins]. I couldn't find another well maintained plugin to replace.

Copy link
Member Author

Choose a reason for hiding this comment

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

#303. Will add to the description.

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks. could we create an issue to tracking move this dependency later. ideally, we should not depend on it.

implementation gradleApi()
implementation localGroovy()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.wiredforcode.gradle.spawn

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Internal


class DefaultSpawnTask extends DefaultTask {

@Internal
String pidLockFileName = '.pid.lock'
@Internal
String directory = '.'

@Internal
File getPidFile() {
return new File(directory, pidLockFileName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.wiredforcode.gradle.spawn

import org.gradle.api.tasks.TaskAction

class KillProcessTask extends DefaultSpawnTask {
Copy link
Member

Choose a reason for hiding this comment

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

what is this for?

Copy link
Member Author

Choose a reason for hiding this comment

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

#507 (comment)

Commented here.

@TaskAction
void kill() {
def pidFile = getPidFile()
if(!pidFile.exists()) {
logger.quiet "No server running!"
return
}

def pid = pidFile.text
def process = "kill $pid".execute()

try {
process.waitFor()
} finally {
pidFile.delete()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.wiredforcode.gradle.spawn

import org.gradle.api.Plugin
import org.gradle.api.Project


class SpawnPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.with {
ext.SpawnProcessTask = SpawnProcessTask
ext.KillProcessTask = KillProcessTask

task('spawnProcess', type: SpawnProcessTask)
task('killProcess', type: KillProcessTask)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.wiredforcode.gradle.spawn

import org.gradle.api.GradleException
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction

class SpawnProcessTask extends DefaultSpawnTask {
@Input
String command
@Input
String ready
@Internal
List<Closure> outputActions = new ArrayList<Closure>()

@Input
Map<String, String> environmentVariables = new HashMap<String, String>()

void environmentVariable(String key, Object value) {
environmentVariables.put(key, String.valueOf(value))
}

SpawnProcessTask() {
description = "Spawn a new server process in the background."
}

void withOutput(Closure outputClosure) {
outputActions.add(outputClosure)
}

@TaskAction
void spawn() {
if (!(command && ready)) {
throw new GradleException("Ensure that mandatory fields command and ready are set.")
}

def pidFile = getPidFile()
if (pidFile.exists()) throw new GradleException("Server already running!")

def process = buildProcess(directory, command)
waitToProcessReadyOrClosed(process)
}

private void waitToProcessReadyOrClosed(Process process) {
boolean isReady = waitUntilIsReadyOrEnd(process)
if (isReady) {
stampLockFile(pidFile, process)
} else {
checkForAbnormalExit(process)
}
}

private void checkForAbnormalExit(Process process) {
try {
process.waitFor()
def exitValue = process.exitValue()
if (exitValue) {
throw new GradleException("The process terminated unexpectedly - status code ${exitValue}")
}
} catch (IllegalThreadStateException ignored) {
}
}

private boolean waitUntilIsReadyOrEnd(Process process) {
def line
def reader = new BufferedReader(new InputStreamReader(process.getInputStream()))
boolean isReady = false
while (!isReady && (line = reader.readLine()) != null) {
logger.quiet line
runOutputActions(line)
if (line.contains(ready)) {
logger.quiet "$command is ready."
isReady = true
}
}
isReady
}

def runOutputActions(String line) {
outputActions.each { Closure<String> outputAction ->
outputAction.call(line)
}
}

private Process buildProcess(String directory, String command) {
def builder = new ProcessBuilder(command.split(' '))
builder.redirectErrorStream(true)
builder.environment().putAll(environmentVariables)
builder.directory(new File(directory))
builder.start()
}

private File stampLockFile(File pidFile, Process process) {
pidFile << extractPidFromProcess(process)
}

private int extractPidFromProcess(Process process) {
def pidField = process.class.getDeclaredField('pid')
pidField.accessible = true

return pidField.getInt(process)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
implementation-class=com.wiredforcode.gradle.spawn.SpawnPlugin
10 changes: 5 additions & 5 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

plugins {
id 'java'
id 'java-library'
id "io.freefair.lombok"
}

Expand All @@ -32,9 +32,9 @@ repositories {
}

dependencies {
compile "org.antlr:antlr4-runtime:4.7.1"
compile group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.17.1'
api "org.antlr:antlr4-runtime:4.7.1"
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
api group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.17.1'

testCompile group: 'junit', name: 'junit', version: '4.13.2'
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
}
24 changes: 12 additions & 12 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

plugins {
id 'java'
id 'java-library'
id "io.freefair.lombok"
id 'jacoco'
}
Expand All @@ -39,19 +39,19 @@ repositories {
//}

dependencies {
compile group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
compile group: 'org.springframework', name: 'spring-context', version: '5.2.19.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version: '5.2.19.RELEASE'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
compile group: 'com.facebook.presto', name: 'presto-matching', version: '0.240'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
compile project(':common')
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
api group: 'org.springframework', name: 'spring-context', version: '5.2.19.RELEASE'
api group: 'org.springframework', name: 'spring-beans', version: '5.2.19.RELEASE'
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
api group: 'com.facebook.presto', name: 'presto-matching', version: '0.240'
api group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
api project(':common')

testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testCompile group: 'org.springframework', name: 'spring-test', version: '5.2.19.RELEASE'
testCompile group: 'org.mockito', name: 'mockito-core', version: '3.3.3'
testCompile group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.3.3'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation group: 'org.springframework', name: 'spring-test', version: '5.2.19.RELEASE'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.3.3'
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.3.3'
}

test {
Expand Down
2 changes: 1 addition & 1 deletion doctest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import java.util.concurrent.Callable
import org.opensearch.gradle.testclusters.RunTask

plugins {
id "com.wiredforcode.spawn" version "0.8.2"
id 'base'
id 'com.wiredforcode.spawn'
}

apply plugin: 'opensearch.testclusters'
Expand Down
Binary file not shown.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
vamsi-amazon marked this conversation as resolved.
Show resolved Hide resolved

distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading