Skip to content

Commit

Permalink
Add support for multiple BWC Versions (#389)
Browse files Browse the repository at this point in the history
Signed-off-by: Naveen Tatikonda <[email protected]>
  • Loading branch information
naveentatikonda authored May 13, 2022
1 parent 1438042 commit 7ec926b
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 55 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ jobs:
run: |
./gradlew build
- name: Run k-NN Backwards Compatibility Tests
run: |
echo "Running backwards compatibility tests ..."
./gradlew :qa:bwcTestSuite
- name: Upload Coverage Report
uses: codecov/codecov-action@v1
with:
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/backwards_compatibility_tests_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Backwards Compatibility Tests k-NN
on:
push:
branches:
- "*"
- "feature/**"
pull_request:
branches:
- "*"
- "feature/**"

jobs:
Restart-Upgrade-BWCTests-k-NN:
strategy:
matrix:
java: [ 11, 17 ]
bwc_version : [ "1.0.0", "1.1.0", "1.2.4", "1.3.2" ]
opensearch_version : [ "2.0.0-rc1-SNAPSHOT" ]

name: k-NN Restart-Upgrade BWC Tests
runs-on: ubuntu-latest
env:
BWC_VERSION_RESTART_UPGRADE: ${{ matrix.bwc_version }}

steps:
- name: Checkout k-NN
uses: actions/checkout@v1

- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Install dependencies
run: |
sudo apt-get install libopenblas-dev gfortran -y
- name: Run k-NN Restart-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }}
run: |
echo "Running restart-upgrade backwards compatibility tests ..."
./gradlew :qa:restart-upgrade:testRestartUpgrade -Dtests.bwc.version=$BWC_VERSION_RESTART_UPGRADE
Rolling-Upgrade-BWCTests-k-NN:
strategy:
matrix:
java: [ 11, 17 ]
bwc_version: [ "1.3.2" ]
opensearch_version: [ "2.0.0-rc1-SNAPSHOT" ]

name: k-NN Rolling-Upgrade BWC Tests
runs-on: ubuntu-latest
env:
OPENSEARCH_VERSION_ROLLING_UPGRADE: ${{ matrix.opensearch_version }}

steps:
- name: Checkout k-NN
uses: actions/checkout@v1

- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Install dependencies
run: |
sudo apt-get install libopenblas-dev gfortran -y
- name: Run k-NN Rolling-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }}
run: |
echo "Running rolling-upgrade backwards compatibility tests ..."
./gradlew :qa:rolling-upgrade:testRollingUpgrade -Drolling.bwctests.opensearch.version=$OPENSEARCH_VERSION_ROLLING_UPGRADE
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

version=1.0.0
systemProp.bwc.version=1.3.1
systemProp.bwc.version=1.3.2

org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
Expand Down
3 changes: 2 additions & 1 deletion qa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ dependencies {

def tmp_dir = project.file('build/private/artifact_tmp').absoluteFile
tmp_dir.mkdirs()
String knn_bwc_version = System.getProperty("bwc.version")
String default_bwc_version = System.getProperty("bwc.version")
String knn_bwc_version = System.getProperty("tests.bwc.version", default_bwc_version)

// Task to pull k-NN plugin from archive
task pullBwcPlugin {
Expand Down
109 changes: 78 additions & 31 deletions qa/restart-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask

apply from : "$rootDir/qa/build.gradle"

String knn_bwc_version = System.getProperty("bwc.version")
String default_bwc_version = System.getProperty("bwc.version")
String knn_bwc_version = System.getProperty("tests.bwc.version", default_bwc_version)
String baseName = "knnBwcCluster-restart"

// Creates a test cluster of previous version and loads k-NN plugin of bwcVersion
Expand All @@ -19,40 +20,86 @@ testClusters {
plugin(project.tasks.zipBwcPlugin.archiveFile)
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
setting 'http.content_type.required', 'true'
environment "LD_LIBRARY_PATH", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib"
systemProperty "java.library.path", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib"
environment "LD_LIBRARY_PATH", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib;${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/lib"
systemProperty "java.library.path", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib:${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/lib"
}
}

// Task to run BWC tests against the old cluster
task testAgainstOldCluster(type: StandaloneRestIntegTestTask) {
dependsOn "zipBwcPlugin"
useCluster testClusters."${baseName}"
systemProperty 'tests.rest.bwcsuite_cluster', 'old_cluster'
systemProperty 'tests.is_old_cluster', 'true'
systemProperty 'tests.skip_delete_model_index', 'true'
systemProperty 'tests.plugin_bwc_version', knn_bwc_version
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.security.manager', 'false'
}
task testAgainstOldCluster(type: StandaloneRestIntegTestTask) {
dependsOn "zipBwcPlugin"
useCluster testClusters."${baseName}"
systemProperty 'tests.rest.bwcsuite_cluster', 'old_cluster'
systemProperty 'tests.is_old_cluster', 'true'
systemProperty 'tests.skip_delete_model_index', 'true'
systemProperty 'tests.plugin_bwc_version', knn_bwc_version

// Skip test if version is 1.0 or 1.1 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.0") || knn_bwc_version.startsWith("1.1")) {
filter {
excludeTestsMatching "org.opensearch.knn.bwc.ModelIT"
excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testKNNIndexCustomMethodFieldMapping"
excludeTestsMatching "org.opensearch.knn.bwc.WarmupIT.testKNNWarmupCustomMethodFieldMapping"
}
}

// Skip test if version is 1.2 or 1.3 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.2") || knn_bwc_version.startsWith("1.3")) {
filter {
excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testNullParametersOnUpgrade"
}
}

// Skip test if version is 1.0, 1.1, 1.2 or 1.3 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.")) {
filter {
excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testEmptyParametersOnUpgrade"
}
}
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.security.manager', 'false'
}

