From b126c6894b865d264f23fe000f6cccf88f41ec43 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 30 Oct 2024 23:33:34 -0400 Subject: [PATCH 1/5] Add integtest.sh script and remove integTest dependency on integrationTest task Signed-off-by: Craig Perkins --- README.md | 4 ++ build.gradle | 6 --- scripts/integtest.sh | 105 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 scripts/integtest.sh diff --git a/README.md b/README.md index 44df49eb77..0c7f7f0b0a 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ Run tests against local cluster: ```bash ./gradlew integTestRemote -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername=docker-cluster -Dsecurity=true -Dhttps=true -Duser=admin -Dpassword=admin -Dcommon_utils.version="2.2.0.0" ``` +OR +```bash +./scripts/integtest.sh +``` Note: To run against a remote cluster replace cluster-name and `localhost:9200` with the IPAddress:Port of that cluster. Build artifacts (zip, deb, rpm): diff --git a/build.gradle b/build.gradle index ae34ea67e2..b56c518937 100644 --- a/build.gradle +++ b/build.gradle @@ -569,12 +569,6 @@ task integrationTest(type: Test) { } } -tasks.named("integrationTest") { - minHeapSize = "512m" - maxHeapSize = "2g" -} - -tasks.integTest.dependsOn(integrationTest) tasks.integrationTest.finalizedBy(jacocoTestReport) // report is always generated after integration tests run //run the integrationTest task before the check task diff --git a/scripts/integtest.sh b/scripts/integtest.sh new file mode 100644 index 0000000000..98ee40fbd6 --- /dev/null +++ b/scripts/integtest.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +set -e + +function usage() { + echo "" + echo "This script is used to run integration tests for plugin installed on a remote OpenSearch/Dashboards cluster." + echo "--------------------------------------------------------------------------" + echo "Usage: $0 [args]" + echo "" + echo "Required arguments:" + echo "None" + echo "" + echo "Optional arguments:" + echo -e "-b BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." + echo -e "-p BIND_PORT\t, defaults to 9200, can be changed to any port for the cluster location." + echo -e "-s SECURITY_ENABLED\t(true | false), defaults to true. Specify the OpenSearch/Dashboards have security enabled or not." + echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true." + echo -e "-h\tPrint this message." + echo -e "-v OPENSEARCH_VERSION\t, no defaults" + echo -e "-n SNAPSHOT\t, defaults to false" + echo -e "-m CLUSTER_NAME\t, defaults to docker-cluster" + echo "--------------------------------------------------------------------------" +} + +while getopts ":h:b:p:s:c:v:n:t:m:u:" arg; do + case $arg in + h) + usage + exit 1 + ;; + b) + BIND_ADDRESS=$OPTARG + ;; + p) + BIND_PORT=$OPTARG + ;; + t) + TRANSPORT_PORT=$OPTARG + ;; + s) + SECURITY_ENABLED=$OPTARG + ;; + c) + CREDENTIAL=$OPTARG + ;; + m) + CLUSTER_NAME=$OPTARG + ;; + v) + # Do nothing as we're not consuming this param. + ;; + n) + # Do nothing as we're not consuming this param. + ;; + u) + COMMON_UTILS_VERSION=$OPTARG + ;; + :) + echo "-${OPTARG} requires an argument" + usage + exit 1 + ;; + ?) + echo "Invalid option: -${OPTARG}" + exit 1 + ;; + esac +done + + +if [ -z "$BIND_ADDRESS" ] +then + BIND_ADDRESS="localhost" +fi + +if [ -z "$BIND_PORT" ] +then + BIND_PORT="9200" +fi + +if [ -z "$SECURITY_ENABLED" ] +then + SECURITY_ENABLED="true" +fi + +if [ -z "$CREDENTIAL" ] +then + CREDENTIAL="admin:admin" +fi + +if [ -z "$CREDENTIAL" ] +then + CREDENTIAL="admin:admin" +fi + +if [ -z "$CLUSTER_NAME" ] +then + CLUSTER_NAME="docker-cluster" +fi + +USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` +PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'` + +./gradlew integTestRemote -Dtests.rest.cluster="$BIND_ADDRESS:$BIND_PORT" -Dtests.cluster="$BIND_ADDRESS:$BIND_PORT" -Dsecurity_enabled=$SECURITY_ENABLED -Dtests.clustername=$CLUSTER_NAME -Dhttps=true -Duser=$USERNAME -Dpassword=$PASSWORD From fd2a3a2f8c3130dfe56d51ed3ec3fe80bbc579ce Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 30 Oct 2024 23:51:47 -0400 Subject: [PATCH 2/5] Update default credential logic Signed-off-by: Craig Perkins --- scripts/integtest.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/integtest.sh b/scripts/integtest.sh index 98ee40fbd6..15b446ff24 100644 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -89,9 +89,16 @@ then CREDENTIAL="admin:admin" fi +OPENSEARCH_REQUIRED_VERSION="2.12.0" if [ -z "$CREDENTIAL" ] then - CREDENTIAL="admin:admin" + # 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 if [ -z "$CLUSTER_NAME" ] From c804b42a7f746be4e311dec37ae647bc1504aa7d Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 30 Oct 2024 23:59:40 -0400 Subject: [PATCH 3/5] chmod 755 Signed-off-by: Craig Perkins --- scripts/integtest.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/integtest.sh diff --git a/scripts/integtest.sh b/scripts/integtest.sh old mode 100644 new mode 100755 From 3302ed0a8bc7fcfebcc2025d418e76088ff5e9a0 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 31 Oct 2024 00:04:52 -0400 Subject: [PATCH 4/5] Set OPENSEARCH_VERSION Signed-off-by: Craig Perkins --- scripts/integtest.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/integtest.sh b/scripts/integtest.sh index 15b446ff24..4bdac1544b 100755 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -48,7 +48,7 @@ while getopts ":h:b:p:s:c:v:n:t:m:u:" arg; do CLUSTER_NAME=$OPTARG ;; v) - # Do nothing as we're not consuming this param. + OPENSEARCH_VERSION=$OPTARG ;; n) # Do nothing as we're not consuming this param. @@ -84,11 +84,6 @@ then SECURITY_ENABLED="true" fi -if [ -z "$CREDENTIAL" ] -then - CREDENTIAL="admin:admin" -fi - OPENSEARCH_REQUIRED_VERSION="2.12.0" if [ -z "$CREDENTIAL" ] then From 26159eb533d461a53c6b5b51838052878b548803 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 31 Oct 2024 09:55:46 -0400 Subject: [PATCH 5/5] Add maxHeapSize back in Signed-off-by: Craig Perkins --- build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.gradle b/build.gradle index b56c518937..83e038662c 100644 --- a/build.gradle +++ b/build.gradle @@ -569,6 +569,11 @@ task integrationTest(type: Test) { } } +tasks.named("integrationTest") { + minHeapSize = "512m" + maxHeapSize = "2g" +} + tasks.integrationTest.finalizedBy(jacocoTestReport) // report is always generated after integration tests run //run the integrationTest task before the check task