Skip to content

Commit

Permalink
Consume numNodes sent during integTestRemote (#1085)
Browse files Browse the repository at this point in the history
* Consume numNodes sent during integTestRemote

Signed-off-by: monusingh-1 <[email protected]>

* Consume numNodes sent during integTestRemote

Signed-off-by: monusingh-1 <[email protected]>

* Address comments

Signed-off-by: monusingh-1 <[email protected]>

---------

Signed-off-by: monusingh-1 <[email protected]>
  • Loading branch information
monusingh-1 authored Jul 19, 2023
1 parent 7d5e071 commit 0f4af64
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,9 @@ task integTestRemote (type: RestIntegTestTask) {
systemProperty "tests.cluster.leaderCluster.security_enabled", System.getProperty("security_enabled")

nonInputProperties.systemProperty('tests.integTestRemote', "true")
var numberOfNodes = findProperty('numNodes') as Integer
systemProperty "tests.cluster.followCluster.total_nodes", "${-> numberOfNodes.toString()}"
systemProperty "tests.cluster.leaderCluster.total_nodes", "${-> numberOfNodes.toString()}"
systemProperty "build.dir", "${buildDir}"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() {
lateinit var testClusters : Map<String, TestCluster>
var isSecurityPropertyEnabled = false
var forceInitSecurityConfiguration = false
var isMultiNodeClusterConfiguration = true

internal fun createTestCluster(configuration: ClusterConfiguration) : TestCluster {
return createTestCluster(configuration.clusterName, configuration.preserveSnapshots, configuration.preserveIndices,
Expand All @@ -131,7 +130,6 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() {
val httpHostsProp = systemProperties.get("tests.cluster.${cluster}.http_hosts") as String?
val transportHostsProp = systemProperties.get("tests.cluster.${cluster}.transport_hosts") as String?
val securityEnabled = systemProperties.get("tests.cluster.${cluster}.security_enabled") as String?
val totalNodes = systemProperties.get("tests.cluster.${cluster}.total_nodes") as String?

requireNotNull(httpHostsProp) { "Missing http hosts property for cluster: $cluster."}
requireNotNull(transportHostsProp) { "Missing transport hosts property for cluster: $cluster."}
Expand All @@ -143,9 +141,6 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() {
isSecurityPropertyEnabled = true
}

if(totalNodes != null && totalNodes < "2") {
isMultiNodeClusterConfiguration = false
}

forceInitSecurityConfiguration = isSecurityPropertyEnabled && initSecurityConfiguration

Expand Down Expand Up @@ -664,6 +659,19 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() {
return integTestRemote.equals("true")
}

protected fun isMultiNodeClusterConfiguration(leaderCluster: String, followerCluster: String): Boolean{
val systemProperties = BootstrapInfo.getSystemProperties()
val totalLeaderNodes = systemProperties.get("tests.cluster.${leaderCluster}.total_nodes") as String
val totalFollowerNodes = systemProperties.get("tests.cluster.${followerCluster}.total_nodes") as String

assertNotNull(totalLeaderNodes)
assertNotNull(totalFollowerNodes)
if(totalLeaderNodes < "2" || totalFollowerNodes < "2" ) {
return false
}
return true
}

protected fun docCount(cluster: RestHighLevelClient, indexName: String) : Int {
val persistentConnectionRequest = Request("GET", "/$indexName/_search?pretty&q=*")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ClusterRerouteFollowerIT : MultiClusterRestTestCase() {

@Before
fun beforeTest() {
Assume.assumeTrue(isMultiNodeClusterConfiguration)
Assume.assumeTrue(isMultiNodeClusterConfiguration(LEADER, FOLLOWER))
}

fun `test replication works after rerouting a shard from one node to another in follower cluster`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ClusterRerouteLeaderIT : MultiClusterRestTestCase() {

@Before
fun beforeTest() {
Assume.assumeTrue(isMultiNodeClusterConfiguration)
Assume.assumeTrue(isMultiNodeClusterConfiguration(LEADER, FOLLOWER))
}

fun `test replication works after rerouting a shard from one node to another in leader cluster`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ class StartReplicationIT: MultiClusterRestTestCase() {
fun `test that wait_for_active_shards setting is updated on follower through start replication api`() {

//Ignore this test if clusters dont have multiple nodes
if(!isMultiNodeClusterConfiguration){
if(!isMultiNodeClusterConfiguration(LEADER, FOLLOWER)){
return
}

Expand Down

0 comments on commit 0f4af64

Please sign in to comment.