// All nodes are upgraded to latest version and run the tests
task testRestartUpgrade(type: StandaloneRestIntegTestTask) {
dependsOn "testAgainstOldCluster"
dependsOn rootProject.tasks.buildJniLib
dependsOn rootProject.tasks.assemble
useCluster testClusters."${baseName}"
doFirst {
testClusters."${baseName}".environment("LD_LIBRARY_PATH", "$rootDir/jni/release")
testClusters."${baseName}".systemProperty("java.library.path", "$rootDir/jni/release")
testClusters."${baseName}".upgradeAllNodesAndPluginsToNextVersion([rootProject.tasks.bundlePlugin.archiveFile])
task testRestartUpgrade(type: StandaloneRestIntegTestTask) {
dependsOn "testAgainstOldCluster"
dependsOn rootProject.tasks.buildJniLib
dependsOn rootProject.tasks.assemble
useCluster testClusters."${baseName}"
doFirst {
testClusters."${baseName}".environment("LD_LIBRARY_PATH", "$rootDir/jni/release")
testClusters."${baseName}".systemProperty("java.library.path", "$rootDir/jni/release")
testClusters."${baseName}".upgradeAllNodesAndPluginsToNextVersion([rootProject.tasks.bundlePlugin.archiveFile])
}
systemProperty 'tests.rest.bwcsuite_cluster', 'upgraded_cluster'
systemProperty 'tests.skip_delete_model_index', 'true'
systemProperty 'tests.is_old_cluster', 'false'
systemProperty 'tests.plugin_bwc_version', knn_bwc_version

// Skip test if version is 1.0 or 1.1 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.0") || knn_bwc_version.startsWith("1.1")) {
filter {
excludeTestsMatching "org.opensearch.knn.bwc.ModelIT"
excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testKNNIndexCustomMethodFieldMapping"
excludeTestsMatching "org.opensearch.knn.bwc.WarmupIT.testKNNWarmupCustomMethodFieldMapping"
}
}

// Skip test if version is 1.2 or 1.3 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.2") || knn_bwc_version.startsWith("1.3")) {
filter {
excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testNullParametersOnUpgrade"
}
}

// Skip test if version is 1.0, 1.1, 1.2 or 1.3 as they are not supported in those versions
if (knn_bwc_version.startsWith("1.")) {
filter {
excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testEmptyParametersOnUpgrade"
}
}
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.security.manager', 'false'
}
systemProperty 'tests.rest.bwcsuite_cluster', 'upgraded_cluster'
systemProperty 'tests.skip_delete_model_index', 'true'
systemProperty 'tests.is_old_cluster', 'false'
systemProperty 'tests.plugin_bwc_version', knn_bwc_version
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.security.manager', 'false'
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.knn.index.SpaceType;

import java.util.Optional;

import static org.opensearch.knn.TestUtils.KNN_ALGO_PARAM_EF_CONSTRUCTION_MIN_VALUE;
import static org.opensearch.knn.TestUtils.KNN_ALGO_PARAM_M_MIN_VALUE;
import static org.opensearch.knn.TestUtils.KNN_VECTOR;
Expand Down Expand Up @@ -97,12 +95,6 @@ public void testKNNIndexCustomMethodFieldMapping() throws Exception {

// test null parameters
public void testNullParametersOnUpgrade() throws Exception {

// Skip test if version is 1.2 or 1.3
Optional<String> bwcVersion = getBWCVersion();
if (bwcVersion.isEmpty() || bwcVersion.get().startsWith("1.2") || bwcVersion.get().startsWith("1.3")) {
return;
}
if (isRunningAgainstOldCluster()) {
String mapping = Strings.toString(
XContentFactory.jsonBuilder()
Expand All @@ -128,12 +120,6 @@ public void testNullParametersOnUpgrade() throws Exception {

// test empty parameters
public void testEmptyParametersOnUpgrade() throws Exception {

// Skip test if version is 1.2 or 1.3
Optional<String> bwcVersion = getBWCVersion();
if (bwcVersion.isEmpty() || bwcVersion.get().startsWith("1.2") || bwcVersion.get().startsWith("1.3")) {
return;
}
if (isRunningAgainstOldCluster()) {
String mapping = Strings.toString(
XContentFactory.jsonBuilder()
Expand Down
7 changes: 4 additions & 3 deletions qa/rolling-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ apply from : "$rootDir/qa/build.gradle"

String knn_bwc_version = System.getProperty("bwc.version")
String baseName = "knnBwcCluster-rolling"
String opensearch_version_upgraded = System.getProperty("rolling.bwctests.opensearch.version", opensearch_version)

// Creates a test cluster of previous version and loads k-NN plugin of bwcVersion
testClusters {
"${baseName}" {
testDistribution = "ARCHIVE"
versions = [knn_bwc_version, opensearch_version]
versions = [knn_bwc_version, opensearch_version_upgraded]
numberOfNodes = 3
plugin(project.tasks.zipBwcPlugin.archiveFile)
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
setting 'http.content_type.required', 'true'
environment "LD_LIBRARY_PATH", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib"
systemProperty "java.library.path", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib"
environment "LD_LIBRARY_PATH", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib;${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/lib"
systemProperty "java.library.path", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib:${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/lib"
}
}

Expand Down

0 comments on commit 7ec926b

Please sign in to comment.