Skip to content

Commit 60ed8c7

Browse files
authored
Add integtest.sh script and remove integTest dependency on integrationTest task (#4866)
Signed-off-by: Craig Perkins <[email protected]>
1 parent 128a304 commit 60ed8c7

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ Run tests against local cluster:
7676
```bash
7777
./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"
7878
```
79+
OR
80+
```bash
81+
./scripts/integtest.sh
82+
```
7983
Note: To run against a remote cluster replace cluster-name and `localhost:9200` with the IPAddress:Port of that cluster.
8084

8185
Build artifacts (zip, deb, rpm):

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ tasks.named("integrationTest") {
574574
maxHeapSize = "2g"
575575
}
576576

577-
tasks.integTest.dependsOn(integrationTest)
578577
tasks.integrationTest.finalizedBy(jacocoTestReport) // report is always generated after integration tests run
579578

580579
//run the integrationTest task before the check task

scripts/integtest.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function usage() {
6+
echo ""
7+
echo "This script is used to run integration tests for plugin installed on a remote OpenSearch/Dashboards cluster."
8+
echo "--------------------------------------------------------------------------"
9+
echo "Usage: $0 [args]"
10+
echo ""
11+
echo "Required arguments:"
12+
echo "None"
13+
echo ""
14+
echo "Optional arguments:"
15+
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."
16+
echo -e "-p BIND_PORT\t, defaults to 9200, can be changed to any port for the cluster location."
17+
echo -e "-s SECURITY_ENABLED\t(true | false), defaults to true. Specify the OpenSearch/Dashboards have security enabled or not."
18+
echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true."
19+
echo -e "-h\tPrint this message."
20+
echo -e "-v OPENSEARCH_VERSION\t, no defaults"
21+
echo -e "-n SNAPSHOT\t, defaults to false"
22+
echo -e "-m CLUSTER_NAME\t, defaults to docker-cluster"
23+
echo "--------------------------------------------------------------------------"
24+
}
25+
26+
while getopts ":h:b:p:s:c:v:n:t:m:u:" arg; do
27+
case $arg in
28+
h)
29+
usage
30+
exit 1
31+
;;
32+
b)
33+
BIND_ADDRESS=$OPTARG
34+
;;
35+
p)
36+
BIND_PORT=$OPTARG
37+
;;
38+
t)
39+
TRANSPORT_PORT=$OPTARG
40+
;;
41+
s)
42+
SECURITY_ENABLED=$OPTARG
43+
;;
44+
c)
45+
CREDENTIAL=$OPTARG
46+
;;
47+
m)
48+
CLUSTER_NAME=$OPTARG
49+
;;
50+
v)
51+
OPENSEARCH_VERSION=$OPTARG
52+
;;
53+
n)
54+
# Do nothing as we're not consuming this param.
55+
;;
56+
u)
57+
COMMON_UTILS_VERSION=$OPTARG
58+
;;
59+
:)
60+
echo "-${OPTARG} requires an argument"
61+
usage
62+
exit 1
63+
;;
64+
?)
65+
echo "Invalid option: -${OPTARG}"
66+
exit 1
67+
;;
68+
esac
69+
done
70+
71+
72+
if [ -z "$BIND_ADDRESS" ]
73+
then
74+
BIND_ADDRESS="localhost"
75+
fi
76+
77+
if [ -z "$BIND_PORT" ]
78+
then
79+
BIND_PORT="9200"
80+
fi
81+
82+
if [ -z "$SECURITY_ENABLED" ]
83+
then
84+
SECURITY_ENABLED="true"
85+
fi
86+
87+
OPENSEARCH_REQUIRED_VERSION="2.12.0"
88+
if [ -z "$CREDENTIAL" ]
89+
then
90+
# Starting in 2.12.0, security demo configuration script requires an initial admin password
91+
COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1`
92+
if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then
93+
CREDENTIAL="admin:admin"
94+
else
95+
CREDENTIAL="admin:myStrongPassword123!"
96+
fi
97+
fi
98+
99+
if [ -z "$CLUSTER_NAME" ]
100+
then
101+
CLUSTER_NAME="docker-cluster"
102+
fi
103+
104+
USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'`
105+
PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'`
106+
107+
./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

0 commit comments

Comments
 (0)