Skip to content

Commit ff38622

Browse files
authored
Initial commit for adding BWC tests in neural search plugin (#515)
* Reformatting test package Signed-off-by: Varun Jain <varunudr@amazon.com> * Initial commit of BWC Test Signed-off-by: Varun Jain <varunudr@amazon.com> * Text Search Signed-off-by: Varun Jain <varunudr@amazon.com> * Fixing bug Signed-off-by: Varun Jain <varunudr@amazon.com> * Text Search bug fix Signed-off-by: Varun Jain <varunudr@amazon.com> * Adding windows platform in bwc Signed-off-by: Varun Jain <varunudr@amazon.com> * Adding windows platform in bwc Signed-off-by: Varun Jain <varunudr@amazon.com> * Rolling Upgrade tests Signed-off-by: Varun Jain <varunudr@amazon.com> * Bux Fix in rolling upgrade Signed-off-by: Varun Jain <varunudr@amazon.com> * Bug Fix Rolling Upgrade Signed-off-by: Varun Jain <varunudr@amazon.com> * Fixing Flaky tests Signed-off-by: Varun Jain <varunudr@amazon.com> * Updating BWC version to latest Signed-off-by: Varun Jain <varunudr@amazon.com> * Fixing bwc test Signed-off-by: Varun Jain <varunudr@amazon.com> * Semantic Search Signed-off-by: Varun Jain <varunudr@amazon.com> * Bug Fix Signed-off-by: Varun Jain <varunudr@amazon.com> * Debugging Signed-off-by: Varun Jain <varunudr@amazon.com> * Bug Fix Signed-off-by: Varun Jain <varunudr@amazon.com> * Increase memory in nodes Signed-off-by: Varun Jain <varunudr@amazon.com> * Removing extra logging Signed-off-by: Varun Jain <varunudr@amazon.com> * Cleaning up Signed-off-by: Varun Jain <varunudr@amazon.com> * Updating Pipeline Configuration Signed-off-by: Varun Jain <varunudr@amazon.com> * Remove KNN delete models Signed-off-by: Varun Jain <varunudr@amazon.com> * Remove unecessary KNN code Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of naveen Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of naveen Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of Naveen Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing martin comments Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of martin Signed-off-by: Varun Jain <varunudr@amazon.com> * Apply formatting.xml in all lines Signed-off-by: Varun Jain <varunudr@amazon.com> * Removing extra spacess from formatting.gradle Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing martin comment Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing Jack comments Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing Jack comments Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing Jack's comments Signed-off-by: Varun Jain <varunudr@amazon.com> * Fixing Test cases Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of Navneet Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of Navneet Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of Navneet Signed-off-by: Varun Jain <varunudr@amazon.com> * Addressing comments of Navneet Signed-off-by: Varun Jain <varunudr@amazon.com> * Removing extra parameter from createPipelineProcessor Signed-off-by: Varun Jain <varunudr@amazon.com> * Fixing bug Signed-off-by: Varun Jain <varunudr@amazon.com> * Increasing number of shards Signed-off-by: Varun Jain <varunudr@amazon.com> * Bug fix of load model id Signed-off-by: Varun Jain <varunudr@amazon.com> * Changing names of tests to TextEmbeddingPRocessor Signed-off-by: Varun Jain <varunudr@amazon.com> * Updating indexes and replicas Signed-off-by: Varun Jain <varunudr@amazon.com> --------- Signed-off-by: Varun Jain <varunudr@amazon.com>
1 parent 585fbbe commit ff38622

File tree

135 files changed

+1215
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+1215
-211
lines changed

.github/draft-release-notes-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ categories:
3737
- 'Maintenance'
3838
- title: 'Refactoring'
3939
labels:
40-
- 'Refactoring'
40+
- 'Refactoring'

.github/workflows/add-untriaged.yml

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
name: Apply 'untriaged' label during issue lifecycle
2-
3-
on:
4-
issues:
5-
types: [opened, reopened, transferred]
6-
7-
jobs:
8-
apply-label:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/github-script@v6
12-
with:
13-
script: |
14-
github.rest.issues.addLabels({
15-
issue_number: context.issue.number,
16-
owner: context.repo.owner,
17-
repo: context.repo.repo,
18-
labels: ['untriaged']
19-
})
1+
name: Apply 'untriaged' label during issue lifecycle
2+
3+
on:
4+
issues:
5+
types: [opened, reopened, transferred]
6+
7+
jobs:
8+
apply-label:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/github-script@v6
12+
with:
13+
script: |
14+
github.rest.issues.addLabels({
15+
issue_number: context.issue.number,
16+
owner: context.repo.owner,
17+
repo: context.repo.repo,
18+
labels: ['untriaged']
19+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Backwards Compatibility Tests NeuralSearch
2+
on:
3+
push:
4+
branches:
5+
- "*"
6+
- "feature/**"
7+
pull_request:
8+
branches:
9+
- "*"
10+
- "feature/**"
11+
12+
jobs:
13+
Restart-Upgrade-BWCTests-NeuralSearch:
14+
strategy:
15+
matrix:
16+
java: [ 11, 17, 21 ]
17+
os: [ubuntu-latest,windows-latest]
18+
bwc_version : ["2.9.0","2.10.0","2.11.0","2.12.0-SNAPSHOT"]
19+
opensearch_version : [ "3.0.0-SNAPSHOT" ]
20+
21+
name: NeuralSearch Restart-Upgrade BWC Tests
22+
runs-on: ${{ matrix.os }}
23+
env:
24+
BWC_VERSION_RESTART_UPGRADE: ${{ matrix.bwc_version }}
25+
26+
steps:
27+
- name: Checkout NeuralSearch
28+
uses: actions/checkout@v1
29+
30+
- name: Setup Java ${{ matrix.java }}
31+
uses: actions/setup-java@v1
32+
with:
33+
java-version: ${{ matrix.java }}
34+
35+
- name: Run NeuralSearch Restart-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on ${{matrix.os}}
36+
run: |
37+
echo "Running restart-upgrade backwards compatibility tests ..."
38+
./gradlew :qa:restart-upgrade:testAgainstNewCluster -D'tests.bwc.version=${{ matrix.bwc_version }}'
39+
40+
Rolling-Upgrade-BWCTests-NeuralSearch:
41+
strategy:
42+
matrix:
43+
java: [ 11, 17, 21 ]
44+
os: [ubuntu-latest,windows-latest]
45+
bwc_version: [ "2.12.0-SNAPSHOT" ]
46+
opensearch_version: [ "3.0.0-SNAPSHOT" ]
47+
48+
name: NeuralSearch Rolling-Upgrade BWC Tests
49+
runs-on: ${{ matrix.os }}
50+
env:
51+
BWC_VERSION_ROLLING_UPGRADE: ${{ matrix.bwc_version }}
52+
53+
steps:
54+
- name: Checkout NeuralSearch
55+
uses: actions/checkout@v1
56+
57+
- name: Setup Java ${{ matrix.java }}
58+
uses: actions/setup-java@v1
59+
with:
60+
java-version: ${{ matrix.java }}
61+
62+
- name: Run NeuralSearch Rolling-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on ${{matrix.os}}
63+
run: |
64+
echo "Running rolling-upgrade backwards compatibility tests ..."
65+
./gradlew :qa:rolling-upgrade:testRollingUpgrade -D'tests.bwc.version=${{ matrix.bwc_version }}'
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Delete merged branch of the backport PRs
2-
on:
2+
on:
33
pull_request:
44
types:
55
- closed
6-
6+
77
jobs:
88
delete-branch:
99
runs-on: ubuntu-latest
@@ -12,4 +12,4 @@ jobs:
1212
- name: Delete merged branch
1313
uses: SvanBoxel/delete-merged-branch@main
1414
env:
15-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/links.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
env:
2121
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2222
- name: Fail if there were link errors
23-
run: exit ${{ steps.lychee.outputs.exit_code }}
23+
run: exit ${{ steps.lychee.outputs.exit_code }}

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2222
### Bug Fixes
2323
- Fixing multiple issues reported in #497 ([#524](https://github.com/opensearch-project/neural-search/pull/524))
2424
### Infrastructure
25+
- BWC tests for Neural Search ([#515](https://github.com/opensearch-project/neural-search/pull/515))
2526
### Documentation
2627
### Maintenance
2728
### Refactoring
29+
- Added spotless check in the build ([#515](https://github.com/opensearch-project/neural-search/pull/515))

DEVELOPER_GUIDE.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ git clone https://github.com/[your username]/neural-search.git
3333

3434
#### JDK 11
3535

36-
OpenSearch builds using Java 11 at a minimum. This means you must have a JDK 11 installed with the environment variable
36+
OpenSearch builds using Java 11 at a minimum. This means you must have a JDK 11 installed with the environment variable
3737
`JAVA_HOME` referencing the path to Java home for your JDK 11 installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-11`.
3838

3939
One easy way to get Java 11 on *nix is to use [sdkman](https://sdkman.io/).
@@ -83,10 +83,10 @@ Please follow these formatting guidelines:
8383

8484
## Build
8585

86-
OpenSearch neural-search uses a [Gradle](https://docs.gradle.org/6.6.1/userguide/userguide.html) wrapper for its build.
86+
OpenSearch neural-search uses a [Gradle](https://docs.gradle.org/6.6.1/userguide/userguide.html) wrapper for its build.
8787
Run `gradlew` on Unix systems.
8888

89-
Build OpenSearch neural-search using `gradlew build`
89+
Build OpenSearch neural-search using `gradlew build`
9090

9191
```
9292
./gradlew build
@@ -221,8 +221,8 @@ See [CONTRIBUTING](CONTRIBUTING.md).
221221

222222
## Backports
223223

224-
The Github workflow in [`backport.yml`](.github/workflows/backport.yml) creates backport PRs automatically when the
225-
original PR with an appropriate label `backport <backport-branch-name>` is merged to main with the backport workflow
226-
run successfully on the PR. For example, if a PR on main needs to be backported to `2.x` branch, add a label
227-
`backport 2.x` to the PR and make sure the backport workflow runs on the PR along with other checks. Once this PR is
224+
The Github workflow in [`backport.yml`](.github/workflows/backport.yml) creates backport PRs automatically when the
225+
original PR with an appropriate label `backport <backport-branch-name>` is merged to main with the backport workflow
226+
run successfully on the PR. For example, if a PR on main needs to be backported to `2.x` branch, add a label
227+
`backport 2.x` to the PR and make sure the backport workflow runs on the PR along with other checks. Once this PR is
228228
merged to main, the workflow will create a backport PR to the `2.x` branch.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success)
88

99
## OpenSearch Neural Search
10-
**OpenSearch Neural Search** is an OpenSearch plugin that adds dense neural retrieval into the OpenSearch ecosystem.
10+
**OpenSearch Neural Search** is an OpenSearch plugin that adds dense neural retrieval into the OpenSearch ecosystem.
1111
The plugin provides the capability for indexing documents and doing neural search on the indexed documents.
1212

1313
## Project Resources

build.gradle

+30-10
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import org.opensearch.gradle.test.RestIntegTestTask
1111
import java.util.concurrent.Callable
1212

1313
apply plugin: 'java'
14+
apply plugin: 'java-test-fixtures'
1415
apply plugin: 'idea'
1516
apply plugin: 'opensearch.opensearchplugin'
1617
apply plugin: 'opensearch.pluginzip'
1718
apply plugin: 'jacoco'
1819
apply plugin: "com.diffplug.spotless"
1920
apply plugin: 'io.freefair.lombok'
21+
apply from: 'gradle/formatting.gradle'
2022

2123
def pluginName = 'opensearch-neural-search'
2224
def pluginDescription = 'A plugin that adds dense neural retrieval into the OpenSearch ecosytem'
@@ -123,6 +125,25 @@ allprojects {
123125
version = "${opensearch_build}"
124126
targetCompatibility = JavaVersion.VERSION_11
125127
sourceCompatibility = JavaVersion.VERSION_11
128+
129+
apply from: rootProject.file('repositories.gradle').absoluteFile
130+
plugins.withId('java') {
131+
sourceCompatibility = targetCompatibility = "11"
132+
}
133+
134+
afterEvaluate {
135+
project.dependencyLicenses.enabled = false
136+
project.thirdPartyAudit.enabled = false
137+
project.loggerUsageCheck.enabled = false
138+
project.forbiddenApis.ignoreFailures = false
139+
project.forbiddenPatterns {
140+
setEnabled(false)
141+
}
142+
project.testingConventions.enabled = false
143+
project.validateNebulaPom.enabled = false
144+
project.licenseFile = rootProject.file('LICENSE.txt')
145+
project.noticeFile = rootProject.file('NOTICE.txt')
146+
}
126147
}
127148

128149
repositories {
@@ -144,6 +165,7 @@ dependencies {
144165
zipArchive group: 'org.opensearch.plugin', name:'opensearch-ml-plugin', version: "${opensearch_build}"
145166
compileOnly fileTree(dir: knnJarDirectory, include: '*.jar')
146167
api group: 'org.opensearch', name:'opensearch-ml-client', version: "${opensearch_build}"
168+
testFixturesImplementation "org.opensearch.test:framework:${opensearch_version}"
147169
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
148170
// ml-common excluded reflection for runtime so we need to add it by ourselves.
149171
// https://github.com/opensearch-project/ml-commons/commit/464bfe34c66d7a729a00dd457f03587ea4e504d9
@@ -154,6 +176,10 @@ dependencies {
154176
runtimeOnly group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
155177
runtimeOnly group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
156178
runtimeOnly group: 'org.json', name: 'json', version: '20231013'
179+
testFixturesImplementation "org.opensearch:common-utils:${version}"
180+
testFixturesImplementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
181+
testFixturesCompileOnly group: 'com.google.guava', name: 'guava', version:'32.0.1-jre'
182+
testFixturesCompileOnly fileTree(dir: knnJarDirectory, include: '*.jar')
157183
}
158184

159185
// In order to add the jar to the classpath, we need to unzip the
@@ -173,6 +199,9 @@ compileJava {
173199
compileTestJava {
174200
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor'])
175201
}
202+
compileTestFixturesJava {
203+
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor'])
204+
}
176205

177206
def opensearch_tmp_dir = rootProject.file('build/private/opensearch_tmp').absoluteFile
178207
opensearch_tmp_dir.mkdirs()
@@ -284,16 +313,6 @@ run {
284313
useCluster testClusters.integTest
285314
}
286315

287-
spotless {
288-
java {
289-
removeUnusedImports()
290-
importOrder 'java', 'javax', 'org', 'com'
291-
eclipse().configFile rootProject.file('formatterConfig.xml')
292-
trimTrailingWhitespace()
293-
endWithNewline()
294-
}
295-
}
296-
297316
jacocoTestReport {
298317
dependsOn integTest, test
299318
reports {
@@ -302,6 +321,7 @@ jacocoTestReport {
302321
}
303322
}
304323

324+
check.dependsOn spotlessCheck
305325
check.dependsOn jacocoTestCoverageVerification
306326
jacocoTestCoverageVerification.dependsOn jacocoTestReport
307327

File renamed without changes.

formatter/license-header.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/

gradle.properties

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

6+
# The BWC version here should always be the latest opensearch version set in
7+
# https://github.com/opensearch-project/OpenSearch/blob/main/libs/core/src/main/java/org/opensearch/Version.java .
8+
# Wired compatibility of OpenSearch works like 3.x version is compatible with 2.(latest-major) version.
9+
# Therefore, to run rolling-upgrade BWC Test on local machine the BWC version here should be set 2.(latest-major).
10+
systemProp.bwc.version=2.12.0-SNAPSHOT
11+
612
# For fixing Spotless check with Java 17
713
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
814
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \

gradle/formatting.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
allprojects {
2+
project.apply plugin: "com.diffplug.spotless"
3+
spotless {
4+
java {
5+
// Normally this isn't necessary, but we have Java sources in
6+
// non-standard places
7+
target '**/*.java'
8+
9+
removeUnusedImports()
10+
eclipse().configFile rootProject.file('formatter/formatterConfig.xml')
11+
trimTrailingWhitespace()
12+
endWithNewline();
13+
14+
custom 'Refuse wildcard imports', {
15+
// Wildcard imports can't be resolved; fail the build
16+
if (it =~ /\s+import .*\*;/) {
17+
throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
18+
}
19+
}
20+
}
21+
format 'misc', {
22+
target '*.md', '**/*.gradle', '**/*.json', '**/*.yaml', '**/*.yml', '**/*.svg'
23+
24+
trimTrailingWhitespace()
25+
endWithNewline()
26+
}
27+
format("license", {
28+
licenseHeaderFile("${rootProject.file("formatter/license-header.txt")}", "package ");
29+
target("src/*/java/**/*.java","qa/*/java/**/*.java")
30+
})
31+
}
32+
}

0 commit comments

Comments
 (0)