Skip to content

Commit fa00555

Browse files
authored
all the os -2 .0 code (opensearch-project#464)
Signed-off-by: Amit Singh <[email protected]>
1 parent 9dd9718 commit fa00555

29 files changed

+231
-354
lines changed

.github/workflows/CI.yml

+50-49
Original file line numberDiff line numberDiff line change
@@ -29,63 +29,64 @@ jobs:
2929

3030
- name: Assemble anomaly-detection
3131
run: |
32-
./gradlew assemble -Dopensearch.version=1.3.0-SNAPSHOT
33-
echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.0.0-SNAPSHOT ..."
34-
mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.0.0-SNAPSHOT
35-
echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.0.0-SNAPSHOT ..."
32+
./gradlew assemble -Dopensearch.version=2.0.0-SNAPSHOT
33+
echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT ..."
34+
mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT
35+
echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT ..."
3636
ls ./build/distributions/
37-
cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.0.0-SNAPSHOT
38-
echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.0.0-SNAPSHOT ..."
39-
ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.0.0-SNAPSHOT
37+
cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT
38+
echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT ..."
39+
ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/2.0.0.0-SNAPSHOT
4040
- name: Build and Run Tests
4141
run: |
42-
./gradlew build -Dopensearch.version=1.3.0-SNAPSHOT
42+
./gradlew build -Dopensearch.version=2.0.0-SNAPSHOT
4343
- name: Publish to Maven Local
4444
run: |
45-
./gradlew publishToMavenLocal -Dopensearch.version=1.3.0-SNAPSHOT
45+
./gradlew publishToMavenLocal -Dopensearch.version=2.0.0-SNAPSHOT
4646
- name: Multi Nodes Integration Testing
4747
run: |
4848
./gradlew integTest -PnumNodes=3
49-
- name: Pull and Run Docker
50-
run: |
51-
plugin=`ls build/distributions/*.zip`
52-
version=1.3.0
53-
plugin_version=1.3.0.0-SNAPSHOT
54-
echo Using OpenSearch $version with AD $plugin_version
55-
cd ..
56-
if docker pull opensearchstaging/opensearch:$version
57-
then
58-
echo "FROM opensearchstaging/opensearch:$version" >> Dockerfile
59-
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-anomaly-detection ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-anomaly-detection; fi" >> Dockerfile
60-
echo "ADD anomaly-detection/build/distributions/opensearch-anomaly-detection-$plugin_version.zip /tmp/" >> Dockerfile
61-
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-anomaly-detection-$plugin_version.zip" >> Dockerfile
62-
docker build -t opensearch-ad:test .
63-
echo "imagePresent=true" >> $GITHUB_ENV
64-
else
65-
echo "imagePresent=false" >> $GITHUB_ENV
66-
fi
67-
- name: Run Docker Image
68-
if: env.imagePresent == 'true'
69-
run: |
70-
cd ..
71-
docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-ad:test
72-
sleep 90
73-
- name: Run AD Test
74-
if: env.imagePresent == 'true'
75-
run: |
76-
security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:admin --insecure |grep opensearch-security|wc -l`
77-
if [ $security -gt 0 ]
78-
then
79-
echo "Security plugin is available"
80-
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" -Dhttps=true -Duser=admin -Dpassword=admin
81-
else
82-
echo "Security plugin is NOT available"
83-
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster"
84-
fi
85-
- name: Run AD Backwards Compatibility Tests
86-
run: |
87-
echo "Running backwards compatibility tests ..."
88-
./gradlew bwcTestSuite -Dtests.security.manager=false
49+
# ToDo: Check infra team for 2.0 docker availability and re-enable
50+
# - name: Pull and Run Docker
51+
# run: |
52+
# plugin=`ls build/distributions/*.zip`
53+
# version=2.0.0
54+
# plugin_version=2.0.0.0-SNAPSHOT
55+
# echo Using OpenSearch $version with AD $plugin_version
56+
# cd ..
57+
# if docker pull opensearchstaging/opensearch:$version
58+
# then
59+
# echo "FROM opensearchstaging/opensearch:$version" >> Dockerfile
60+
# echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-anomaly-detection ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-anomaly-detection; fi" >> Dockerfile
61+
# echo "ADD anomaly-detection/build/distributions/opensearch-anomaly-detection-$plugin_version.zip /tmp/" >> Dockerfile
62+
# echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-anomaly-detection-$plugin_version.zip" >> Dockerfile
63+
# docker build -t opensearch-ad:test .
64+
# echo "imagePresent=true" >> $GITHUB_ENV
65+
# else
66+
# echo "imagePresent=false" >> $GITHUB_ENV
67+
# fi
68+
# - name: Run Docker Image
69+
# if: env.imagePresent == 'true'
70+
# run: |
71+
# cd ..
72+
# docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-ad:test
73+
# sleep 90
74+
# - name: Run AD Test
75+
# if: env.imagePresent == 'true'
76+
# run: |
77+
# security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:admin --insecure |grep opensearch-security|wc -l`
78+
# if [ $security -gt 0 ]
79+
# then
80+
# echo "Security plugin is available"
81+
# ./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" -Dhttps=true -Duser=admin -Dpassword=admin
82+
# else
83+
# echo "Security plugin is NOT available"
84+
# ./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster"
85+
# fi
86+
# - name: Run AD Backwards Compatibility Tests
87+
# run: |
88+
# echo "Running backwards compatibility tests ..."
89+
# ./gradlew bwcTestSuite -Dtests.security.manager=false
8990
- name: Upload Coverage Report
9091
uses: codecov/codecov-action@v1
9192
with:

build.gradle

+30-25
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
1616
buildscript {
1717
ext {
1818
opensearch_group = "org.opensearch"
19-
opensearch_version = System.getProperty("opensearch.version", "1.3.0-SNAPSHOT")
19+
opensearch_version = System.getProperty("opensearch.version", "2.0.0-SNAPSHOT")
2020
// 1.2.0 -> 1.2.0.0, and 1.2.0-SNAPSHOT -> 1.2.0.0-SNAPSHOT
2121
opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
2222
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
@@ -116,7 +116,7 @@ configurations.all {
116116
}
117117

118118
configurations {
119-
testCompile {
119+
testImplementation {
120120
exclude group: 'org.hamcrest', module: 'hamcrest-core'
121121
}
122122
}
@@ -503,6 +503,7 @@ List<String> jacocoExclusions = [
503503
'org.opensearch.ad.transport.GetAnomalyDetectorTransportAction*',
504504
'org.opensearch.ad.transport.SearchAnomalyResultTransportAction*',
505505
'org.opensearch.ad.transport.SearchAnomalyDetectorInfoTransportAction*',
506+
'org.opensearch.ad.transport.AnomalyDetectorJobRequest',
506507

507508
// TODO: unified flow caused coverage drop
508509
'org.opensearch.ad.transport.DeleteAnomalyResultsTransportAction',
@@ -549,40 +550,44 @@ check.dependsOn jacocoTestCoverageVerification
549550
jacocoTestCoverageVerification.dependsOn jacocoTestReport
550551

551552
dependencies {
552-
compile "org.opensearch:opensearch:${opensearch_version}"
553+
implementation "org.opensearch:opensearch:${opensearch_version}"
553554
compileOnly "org.opensearch.plugin:opensearch-scripting-painless-spi:${opensearch_version}"
554-
compileOnly "org.opensearch:opensearch-job-scheduler-spi:${job_scheduler_version}"
555-
compile "org.opensearch:common-utils:${common_utils_version}"
556-
compile "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
557-
compile group: 'com.google.guava', name: 'guava', version:'31.0.1-jre'
558-
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
559-
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
560-
compile group: 'com.yahoo.datasketches', name: 'sketches-core', version: '0.13.4'
561-
compile group: 'com.yahoo.datasketches', name: 'memory', version: '0.12.2'
562-
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
563-
compile group: 'org.apache.commons', name: 'commons-pool2', version: '2.10.0'
555+
compileOnly "org.opensearch:opensearch-job-scheduler-spi:2.0.0.0-alpha1-SNAPSHOT"
556+
implementation "org.opensearch:common-utils:${common_utils_version}"
557+
implementation "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
558+
implementation group: 'com.google.guava', name: 'guava', version:'31.0.1-jre'
559+
implementation group: 'com.google.guava', name: 'failureaccess', version:'1.0.1'
560+
implementation group: 'org.javassist', name: 'javassist', version:'3.28.0-GA'
561+
implementation group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
562+
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
563+
implementation group: 'com.yahoo.datasketches', name: 'sketches-core', version: '0.13.4'
564+
implementation group: 'com.yahoo.datasketches', name: 'memory', version: '0.12.2'
565+
implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
566+
implementation group: 'org.apache.commons', name: 'commons-pool2', version: '2.10.0'
564567

565568
// force Jackson version to avoid version conflict issue
566569
implementation 'software.amazon.randomcutforest:randomcutforest-serialization:2.0.1'
567570
implementation "com.fasterxml.jackson.core:jackson-core:2.12.6"
568571
implementation "com.fasterxml.jackson.core:jackson-databind:2.12.6"
569572
implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.6"
570-
compile files('lib/randomcutforest-parkservices-2.0.1.jar')
571-
compile files('lib/randomcutforest-core-2.0.1.jar')
573+
implementation files('lib/randomcutforest-parkservices-2.0.1.jar')
574+
implementation files('lib/randomcutforest-core-2.0.1.jar')
572575

573576
// used for serializing/deserializing rcf models.
574-
compile group: 'io.protostuff', name: 'protostuff-core', version: '1.8.0'
575-
compile group: 'io.protostuff', name: 'protostuff-runtime', version: '1.8.0'
576-
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
577-
578-
compile "org.jacoco:org.jacoco.agent:0.8.5"
579-
compile ("org.jacoco:org.jacoco.ant:0.8.5") {
577+
implementation group: 'io.protostuff', name: 'protostuff-core', version: '1.8.0'
578+
implementation group: 'io.protostuff', name: 'protostuff-runtime', version: '1.8.0'
579+
implementation group: 'io.protostuff', name: 'protostuff-api', version: '1.8.0'
580+
implementation group: 'io.protostuff', name: 'protostuff-collectionschema', version: '1.8.0'
581+
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
582+
583+
implementation "org.jacoco:org.jacoco.agent:0.8.5"
584+
implementation ("org.jacoco:org.jacoco.ant:0.8.5") {
580585
exclude group: 'org.ow2.asm', module: 'asm-commons'
581586
exclude group: 'org.ow2.asm', module: 'asm'
582587
exclude group: 'org.ow2.asm', module: 'asm-tree'
583588
}
584589

585-
testCompile group: 'pl.pragmatists', name: 'JUnitParams', version: '1.1.1'
590+
testImplementation group: 'pl.pragmatists', name: 'JUnitParams', version: '1.1.1'
586591
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.25.0'
587592
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.2'
588593
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.2'
@@ -591,11 +596,11 @@ dependencies {
591596
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.2'
592597
testImplementation group: 'org.powermock', name: 'powermock-reflect', version: '2.0.7'
593598
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.0.1'
594-
testCompile group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.15'
595-
testCompile group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.9.15'
599+
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.15'
600+
testImplementation group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.9.15'
596601
testCompileOnly 'org.apiguardian:apiguardian-api:1.1.0'
597602
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
598-
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.2'
603+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.2'
599604
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
600605
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.2'
601606
testCompileOnly 'junit:junit:4.13.2'

gradle/wrapper/gradle-wrapper.jar

2.96 KB
Binary file not shown.
+1-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
/*
2-
* SPDX-License-Identifier: Apache-2.0
3-
*
4-
* The OpenSearch Contributors require contributions made to
5-
* this file be licensed under the Apache-2.0 license or a
6-
* compatible open source license.
7-
*
8-
* Modifications Copyright OpenSearch Contributors. See
9-
* GitHub history for details.
10-
*/
11-
121
distributionBase=GRADLE_USER_HOME
132
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
144
zipStoreBase=GRADLE_USER_HOME
155
zipStorePath=wrapper/dists
16-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip

gradlew

+33-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env sh
22

3+
#
4+
# Copyright 2015 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
319
##############################################################################
420
##
521
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
2844
APP_BASE_NAME=`basename "$0"`
2945

3046
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
47+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
3248

3349
# Use the maximum available, or set MAX_FD != -1 to use that value.
3450
MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
6682

6783
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
6884

85+
6986
# Determine the Java command to use to start the JVM.
7087
if [ -n "$JAVA_HOME" ] ; then
7188
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
109126
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110127
fi
111128

112-
# For Cygwin, switch paths to Windows format before running java
113-
if $cygwin ; then
129+
# For Cygwin or MSYS, switch paths to Windows format before running java
130+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
114131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133+
116134
JAVACMD=`cygpath --unix "$JAVACMD"`
117135

118136
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
138156
else
139157
eval `echo args$i`="\"$arg\""
140158
fi
141-
i=$((i+1))
159+
i=`expr $i + 1`
142160
done
143161
case $i in
144-
(0) set -- ;;
145-
(1) set -- "$args0" ;;
146-
(2) set -- "$args0" "$args1" ;;
147-
(3) set -- "$args0" "$args1" "$args2" ;;
148-
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149-
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150-
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151-
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152-
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153-
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
162+
0) set -- ;;
163+
1) set -- "$args0" ;;
164+
2) set -- "$args0" "$args1" ;;
165+
3) set -- "$args0" "$args1" "$args2" ;;
166+
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167+
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168+
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169+
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170+
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171+
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154172
esac
155173
fi
156174

@@ -159,14 +177,9 @@ save () {
159177
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160178
echo " "
161179
}
162-
APP_ARGS=$(save "$@")
180+
APP_ARGS=`save "$@"`
163181

164182
# Collect all arguments for the java command, following the shell quoting and substitution rules
165183
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166184

167-
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168-
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169-
cd "$(dirname "$0")"
170-
fi
171-
172185
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)