Skip to content

Commit

Permalink
Addressing comments of Navneet
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Jan 2, 2024
1 parent 8721079 commit e371d58
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 44 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/backwards_compatibility_tests_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,10 @@ jobs:
with:
java-version: ${{ matrix.java }}

- if: startsWith(matrix.os,'windows')
name: Run NeuralSearch Restart-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on Windows
- name: Run NeuralSearch Restart-Upgrade BWC Tests from BWCVersion-$BWC_VERSION_RESTART_UPGRADE to OpenSearch Version-${{ matrix.opensearch_version }} on ${{matrix.os}}
run: |
echo "Running restart-upgrade backwards compatibility tests ..."
./gradlew :qa:restart-upgrade:testAgainstNewCluster -D'tests.bwc.version=${{ matrix.bwc_version }}'
- if: startsWith(matrix.os,'ubuntu')
name: Run NeuralSearch Restart-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on Ubuntu
run: |
echo "Running restart-upgrade backwards compatibility tests ..."
./gradlew :qa:restart-upgrade:testAgainstNewCluster -Dtests.bwc.version=$BWC_VERSION_RESTART_UPGRADE
./gradlew :qa:restart-upgrade:testAgainstNewCluster -D'tests.bwc.version=$BWC_VERSION_RESTART_UPGRADE'
Rolling-Upgrade-BWCTests-NeuralSearch:
strategy:
Expand All @@ -67,14 +59,7 @@ jobs:
with:
java-version: ${{ matrix.java }}

