Skip to content

Commit 978675f

Browse files
Refactor BWC framework into sub-projects (#362)
Signed-off-by: Naveen Tatikonda <navtat@amazon.com>
1 parent e1aad3e commit 978675f

File tree

11 files changed

+576
-205
lines changed

11 files changed

+576
-205
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Run k-NN Backwards Compatibility Tests
4141
run: |
4242
echo "Running backwards compatibility tests ..."
43-
./gradlew :qa:bwc:bwcTestSuite
43+
./gradlew :qa:bwcTestSuite
4444
4545
- name: Upload Coverage Report
4646
uses: codecov/codecov-action@v1

DEVELOPER_GUIDE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@ Additionally, it is possible to attach one debugger to the cluster JVM and anoth
250250
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)
251251

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

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

RELEASING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Repositories create consistent release labels, such as `v1.0.0`, `v1.1.0` and `v
3131

3232
## Backwards Compatibility
3333

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

3737
## Releasing

build.gradle

+11-13
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,18 @@ allprojects {
6464
}
6565

6666
afterEvaluate {
67-
if (project.name != "qa") {
68-
project.dependencyLicenses.enabled = false
69-
project.thirdPartyAudit.enabled = false
70-
project.loggerUsageCheck.enabled = false
71-
project.forbiddenApis.ignoreFailures = true
72-
project.forbiddenPatterns {
73-
setEnabled(false)
74-
}
75-
project.testingConventions.enabled = false
76-
project.validateNebulaPom.enabled = false
77-
project.licenseFile = rootProject.file('LICENSE.txt')
78-
project.noticeFile = rootProject.file('NOTICE.txt')
79-
project.forbiddenApis.ignoreFailures = true
67+
project.dependencyLicenses.enabled = false
68+
project.thirdPartyAudit.enabled = false
69+
project.loggerUsageCheck.enabled = false
70+
project.forbiddenApis.ignoreFailures = true
71+
project.forbiddenPatterns {
72+
setEnabled(false)
8073
}
74+
project.testingConventions.enabled = false
75+
project.validateNebulaPom.enabled = false
76+
project.licenseFile = rootProject.file('LICENSE.txt')
77+
project.noticeFile = rootProject.file('NOTICE.txt')
78+
project.forbiddenApis.ignoreFailures = true
8179
}
8280
}
8381

qa/build.gradle

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
7+
apply plugin: 'opensearch.testclusters'
8+
apply plugin: 'opensearch.build'
9+
apply plugin: 'opensearch.rest-test'
10+
11+
// Disable a few tasks that come with build
12+
build.enabled = false
13+
integTest.enabled = false
14+
test.enabled = false
15+
assemble.enabled = false
16+
dependenciesInfo.enabled = false
17+
18+
dependencies {
19+
api "org.opensearch:opensearch:${opensearch_version}"
20+
compileOnly "org.opensearch.plugin:opensearch-scripting-painless-spi:${versions.opensearch}"
21+
api group: 'commons-lang', name: 'commons-lang', version: '2.6'
22+
23+
api "org.apache.logging.log4j:log4j-api:${versions.log4j}"
24+
api "org.apache.logging.log4j:log4j-core:${versions.log4j}"
25+
26+
testImplementation "org.opensearch.test:framework:${opensearch_version}"
27+
testImplementation(testFixtures(rootProject))
28+
}
29+
30+
def tmp_dir = project.file('build/private/artifact_tmp').absoluteFile
31+
tmp_dir.mkdirs()
32+
String knn_bwc_version = System.getProperty("bwc.version")
33+
34+
// Task to pull k-NN plugin from archive
35+
task pullBwcPlugin {
36+
doFirst {
37+
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-*")
38+
}
39+
40+
doLast {
41+
ant.get(
42+
src: "https://artifacts.opensearch.org/releases/bundle/opensearch/${knn_bwc_version}/opensearch-${knn_bwc_version}-linux-x64.tar.gz",
43+
dest: tmp_dir.absolutePath,
44+
httpusecaches: false
45+
)
46+
copy {
47+
from tarTree(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version}-linux-x64.tar.gz"))
48+
into tmp_dir.absolutePath
49+
}
50+
copy {
51+
from(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version}", "plugins", "opensearch-knn"))
52+
into java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn")
53+
}
54+
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")
55+
}
56+
}
57+
58+
// Task to zip plugin from archive
59+
task zipBwcPlugin(type: Zip) {
60+
dependsOn "pullBwcPlugin"
61+
from(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn"))
62+
destinationDirectory = tmp_dir
63+
archiveFileName = "opensearch-knn-${knn_bwc_version}.zip"
64+
doLast {
65+
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn")
66+
}
67+
}
68+
69+
task bwcTestSuite {
70+
dependsOn ":qa:restart-upgrade:testRestartUpgrade"
71+
dependsOn ":qa:rolling-upgrade:testRollingUpgrade"
72+
}

qa/bwc/build.gradle

-185
This file was deleted.

qa/restart-upgrade/build.gradle

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
7+
8+
apply from : "$rootDir/qa/build.gradle"
9+
10+
String knn_bwc_version = System.getProperty("bwc.version")
11+
String baseName = "knnBwcCluster-restart"
12+
13+
// Creates a test cluster of previous version and loads k-NN plugin of bwcVersion
14+
testClusters {
15+
"${baseName}" {
16+
testDistribution = "ARCHIVE"
17+
versions = [knn_bwc_version, opensearch_version]
18+
numberOfNodes = 3
19+
plugin(project.tasks.zipBwcPlugin.archiveFile)
20+
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
21+
setting 'http.content_type.required', 'true'
22+
environment "LD_LIBRARY_PATH", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib"
23+
systemProperty "java.library.path", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version}-ARCHIVE/plugins/opensearch-knn/knnlib"
24+
}
25+
}
26+
27+
// Task to run BWC tests against the old cluster
28+
task "testAgainstOldCluster"(type: StandaloneRestIntegTestTask) {
29+
dependsOn "zipBwcPlugin"
30+
useCluster testClusters."${baseName}"
31+
systemProperty 'tests.rest.bwcsuite_cluster', 'old_cluster'
32+
systemProperty 'tests.rest.bwcsuite_round', 'old'
33+
systemProperty 'tests.plugin_bwc_version', knn_bwc_version
34+
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
35+
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
36+
systemProperty 'tests.security.manager', 'false'
37+
}
38+
39+
// All nodes are upgraded to latest version and run the tests
40+
task testRestartUpgrade(type: StandaloneRestIntegTestTask) {
41+
dependsOn "testAgainstOldCluster"
42+
dependsOn rootProject.tasks.buildJniLib
43+
dependsOn rootProject.tasks.assemble
44+
useCluster testClusters."${baseName}"
45+
doFirst {
46+
testClusters."${baseName}".environment("LD_LIBRARY_PATH", "$rootDir/jni/release")
47+
testClusters."${baseName}".systemProperty("java.library.path", "$rootDir/jni/release")
48+
testClusters."${baseName}".upgradeAllNodesAndPluginsToNextVersion([rootProject.tasks.bundlePlugin.archiveFile])
49+
}
50+
systemProperty 'tests.rest.bwcsuite_cluster', 'upgraded_cluster'
51+
systemProperty 'tests.rest.bwcsuite_round', 'fullrestart'
52+
systemProperty 'tests.plugin_bwc_version', knn_bwc_version
53+
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
54+
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
55+
systemProperty 'tests.security.manager', 'false'
56+
}

0 commit comments

Comments
 (0)