Skip to content

Commit

Permalink
Updates integTest behavior to accept the version and set the password…
Browse files Browse the repository at this point in the history
… accordingly

Signed-off-by: Darshit Chanpura <[email protected]>
(cherry picked from commit d703887)
  • Loading branch information
DarshitChanpura committed Feb 9, 2024
1 parent 4d22b88 commit 9212cd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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", "2.12.0-SNAPSHOT")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
Expand Down Expand Up @@ -430,7 +429,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)
}

Expand Down Expand Up @@ -683,7 +682,6 @@ clusters.each { name ->
if (securityEnabled) {
plugin(provider(securityPluginOld))
cliSetup("opensearch-security/install_demo_configuration.sh", "-y")

}
// Currently fetching the ARCHIVE distribution fails on mac as it tries to fetch the Mac specific "DARWIN" distribution
// for Opensearch which is not publish yet. Changing this to INTEG_TEST to make it work on mac.
Expand Down
16 changes: 10 additions & 6 deletions scripts/integtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -70,15 +70,19 @@ 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
# 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!"
fi
fi

Expand Down Expand Up @@ -125,4 +129,4 @@ else
TRANSPORT_PORT="9300"
fi
./gradlew singleClusterSanityTest -Dfollower.http_host="$BIND_ADDRESS:$BIND_PORT" -Dfollower.transport_host="$BIND_ADDRESS:$TRANSPORT_PORT" -Dsecurity_enabled=$SECURITY_ENABLED -Duser=$USERNAME -Dpassword=$PASSWORD --console=plain
fi
fi

0 comments on commit 9212cd2

Please sign in to comment.