- if: startsWith(matrix.os,'windows')
name: Run NeuralSearch Rolling-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on Windows
run: |
echo "Running rolling-upgrade backwards compatibility tests ..."
./gradlew :qa:rolling-upgrade:testRollingUpgrade -D'tests.bwc.version=${{ matrix.bwc_version }}'
- if: startsWith(matrix.os,'ubuntu')
name: Run NeuralSearch Rolling-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on Ubuntu
- name: Run NeuralSearch Rolling-Upgrade BWC Tests from BWCVersion-$BWC_VERSION_ROLLING_UPGRADE to OpenSearch Version-${{ matrix.opensearch_version }} on ${{matrix.os}}
run: |
echo "Running rolling-upgrade backwards compatibility tests ..."
./gradlew :qa:rolling-upgrade:testRollingUpgrade -Dtests.bwc.version=$BWC_VERSION_ROLLING_UPGRADE
./gradlew :qa:rolling-upgrade:testRollingUpgrade -D'tests.bwc.version=$BWC_VERSION_ROLLING_UPGRADE'
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Documentation
### Maintenance
### Refactoring
- Added spotless check in the build ([#515](https://github.com/opensearch-project/neural-search/pull/515))
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,14 @@ allprojects {
project.dependencyLicenses.enabled = false
project.thirdPartyAudit.enabled = false
project.loggerUsageCheck.enabled = false
project.forbiddenApis.ignoreFailures = true
project.forbiddenApis.ignoreFailures = false
project.forbiddenPatterns {
setEnabled(false)
}
project.testingConventions.enabled = false
project.validateNebulaPom.enabled = false
project.licenseFile = rootProject.file('LICENSE.txt')
project.noticeFile = rootProject.file('NOTICE.txt')
project.forbiddenApis.ignoreFailures = true
}
}

Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# SPDX-License-Identifier: Apache-2.0
#

# The BWC version here should always be the latest opensearch version set in
# https://github.com/opensearch-project/OpenSearch/blob/main/libs/core/src/main/java/org/opensearch/Version.java .
# Wired compatibility of OpenSearch works like 3.x version is compatible with 2.(latest-major) version.
# Therefore, to run rolling-upgrade BWC Test on local machine the BWC version here should be set 2.(latest-major).
systemProp.bwc.version=2.12.0-SNAPSHOT

# For fixing Spotless check with Java 17
Expand Down
2 changes: 1 addition & 1 deletion gradle/formatting.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ allprojects {
}
format("license", {
licenseHeaderFile("${rootProject.file("formatter/license-header.txt")}", "package ");
target("src/*/java/**/*.java")
target("src/*/java/**/*.java","qa/*/java/**/*.java")
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.opensearch.test.rest.OpenSearchRestTestCase;

public abstract class AbstractRestartUpgradeRestTestCase extends BaseNeuralSearchIT {
// protected static String testIndex;

@Before
protected String getIndexNameForTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private String registerModelGroupAndGetModelId(String requestBody) throws Except
String modelGroupId = registerModelGroup(
String.format(LOCALE, modelGroupRegisterRequestBody, "public_model_" + RandomizedTest.randomAsciiAlphanumOfLength(8))
);
return uploadModelId(String.format(LOCALE, requestBody, modelGroupId));
return uploadModel(String.format(LOCALE, requestBody, modelGroupId));
}

protected void createPipelineProcessor(String modelId, String pipelineName, ProcessorType processorType) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"refresh_interval": "30s",
"default_pipeline": "%s"
},
"number_of_shards": 6,
"number_of_replicas": 0
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.opensearch.neuralsearch.TestUtils.NEURAL_SEARCH_BWC_PREFIX;

public abstract class AbstractRollingUpgradeTestCase extends BaseNeuralSearchIT {
// protected String testIndex;

@Before
protected String getIndexNameForTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private String registerModelGroupAndGetModelId(String requestBody) throws Except
String modelGroupId = registerModelGroup(
String.format(LOCALE, modelGroupRegisterRequestBody, "public_model_" + RandomizedTest.randomAsciiAlphanumOfLength(8))
);
return uploadModelId(String.format(LOCALE, requestBody, modelGroupId));
return uploadModel(String.format(LOCALE, requestBody, modelGroupId));
}

protected void createPipelineProcessor(String modelId, String pipelineName, ProcessorType processorType) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"refresh_interval": "30s",
"default_pipeline": "%s"
},
"number_of_shards": 6,
"number_of_replicas": 0
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testTextEmbeddingProcessor() throws Exception {

private String uploadTextEmbeddingModel() throws Exception {
String requestBody = Files.readString(Path.of(classLoader.getResource("processor/UploadModelRequestBody.json").toURI()));
return uploadModel(requestBody);
return registerModelGroupAndUploadModel(requestBody);
}

private void createTextEmbeddingIndex() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testEmbeddingProcessor_whenIngestingDocumentWithSourceWithoutMatchin

private String uploadModel() throws Exception {
String requestBody = Files.readString(Path.of(classLoader.getResource("processor/UploadModelRequestBody.json").toURI()));
return uploadModel(requestBody);
return registerModelGroupAndUploadModel(requestBody);
}

private void createTextImageEmbeddingIndex() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "<MODEL_GROUP_NAME>",
"name": "%s",
"description": "This is a public model group"
}
2 changes: 1 addition & 1 deletion src/test/resources/processor/UploadModelRequestBody.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"model_format": "TORCH_SCRIPT",
"model_task_type": "text_embedding",
"model_content_hash_value": "e13b74006290a9d0f58c1376f9629d4ebc05a0f9385f40db837452b167ae9021",
"model_group_id": "<MODEL_GROUP_ID>",
"model_group_id": "%s",
"model_config": {
"model_type": "bert",
"embedding_dimension": 768,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ protected void updateClusterSettings(String settingKey, Object value) {
assertEquals(RestStatus.OK, RestStatus.fromCode(response.getStatusLine().getStatusCode()));
}

protected String uploadModel(String requestBody) throws Exception {
String modelGroupId = registerModelGroup();
protected String registerModelGroupAndUploadModel(String requestBody) throws Exception {
String modelGroupId = getModelGroupId();
// model group id is dynamically generated, we need to update model update request body after group is registered
requestBody = requestBody.replace("<MODEL_GROUP_ID>", modelGroupId);
return uploadModelId(requestBody);
return uploadModel(String.format(LOCALE, requestBody, modelGroupId));
}

protected String uploadModelId(String requestBody) throws Exception {
protected String uploadModel(String requestBody) throws Exception {
Response uploadResponse = makeRequest(
client(),
"POST",
Expand Down Expand Up @@ -204,7 +203,7 @@ protected void loadModel(String modelId) throws Exception {
@SneakyThrows
protected String prepareModel() {
String requestBody = Files.readString(Path.of(classLoader.getResource("processor/UploadModelRequestBody.json").toURI()));
String modelId = uploadModel(requestBody);
String modelId = registerModelGroupAndUploadModel(requestBody);
loadModel(modelId);
return modelId;
}
Expand Down Expand Up @@ -791,11 +790,13 @@ protected String getDeployedModelId() {
}

@SneakyThrows
private String registerModelGroup() {
private String getModelGroupId() {
String modelGroupRegisterRequestBody = Files.readString(
Path.of(classLoader.getResource("processor/CreateModelGroupRequestBody.json").toURI())
).replace("<MODEL_GROUP_NAME>", "public_model_" + RandomizedTest.randomAsciiAlphanumOfLength(8));
return registerModelGroup(modelGroupRegisterRequestBody);
);
return registerModelGroup(
String.format(LOCALE, modelGroupRegisterRequestBody, "public_model_" + RandomizedTest.randomAsciiAlphanumOfLength(8))
);
}

protected String registerModelGroup(String modelGroupRegisterRequestBody) throws IOException, ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected String prepareModel() {
String requestBody = Files.readString(
Path.of(classLoader.getResource("processor/UploadSparseEncodingModelRequestBody.json").toURI())
);
String modelId = uploadModel(requestBody);
String modelId = registerModelGroupAndUploadModel(requestBody);
loadModel(modelId);
return modelId;
}
Expand Down

0 comments on commit e371d58

Please sign in to comment.