Skip to content

Commit

Permalink
Refactor BWC framework into sub-projects (#362)
Browse files Browse the repository at this point in the history
Signed-off-by: Naveen Tatikonda <navtat@amazon.com>
  • Loading branch information
naveentatikonda authored Apr 18, 2022
1 parent e1aad3e commit 978675f
Show file tree
Hide file tree
Showing 11 changed files with 576 additions and 205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Run k-NN Backwards Compatibility Tests
run: |
echo "Running backwards compatibility tests ..."
./gradlew :qa:bwc:bwcTestSuite
./gradlew :qa:bwcTestSuite
- name: Upload Coverage Report
uses: codecov/codecov-action@v1
Expand Down
8 changes: 4 additions & 4 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ Additionally, it is possible to attach one debugger to the cluster JVM and anoth
The purpose of Backwards Compatibility Testing and different types of BWC tests are explained [here](https://github.com/opensearch-project/opensearch-plugins/blob/main/TESTING.md#backwards-compatibility-testing)

Use these commands to run BWC tests for k-NN:
1. Rolling upgrade tests: `./gradlew :qa:bwc:testRollingUpgrade`
2. Full restart upgrade tests: `./gradlew :qa:bwc:testRestartUpgrade`
3. `./gradlew :qa:bwc:bwcTestSuite` is used to run all the above bwc tests together.
1. Rolling upgrade tests: `./gradlew :qa:rolling-upgrade:testRollingUpgrade`
2. Full restart upgrade tests: `./gradlew :qa:restart-upgrade:testRestartUpgrade`
3. `./gradlew :qa:bwcTestSuite` is used to run all the above bwc tests together.

Use this command to run BWC tests for a given Backwards Compatibility Version:
```
./gradlew :qa:bwc:bwcTestSuite -Dbwc.version=1.0.0
./gradlew :qa:bwcTestSuite -Dbwc.version=1.0.0
```
Here, we are testing BWC Tests with BWC version of plugin as 1.0.0.

Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Repositories create consistent release labels, such as `v1.0.0`, `v1.1.0` and `v

## Backwards Compatibility

[The backwards compatibility test suite](qa/bwc) is used to ensure upgrades to the current version are successful.
[The backwards compatibility test suite](qa) is used to ensure upgrades to the current version are successful.
When releasing a new version, update the `bwc.version` to the latest, previous minor version in [gradle.properties](gradle.properties).

## Releasing
Expand Down
24 changes: 11 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,18 @@ allprojects {
}

afterEvaluate {
if (project.name != "qa") {
project.dependencyLicenses.enabled = false
project.thirdPartyAudit.enabled = false
project.loggerUsageCheck.enabled = false
project.forbiddenApis.ignoreFailures = true
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
project.dependencyLicenses.enabled = false
project.thirdPartyAudit.enabled = false
project.loggerUsageCheck.enabled = false
project.forbiddenApis.ignoreFailures = true
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
72 changes: 72 additions & 0 deletions qa/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/


apply plugin: 'opensearch.testclusters'
apply plugin: 'opensearch.build'
apply plugin: 'opensearch.rest-test'

// Disable a few tasks that come with build
build.enabled = false
integTest.enabled = false
test.enabled = false
assemble.enabled = false
dependenciesInfo.enabled = false

dependencies {
api "org.opensearch:opensearch:${opensearch_version}"
compileOnly "org.opensearch.plugin:opensearch-scripting-painless-spi:${versions.opensearch}"
api group: 'commons-lang', name: 'commons-lang', version: '2.6'

api "org.apache.logging.log4j:log4j-api:${versions.log4j}"
api "org.apache.logging.log4j:log4j-core:${versions.log4j}"

testImplementation "org.opensearch.test:framework:${opensearch_version}"
testImplementation(testFixtures(rootProject))
}

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

// Task to pull k-NN plugin from archive
task pullBwcPlugin {
doFirst {
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-*")
}

doLast {
ant.get(
src: "https://artifacts.opensearch.org/releases/bundle/opensearch/${knn_bwc_version}/opensearch-${knn_bwc_version}-linux-x64.tar.gz",
dest: tmp_dir.absolutePath,
httpusecaches: false
)
copy {
from tarTree(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version}-linux-x64.tar.gz"))
into tmp_dir.absolutePath
}
copy {
from(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version}", "plugins", "opensearch-knn"))
into java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn")
}
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version}"), java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version}-linux-x64.tar.gz")
}
}

// Task to zip plugin from archive
task zipBwcPlugin(type: Zip) {
dependsOn "pullBwcPlugin"
from(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn"))
destinationDirectory = tmp_dir
archiveFileName = "opensearch-knn-${knn_bwc_version}.zip"
doLast {
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn")
}
}

task bwcTestSuite {
dependsOn ":qa:restart-upgrade:testRestartUpgrade"
dependsOn ":qa:rolling-upgrade:testRollingUpgrade"
}
185 changes: 0 additions & 185 deletions qa/bwc/build.gradle

This file was deleted.

56 changes: 56 additions & 0 deletions qa/restart-upgrade/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask

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

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

// Creates a test cluster of previous version and loads k-NN plugin of bwcVersion
testClusters {
"${baseName}" {
testDistribution = "ARCHIVE"
versions = [knn_bwc_version, opensearch_version]
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"
}
}

// 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.rest.bwcsuite_round', 'old'
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'
}

// 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])
}
systemProperty 'tests.rest.bwcsuite_cluster', 'upgraded_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'fullrestart'
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'
}
Loading

0 comments on commit 978675f

Please sign in to comment.