Skip to content

Commit be3ab98

Browse files
committed
Trying to fix bwc tests
Signed-off-by: bowenlan-amzn <[email protected]>
1 parent a29948c commit be3ab98

File tree

8 files changed

+71
-38
lines changed

8 files changed

+71
-38
lines changed

build.gradle

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ buildscript {
4444
opensearch_build += "-SNAPSHOT"
4545
}
4646
if (!isSnapshot) {
47-
opensearch_version = opensearch_version.replace("-SNAPSHOT","")
47+
opensearch_version = opensearch_version.replace("-SNAPSHOT", "")
4848
}
49-
opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT","")
49+
opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT", "")
5050

5151
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
5252

@@ -212,7 +212,7 @@ dependencies {
212212
testImplementation "org.opensearch.test:framework:${opensearch_version}"
213213
testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
214214
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
215-
testImplementation "org.mockito:mockito-core:4.7.0"
215+
testImplementation "org.mockito:mockito-core:${versions.mockito}"
216216

217217
add("ktlint", "com.pinterest:ktlint:0.45.1") {
218218
attributes {
@@ -222,8 +222,8 @@ dependencies {
222222

223223
// https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/
224224
opensearchPlugin "org.opensearch.plugin:opensearch-job-scheduler:${job_scheduler_version}@zip"
225-
opensearchPlugin "org.opensearch.plugin:notifications:${notifications_version}@zip"
226225
opensearchPlugin "org.opensearch.plugin:opensearch-notifications-core:${notifications_version}@zip"
226+
opensearchPlugin "org.opensearch.plugin:notifications:${notifications_version}@zip"
227227
opensearchPlugin "org.opensearch.plugin:opensearch-security:${security_plugin_version}@zip"
228228
}
229229

@@ -282,7 +282,6 @@ ext.resolvePluginFile = { pluginId ->
282282
return new RegularFile() {
283283
@Override
284284
File getAsFile() {
285-
println("Resolving ${pluginId}")
286285
return configurations.opensearchPlugin.resolvedConfiguration.resolvedArtifacts
287286
.find { ResolvedArtifact f ->
288287
f.name.startsWith(pluginId)
@@ -294,13 +293,13 @@ ext.resolvePluginFile = { pluginId ->
294293
}
295294
}
296295
def jobSchedulerFile = resolvePluginFile("opensearch-job-scheduler")
297-
def notificationsFile = resolvePluginFile("notifications")
298296
def notificationsCoreFile = resolvePluginFile("opensearch-notifications-core")
297+
def notificationsFile = resolvePluginFile("notifications")
299298
def securityPluginFile = resolvePluginFile("opensearch-security")
300299

301300
ext.getPluginResource = { download_to_folder, download_from_src ->
302301
def src_split = download_from_src.split("/")
303-
def download_file = src_split[src_split.length-1]
302+
def download_file = src_split[src_split.length - 1]
304303
if (!fileTree(download_to_folder).contains(new File("$project.rootDir/$download_to_folder/$download_file"))) {
305304
println("Downloading ${download_file}")
306305
project.delete download_to_folder
@@ -372,8 +371,8 @@ testClusters.integTest {
372371
}
373372

374373
plugin(provider(jobSchedulerFile))
375-
plugin(provider(notificationsFile))
376374
plugin(provider(notificationsCoreFile))
375+
plugin(provider(notificationsFile))
377376
if (securityEnabled) {
378377
plugin(provider(securityPluginFile))
379378
}
@@ -488,7 +487,7 @@ def waitForClusterSetup(OpenSearchCluster cluster, Boolean securityEnabled) {
488487
String unicastUris = cluster.nodes.stream().flatMap { node ->
489488
node.getAllTransportPortURI().stream()
490489
}.collect(Collectors.joining("\n"))
491-
cluster.nodes.forEach {node ->
490+
cluster.nodes.forEach { node ->
492491
try {
493492
Files.write(node.getConfigDir().resolve("unicast_hosts.txt"), unicastUris.getBytes(StandardCharsets.UTF_8))
494493
} catch (IOException e) {
@@ -501,7 +500,7 @@ def waitForClusterSetup(OpenSearchCluster cluster, Boolean securityEnabled) {
501500
WaitForClusterYellow wait = new WaitForClusterYellow(protocol, cluster.getFirstNode().getHttpSocketURI(), cluster.nodes.size())
502501
wait.setUsername(System.getProperty("user", "admin"))
503502
wait.setPassword(System.getProperty("password", "admin"))
504-
return wait.wait(500)
503+
return wait.wait(180000)
505504
}
506505

507506
cluster.@waitConditions.put("cluster health yellow", pred)
@@ -560,7 +559,7 @@ integTest {
560559
}
561560
}
562561

563-
task integTestRemote(type: RestIntegTestTask) {
562+
task integTestRemote(type: RestIntegTestTask) {
564563
testClassesDirs = sourceSets.test.output.classesDirs
565564
classpath = sourceSets.test.runtimeClasspath
566565
systemProperty 'tests.security.manager', 'false'
@@ -597,12 +596,11 @@ task integTestRemote(type: RestIntegTestTask) {
597596

598597
// === Set up BWC tests ===
599598

600-
String bwcVersionShort = "2.4.0"
599+
String bwcVersionShort = "2.5.0"
601600
String bwcVersion = bwcVersionShort + ".0"
602-
String bwcJobSchedulerVersion = "1.13.0.0"
603601
String baseName = "indexmanagementBwcCluster"
604602
String bwcFilePath = "src/test/resources/bwc/"
605-
String bwc_js_resource_location = bwcFilePath + "job-scheduler/" + bwcJobSchedulerVersion
603+
String bwc_js_resource_location = bwcFilePath + "job-scheduler/" + bwcVersion
606604
String bwc_im_resource_location = bwcFilePath + "indexmanagement/" + bwcVersion
607605

608606
// Downloads the bwc job scheduler version
@@ -613,13 +611,13 @@ String bwc_js_download_url = 'https://ci.opensearch.org/ci/dbc/distribution-buil
613611
String bwc_im_download_url = 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/' + bwcVersionShort + '/latest/linux/x64/tar/builds/' +
614612
'opensearch/plugins/opensearch-index-management-' + bwcVersion + '.zip'
615613

616-
2.times {i ->
614+
2.times { i ->
617615
testClusters {
618616
"${baseName}$i" {
619617
testDistribution = "ARCHIVE"
620618
versions = [bwcVersionShort, opensearch_version]
621619
numberOfNodes = 3
622-
plugin(provider(new Callable<RegularFile>(){
620+
plugin(provider(new Callable<RegularFile>() {
623621
@Override
624622
RegularFile call() throws Exception {
625623
return new RegularFile() {
@@ -630,8 +628,7 @@ String bwc_im_download_url = 'https://ci.opensearch.org/ci/dbc/distribution-buil
630628
}
631629
}
632630
}))
633-
634-
plugin(provider(new Callable<RegularFile>(){
631+
plugin(provider(new Callable<RegularFile>() {
635632
@Override
636633
RegularFile call() throws Exception {
637634
return new RegularFile() {
@@ -656,14 +653,14 @@ task prepareBwcTests {
656653
dependsOn bundlePlugin
657654
doLast {
658655
plugins = [
659-
provider(jobSchedulerFile),
660-
project.getObjects().fileProperty().value(project.tasks.bundlePlugin.archiveFile)
656+
provider(jobSchedulerFile),
657+
project.getObjects().fileProperty().value(project.tasks.bundlePlugin.archiveFile)
661658
]
662659
}
663660
}
664661

665662
// Create two test clusters with 3 nodes of the old version
666-
2.times {i ->
663+
2.times { i ->
667664
task "${baseName}#oldVersionClusterTask$i"(type: StandaloneRestIntegTestTask) {
668665
dependsOn 'prepareBwcTests'
669666
useCluster testClusters."${baseName}$i"
@@ -675,17 +672,21 @@ task prepareBwcTests {
675672
systemProperty 'tests.plugin_bwc_version', bwcVersion
676673
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}$i".allHttpSocketURI.join(",")}")
677674
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}$i".getName()}")
675+
systemProperty 'tests.security.manager', 'false'
678676
}
679677
}
680678

681679
// Upgrade one node of the old cluster to new OpenSearch version with upgraded plugin version.
682680
// This results in a mixed cluster with 2 nodes on the old version and 1 upgraded node.
683681
// This is also used as a one third upgraded cluster for a rolling upgrade.
684-
task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
685-
useCluster testClusters."${baseName}0"
682+
task "${baseName}#oneThirdsUpgradeCluster"(type: StandaloneRestIntegTestTask) {
686683
dependsOn "${baseName}#oldVersionClusterTask0"
684+
useCluster testClusters."${baseName}0"
687685
doFirst {
688686
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
687+
getClusters().forEach { cluster ->
688+
waitForClusterSetup(cluster, securityEnabled)
689+
}
689690
}
690691
filter {
691692
includeTestsMatching "org.opensearch.indexmanagement.bwc.*IT"
@@ -695,13 +696,14 @@ task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
695696
systemProperty 'tests.plugin_bwc_version', bwcVersion
696697
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
697698
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
699+
systemProperty 'tests.security.manager', 'false'
698700
}
699701

700702
// Upgrade the second node to new OpenSearch version with upgraded plugin version after the first node is upgraded.
701703
// This results in a mixed cluster with 1 node on the old version and 2 upgraded nodes.
702704
// This is used for rolling upgrade.
703705
task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTask) {
704-
dependsOn "${baseName}#mixedClusterTask"
706+
dependsOn "${baseName}#oneThirdsUpgradeCluster"
705707
useCluster testClusters."${baseName}0"
706708
doFirst {
707709
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
@@ -714,6 +716,7 @@ task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTas
714716
systemProperty 'tests.plugin_bwc_version', bwcVersion
715717
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
716718
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
719+
systemProperty 'tests.security.manager', 'false'
717720
}
718721

719722
// Upgrade the third node to new OpenSearch version with upgraded plugin version after the second node is upgraded.
@@ -728,12 +731,12 @@ task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask)
728731
filter {
729732
includeTestsMatching "org.opensearch.indexmanagement.bwc.*IT"
730733
}
731-
mustRunAfter "${baseName}#mixedClusterTask"
732-
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
734+
systemProperty 'tests.rest.bwcsuite', 'upgraded_cluster'
733735
systemProperty 'tests.rest.bwcsuite_round', 'third'
734736
systemProperty 'tests.plugin_bwc_version', bwcVersion
735737
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
736738
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
739+
systemProperty 'tests.security.manager', 'false'
737740
}
738741

739742
// Upgrade all the nodes of the old cluster to new OpenSearch version with upgraded plugin version
@@ -751,13 +754,13 @@ task "${baseName}#fullRestartClusterTask"(type: StandaloneRestIntegTestTask) {
751754
systemProperty 'tests.plugin_bwc_version', bwcVersion
752755
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}1".allHttpSocketURI.join(",")}")
753756
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}1".getName()}")
757+
systemProperty 'tests.security.manager', 'false'
754758
}
755759

756760
// A bwc test suite which runs all the bwc tasks combined
757761
task bwcTestSuite(type: StandaloneRestIntegTestTask) {
758762
exclude '**/*Test*'
759763
exclude '**/*IT*'
760-
dependsOn tasks.named("${baseName}#mixedClusterTask")
761764
dependsOn tasks.named("${baseName}#rollingUpgradeClusterTask")
762765
dependsOn tasks.named("${baseName}#fullRestartClusterTask")
763766
}
@@ -848,6 +851,6 @@ task updateVersion {
848851
ext.newVersion = System.getProperty('newVersion')
849852
println "Setting version to ${newVersion}."
850853
// String tokenization to support -SNAPSHOT
851-
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
854+
ant.replaceregexp(file: 'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags: 'g', byline: true)
852855
}
853856
}

src/test/kotlin/org/opensearch/indexmanagement/IndexStateManagementSecurityBehaviorIT.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ class IndexStateManagementSecurityBehaviorIT : SecurityRestTestCase() {
8484
assignRoleToUsers(HELPDESK_ROLE, listOf(superIsmUser))
8585

8686
superUserClient =
87-
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), superIsmUser, password).setSocketTimeout(60000)
87+
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), superIsmUser, password).setSocketTimeout(
88+
60000
89+
).setConnectionRequestTimeout(180000)
8890
.build()
8991
}
9092

@@ -105,6 +107,7 @@ class IndexStateManagementSecurityBehaviorIT : SecurityRestTestCase() {
105107

106108
testClient =
107109
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), testUser, password).setSocketTimeout(60000)
110+
.setConnectionRequestTimeout(180000)
108111
.build()
109112

110113
val indexName = "${AIRLINE_INDEX}_index_basic"
@@ -157,6 +160,7 @@ class IndexStateManagementSecurityBehaviorIT : SecurityRestTestCase() {
157160

158161
testClient =
159162
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), testUser, password).setSocketTimeout(60000)
163+
.setConnectionRequestTimeout(180000)
160164
.build()
161165
try {
162166
val testPolicyJson = createReplicaCountTestPolicyRequest(10, "")
@@ -178,6 +182,7 @@ class IndexStateManagementSecurityBehaviorIT : SecurityRestTestCase() {
178182

179183
testClient =
180184
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), testUser, password).setSocketTimeout(60000)
185+
.setConnectionRequestTimeout(180000)
181186
.build()
182187
try {
183188
val testPolicyJson = createReplicaCountTestPolicyRequest(10, AIRLINE_INDEX_PATTERN)
@@ -197,10 +202,14 @@ class IndexStateManagementSecurityBehaviorIT : SecurityRestTestCase() {
197202
}
198203

199204
fun `test delete policy`() {
200-
createTestUserWithRole(listOf(EXPLAIN_INDEX, GET_POLICY, EXPLAIN_INDEX), listOf(GET_INDEX_MAPPING, SEARCH_INDEX))
205+
createTestUserWithRole(
206+
listOf(EXPLAIN_INDEX, GET_POLICY, EXPLAIN_INDEX),
207+
listOf(GET_INDEX_MAPPING, SEARCH_INDEX)
208+
)
201209

202210
testClient =
203211
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), testUser, password).setSocketTimeout(60000)
212+
.setConnectionRequestTimeout(180000)
204213
.build()
205214

206215
try {

src/test/kotlin/org/opensearch/indexmanagement/ODFERestTestCase.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ abstract class ODFERestTestCase : OpenSearchRestTestCase() {
5050
// create adminDN (super-admin) client
5151
val uri = javaClass.classLoader.getResource("security/sample.pem")?.toURI()
5252
val configPath = PathUtils.get(uri).parent.toAbsolutePath()
53-
SecureRestClientBuilder(settings, configPath, hosts).setSocketTimeout(5000).build()
53+
SecureRestClientBuilder(settings, configPath, hosts).setSocketTimeout(60000)
54+
.setConnectionRequestTimeout(180000).build()
5455
}
56+
5557
false -> {
5658
// create client with passed user
5759
val userName = System.getProperty("user")
5860
val password = System.getProperty("password")
59-
SecureRestClientBuilder(hosts, isHttps(), userName, password).setSocketTimeout(5000).build()
61+
SecureRestClientBuilder(hosts, isHttps(), userName, password).setSocketTimeout(60000)
62+
.setConnectionRequestTimeout(180000).build()
6063
}
6164
}
6265
} else {

src/test/kotlin/org/opensearch/indexmanagement/RollupSecurityBehaviorIT.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class RollupSecurityBehaviorIT : SecurityRestTestCase() {
7272
assignRoleToUsers(HELPDESK_ROLE, listOf(superRollupUser))
7373

7474
superUserClient =
75-
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), superRollupUser, password).setSocketTimeout(60000)
75+
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), superRollupUser, password).setSocketTimeout(
76+
60000
77+
).setConnectionRequestTimeout(180000)
7678
.build()
7779
}
7880

@@ -120,6 +122,7 @@ class RollupSecurityBehaviorIT : SecurityRestTestCase() {
120122

121123
testUserClient =
122124
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), testUser, password).setSocketTimeout(60000)
125+
.setConnectionRequestTimeout(180000)
123126
.build()
124127

125128
val rollup = randomRollup()
@@ -149,6 +152,7 @@ class RollupSecurityBehaviorIT : SecurityRestTestCase() {
149152

150153
testUserClient =
151154
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), testUser, password).setSocketTimeout(60000)
155+
.setConnectionRequestTimeout(180000)
152156
.build()
153157

154158
val rollup = randomRollup()
@@ -194,6 +198,7 @@ class RollupSecurityBehaviorIT : SecurityRestTestCase() {
194198

195199
testUserClient =
196200
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), testUser, password).setSocketTimeout(60000)
201+
.setConnectionRequestTimeout(180000)
197202
.build()
198203
val rollup = randomRollup()
199204

src/test/kotlin/org/opensearch/indexmanagement/SecurityBehaviorIT.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class SecurityBehaviorIT : SecurityRestTestCase() {
5353

5454
johnClient =
5555
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), john, password).setSocketTimeout(60000)
56+
.setConnectionRequestTimeout(180000)
5657
.build()
5758
}
5859

@@ -97,9 +98,11 @@ class SecurityBehaviorIT : SecurityRestTestCase() {
9798

9899
val jillClient =
99100
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), jill, password).setSocketTimeout(60000)
101+
.setConnectionRequestTimeout(180000)
100102
.build()
101103
val janeClient =
102104
SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), jane, password).setSocketTimeout(60000)
105+
.setConnectionRequestTimeout(180000)
103106
.build()
104107

105108
setFilterByBackendRole(false)

0 commit comments

Comments
 (0)