Skip to content

Commit 4df8ed7

Browse files
authored
Create custom integ test file for sql plugin. (#1330)
Sql Plugin integ tests require add files to keystore to add prometheus datasource. So adding a custom integ script which can be consumed by build repo while triggering integ tests during every release. Signed-off-by: Vamsi Manohar <[email protected]>
1 parent 4b3cdbb commit 4df8ed7

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

scripts/integtest.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash
2+
3+
# Copyright OpenSearch Contributors
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# The OpenSearch Contributors require contributions made to
7+
# this file be licensed under the Apache-2.0 license or a
8+
# compatible open source license.
9+
10+
11+
set -e
12+
13+
function usage() {
14+
echo ""
15+
echo "This script is used to run integration tests for plugin installed on a remote OpenSearch/Dashboards cluster."
16+
echo "--------------------------------------------------------------------------"
17+
echo "Usage: $0 [args]"
18+
echo ""
19+
echo "Required arguments:"
20+
echo "None"
21+
echo ""
22+
echo "Optional arguments:"
23+
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."
24+
echo -e "-p BIND_PORT\t, defaults to 9200 or 5601 depends on OpenSearch or Dashboards, can be changed to any port for the cluster location."
25+
echo -e "-s SECURITY_ENABLED\t(true | false), defaults to true. Specify the OpenSearch/Dashboards have security enabled or not."
26+
echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true."
27+
echo -e "-v OPENSEARCH_VERSION\t, no defaults"
28+
echo -e "-n SNAPSHOT\t, defaults to false"
29+
echo -e "-h\tPrint this message."
30+
echo "--------------------------------------------------------------------------"
31+
}
32+
33+
while getopts ":hb:p:s:c:v:n:" arg; do
34+
case $arg in
35+
h)
36+
usage
37+
exit 1
38+
;;
39+
b)
40+
BIND_ADDRESS=$OPTARG
41+
;;
42+
p)
43+
BIND_PORT=$OPTARG
44+
;;
45+
s)
46+
SECURITY_ENABLED=$OPTARG
47+
;;
48+
c)
49+
CREDENTIAL=$OPTARG
50+
;;
51+
v)
52+
OPENSEARCH_VERSION=$OPTARG
53+
;;
54+
n)
55+
SNAPSHOT=$OPTARG
56+
;;
57+
:)
58+
echo "-${OPTARG} requires an argument"
59+
usage
60+
exit 1
61+
;;
62+
?)
63+
echo "Invalid option: -${OPTARG}"
64+
exit 1
65+
;;
66+
esac
67+
done
68+
69+
70+
if [ -z "$BIND_ADDRESS" ]
71+
then
72+
BIND_ADDRESS="localhost"
73+
fi
74+
75+
if [ -z "$BIND_PORT" ]
76+
then
77+
BIND_PORT="9200"
78+
fi
79+
80+
if [ -z "$SECURITY_ENABLED" ]
81+
then
82+
SECURITY_ENABLED="true"
83+
fi
84+
85+
if [ -z "$SNAPSHOT" ]
86+
then
87+
SNAPSHOT="false"
88+
fi
89+
90+
if [ -z "$CREDENTIAL" ]
91+
then
92+
CREDENTIAL="admin:admin"
93+
fi
94+
95+
USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'`
96+
PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'`
97+
98+
OPENSEARCH_HOME=`ps -ef | grep -o "[o]pensearch.path.home=\S\+" | cut -d= -f2- | head -n1`
99+
100+
curl -SL https://raw.githubusercontent.com/opensearch-project/sql/main/integ-test/src/test/resources/datasource/datasources.json -o "$OPENSEARCH_HOME"/datasources.json
101+
102+
yes | $OPENSEARCH_HOME/bin/opensearch-keystore add-file plugins.query.federation.datasources.config $OPENSEARCH_HOME/datasources.json
103+
104+
if [ $SECURITY_ENABLED == "true" ]
105+
then
106+
curl -k --request POST --url https://$BIND_ADDRESS:$BIND_PORT/_nodes/reload_secure_settings --header 'content-type: application/json' --data '{"secure_settings_password":""}' --user $CREDENTIAL
107+
else
108+
curl --request POST --url http://$BIND_ADDRESS:$BIND_PORT/_nodes/reload_secure_settings --header 'content-type: application/json' --data '{"secure_settings_password":""}'
109+
fi
110+
111+
112+
./gradlew integTest -Dopensearch.version=$OPENSEARCH_VERSION -Dbuild.snapshot=$SNAPSHOT -Dtests.rest.cluster="$BIND_ADDRESS:$BIND_PORT" -Dtests.cluster="$BIND_ADDRESS:$BIND_PORT" -Dtests.clustername="opensearch-integrationtest" -Dhttps=$SECURITY_ENABLED -Duser=$USERNAME -Dpassword=$PASSWORD --console=plain

0 commit comments

Comments
 (0)