From 5601085d0895f02c618d5dcc5293237e44c38afa Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Mon, 5 Feb 2024 12:37:27 -0500 Subject: [PATCH 1/5] Updates integTest behavior to accept the version and set the password accordingly Signed-off-by: Darshit Chanpura --- scripts/integtest.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/integtest.sh b/scripts/integtest.sh index 464108c7..0d64d05a 100644 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -50,7 +50,7 @@ while getopts ":h:b:p:t:e:s:c:v:" arg; do CREDENTIAL=$OPTARG ;; v) - # Do nothing as we're not consuming this param. + OPENSEARCH_VERSION=$OPTARG ;; :) echo "-${OPTARG} requires an argument" @@ -70,15 +70,16 @@ then SECURITY_ENABLED="true" fi -IFS='.' read -ra version_array <<< "$OPENSEARCH_VERSION" +OPENSEARCH_REQUIRED_VERSION="2.12.0" if [ -z "$CREDENTIAL" ] then # Starting in 2.12.0, security demo configuration script requires an initial admin password - if (( ${version_array[0]} > 2 || (${version_array[0]} == 2 && ${version_array[1]} >= 12) )); then - CREDENTIAL="admin:myStrongPassword123!" - else + COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` + if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then CREDENTIAL="admin:admin" + else + CREDENTIAL="admin:myStrongPassword123!" fi fi From fcf8736e5388d47f5a3c4d143c5cfb09c121a4cf Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Mon, 5 Feb 2024 13:07:55 -0500 Subject: [PATCH 2/5] Updates credentials Signed-off-by: Darshit Chanpura --- scripts/integtest.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/integtest.sh b/scripts/integtest.sh index 0d64d05a..39d94c73 100644 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -70,17 +70,9 @@ then SECURITY_ENABLED="true" fi -OPENSEARCH_REQUIRED_VERSION="2.12.0" - if [ -z "$CREDENTIAL" ] then - # Starting in 2.12.0, security demo configuration script requires an initial admin password - COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` - if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then - CREDENTIAL="admin:admin" - else - CREDENTIAL="admin:myStrongPassword123!" - fi + CREDENTIAL="admin:admin" # CCR uses custom setup and hence doesn't require custom password fi USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` From 6f02a20394ec95955098729ed123bf9ce512b3d0 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Mon, 5 Feb 2024 13:39:53 -0500 Subject: [PATCH 3/5] Updates credentials to be admin Signed-off-by: Darshit Chanpura --- build.gradle | 3 +-- scripts/integtest.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index e7dbd2c5..40819857 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,6 @@ import org.opensearch.gradle.test.RestIntegTestTask buildscript { ext { - System.setProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD", "myStrongPassword123!") isSnapshot = "true" == System.getProperty("build.snapshot", "true") opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT") buildVersionQualifier = System.getProperty("build.version_qualifier", "") @@ -429,7 +428,7 @@ def configureCluster(OpenSearchCluster cluster, Boolean securityEnabled) { } CrossClusterWaitForHttpResource wait = new CrossClusterWaitForHttpResource(protocol, cluster.getFirstNode().getHttpSocketURI(), cluster.nodes.size()) wait.setUsername("admin") - wait.setPassword(System.getProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD")) + wait.setPassword("admin") return wait.wait(500) } diff --git a/scripts/integtest.sh b/scripts/integtest.sh index 39d94c73..0d64d05a 100644 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -70,9 +70,17 @@ then SECURITY_ENABLED="true" fi +OPENSEARCH_REQUIRED_VERSION="2.12.0" + if [ -z "$CREDENTIAL" ] then - CREDENTIAL="admin:admin" # CCR uses custom setup and hence doesn't require custom password + # Starting in 2.12.0, security demo configuration script requires an initial admin password + COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` + if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then + CREDENTIAL="admin:admin" + else + CREDENTIAL="admin:myStrongPassword123!" + fi fi USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` From 2f35225a55e779c293aceaa568ecb77b2441a811 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Thu, 8 Feb 2024 10:41:20 -0500 Subject: [PATCH 4/5] Forces HTTP1 version policy for local clusters Signed-off-by: Darshit Chanpura --- .../org/opensearch/replication/MultiClusterRestTestCase.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt index eca8750f..090bdf00 100644 --- a/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt @@ -27,6 +27,7 @@ import org.apache.hc.core5.http.message.BasicHeader import org.apache.hc.core5.http.io.entity.StringEntity import org.apache.hc.core5.ssl.SSLContexts import org.apache.hc.core5.http.io.entity.EntityUtils +import org.apache.hc.core5.http2.HttpVersionPolicy import org.apache.hc.core5.util.Timeout import org.apache.lucene.util.SetOnce import org.opensearch.action.admin.cluster.node.tasks.list.ListTasksRequest @@ -102,6 +103,7 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() { val builder = RestClient.builder(*httpHosts.toTypedArray()).setHttpClientConfigCallback { httpAsyncClientBuilder -> httpAsyncClientBuilder.setConnectionManager(connManager) + httpAsyncClientBuilder.setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_1) } configureClient(builder, getClusterSettings(clusterName), securityEnabled) builder.setStrictDeprecationMode(false) From 84b3422e0c3cf5ab23a46354d8aeaa2a953c6bc6 Mon Sep 17 00:00:00 2001 From: Darshit Chanpura Date: Fri, 9 Feb 2024 10:46:52 -0500 Subject: [PATCH 5/5] Adds more comments Signed-off-by: Darshit Chanpura --- scripts/integtest.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/integtest.sh b/scripts/integtest.sh index 0d64d05a..f967dc8a 100644 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -75,8 +75,11 @@ OPENSEARCH_REQUIRED_VERSION="2.12.0" if [ -z "$CREDENTIAL" ] then # Starting in 2.12.0, security demo configuration script requires an initial admin password - COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` - if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then + # Pick the minimum of two versions + VERSION_TO_COMPARE=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` + # Check if the compared version is not equal to the required version. + # If it is not equal, it means the current version is older. + if [ "$VERSION_TO_COMPARE" != "$OPENSEARCH_REQUIRED_VERSION" ]; then CREDENTIAL="admin:admin" else CREDENTIAL="admin:myStrongPassword123!"