Skip to content

Commit

Permalink
Add option for bwc tests in bundle level (opensearch-project#652)
Browse files Browse the repository at this point in the history
* Add option for bwc tests in bundle level

Signed-off-by: Zelin Hao <[email protected]>

* Fix bug for security

Signed-off-by: Zelin Hao <[email protected]>

Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh authored Jan 10, 2023
1 parent c9a988d commit e65ff1f
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 31 deletions.
120 changes: 90 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,13 @@ task integTestRemote(type: RestIntegTestTask) {
exclude 'org/opensearch/indexmanagement/indexstatemanagement/action/SnapshotActionIT.class'
}

String bwcVersion = "1.13.2.0"
String bwcMinVersion = "1.13.2.0"
String bwcJobSchedulerVersion = "1.13.0.0"
String bwcBundleVersion = "1.3.2.0"
Boolean bwcBundleTest = (project.findProperty('customDistributionDownloadType') != null &&
project.properties['customDistributionDownloadType'] == "bundle");
String bwcVersion = bwcBundleTest ? bwcBundleVersion : bwcMinVersion
String bwcCurrentVersion = opensearch_version.replace("-SNAPSHOT", "")
String baseName = "indexmanagementBwcCluster"
String bwcFilePath = "src/test/resources/bwc/"
String bwc_js_resource_location = bwcFilePath + "job-scheduler/" + bwcJobSchedulerVersion
Expand All @@ -641,38 +646,67 @@ getPluginResource(bwc_js_resource_location, bwc_js_download_url)

// Downloads the bwc index management version
String bwc_im_download_url = "https://github.com/opendistro-for-elasticsearch/index-management/releases/download/v" +
bwcVersion + "/index-management-artifacts.zip"
bwcMinVersion + "/index-management-artifacts.zip"
getPluginResource(bwc_im_resource_location, bwc_im_download_url)

2.times {i ->
testClusters {
"${baseName}$i" {
testDistribution = "ARCHIVE"
versions = ["7.10.2", opensearch_version]
numberOfNodes = 3
plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
return fileTree(bwc_js_resource_location).getSingleFile()
if (bwcBundleTest) {
versions = ["1.3.2", bwcCurrentVersion]
nodes.each { node ->
node.extraConfigFile("kirk.pem", file("src/test/resources/security/kirk.pem"))
node.extraConfigFile("kirk-key.pem", file("src/test/resources/security/kirk-key.pem"))
node.extraConfigFile("esnode.pem", file("src/test/resources/security/esnode.pem"))
node.extraConfigFile("esnode-key.pem", file("src/test/resources/security/esnode-key.pem"))
node.extraConfigFile("root-ca.pem", file("src/test/resources/security/root-ca.pem"))
node.setting("plugins.security.disabled", "true")
node.setting("plugins.security.ssl.transport.pemcert_filepath", "esnode.pem")
node.setting("plugins.security.ssl.transport.pemkey_filepath", "esnode-key.pem")
node.setting("plugins.security.ssl.transport.pemtrustedcas_filepath", "root-ca.pem")
node.setting("plugins.security.ssl.transport.enforce_hostname_verification", "false")
node.setting("plugins.security.ssl.http.enabled", "true")
node.setting("plugins.security.ssl.http.pemcert_filepath", "esnode.pem")
node.setting("plugins.security.ssl.http.pemkey_filepath", "esnode-key.pem")
node.setting("plugins.security.ssl.http.pemtrustedcas_filepath", "root-ca.pem")
node.setting("plugins.security.allow_unsafe_democertificates", "true")
node.setting("plugins.security.allow_default_init_securityindex", "true")
node.setting("plugins.security.authcz.admin_dn", "\n - CN=kirk,OU=client,O=client,L=test,C=de")
node.setting("plugins.security.audit.type", "internal_elasticsearch")
node.setting("plugins.security.enable_snapshot_restore_privilege", "true")
node.setting("plugins.security.check_snapshot_restore_write_privileges", "true")
node.setting("plugins.security.restapi.roles_enabled", "[\"all_access\", \"security_rest_api_access\"]")
node.setting("plugins.security.system_indices.enabled", "true")
}
} else {
versions = ["7.10.2", opensearch_version]
plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
return fileTree(bwc_js_resource_location).getSingleFile()
}
}
}
}
}))
}))

plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
return fileTree(bwc_im_resource_location).getSingleFile()
plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
return fileTree(bwc_im_resource_location).getSingleFile()
}
}
}
}
}))
}))
}

setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
setting 'http.content_type.required', 'true'
}
Expand Down Expand Up @@ -708,7 +742,9 @@ task prepareBwcTests {
// Create two test clusters with 3 nodes of the old version
2.times {i ->
task "${baseName}#oldVersionClusterTask$i"(type: StandaloneRestIntegTestTask) {
dependsOn 'prepareBwcTests'
if (!bwcBundleTest){
dependsOn 'prepareBwcTests'
}
useCluster testClusters."${baseName}$i"
filter {
includeTestsMatching "org.opensearch.indexmanagement.bwc.*IT"
Expand All @@ -727,8 +763,14 @@ task prepareBwcTests {
task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
useCluster testClusters."${baseName}0"
dependsOn "${baseName}#oldVersionClusterTask0"
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
if (bwcBundleTest){
doFirst {
testClusters."${baseName}0".nextNodeToNextVersion()
}
} else {
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
}
}
filter {
includeTestsMatching "org.opensearch.indexmanagement.bwc.*IT"
Expand All @@ -746,8 +788,14 @@ task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTask) {
dependsOn "${baseName}#mixedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
if (bwcBundleTest){
doFirst {
testClusters."${baseName}0".nextNodeToNextVersion()
}
} else {
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
}
}
filter {
includeTestsMatching "org.opensearch.indexmanagement.bwc.*IT"
Expand All @@ -765,8 +813,14 @@ task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTas
task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask) {
dependsOn "${baseName}#twoThirdsUpgradedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
if (bwcBundleTest){
doFirst {
testClusters."${baseName}0".nextNodeToNextVersion()
}
} else {
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
}
}
filter {
includeTestsMatching "org.opensearch.indexmanagement.bwc.*IT"
Expand All @@ -784,8 +838,14 @@ task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask)
task "${baseName}#fullRestartClusterTask"(type: StandaloneRestIntegTestTask) {
dependsOn "${baseName}#oldVersionClusterTask1"
useCluster testClusters."${baseName}1"
doFirst {
testClusters."${baseName}1".upgradeAllNodesAndPluginsToNextVersion(plugins)
if (bwcBundleTest){
doFirst {
testClusters."${baseName}1".goToNextVersion()
}
} else {
doFirst {
testClusters."${baseName}1".upgradeAllNodesAndPluginsToNextVersion(plugins)
}
}
filter {
includeTestsMatching "org.opensearch.indexmanagement.bwc.*IT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class IndexManagementBackwardsCompatibilityIT : IndexManagementRestTestCase() {
val pluginNames = plugins.map { plugin -> plugin ["name"] }.toSet()
when (CLUSTER_TYPE) {
ClusterType.OLD -> {
assertTrue(pluginNames.contains("opendistro-index-management"))
assertTrue(pluginNames.contains("opendistro-index-management") || pluginNames.contains("opensearch-index-management"))
createBasicPolicy()

verifyPolicyExists(LEGACY_POLICY_BASE_URI)
Expand Down

0 comments on commit e65ff1f

Please sign in to comment.