-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create custom integ test file for sql plugin. #1330
Merged
vamsimanohar
merged 1 commit into
opensearch-project:main
from
vamsimanohar:vamsi-amazon-patch-1
Feb 10, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/bin/bash | ||
|
||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
|
||
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 or 5601 depends on OpenSearch or Dashboards, 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 "-v OPENSEARCH_VERSION\t, no defaults" | ||
echo -e "-n SNAPSHOT\t, defaults to false" | ||
echo -e "-h\tPrint this message." | ||
echo "--------------------------------------------------------------------------" | ||
} | ||
|
||
while getopts ":hb:p:s:c:v:n:" arg; do | ||
case $arg in | ||
h) | ||
usage | ||
exit 1 | ||
;; | ||
b) | ||
BIND_ADDRESS=$OPTARG | ||
;; | ||
p) | ||
BIND_PORT=$OPTARG | ||
;; | ||
s) | ||
SECURITY_ENABLED=$OPTARG | ||
;; | ||
c) | ||
CREDENTIAL=$OPTARG | ||
;; | ||
v) | ||
OPENSEARCH_VERSION=$OPTARG | ||
;; | ||
n) | ||
SNAPSHOT=$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 "$SNAPSHOT" ] | ||
then | ||
SNAPSHOT="false" | ||
fi | ||
|
||
if [ -z "$CREDENTIAL" ] | ||
then | ||
CREDENTIAL="admin:admin" | ||
fi | ||
|
||
USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` | ||
PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'` | ||
|
||
OPENSEARCH_HOME=`ps -ef | grep -o "[o]pensearch.path.home=\S\+" | cut -d= -f2- | head -n1` | ||
|
||
curl -SL https://raw.githubusercontent.com/opensearch-project/sql/main/integ-test/src/test/resources/datasource/datasources.json -o "$OPENSEARCH_HOME"/datasources.json | ||
|
||
yes | $OPENSEARCH_HOME/bin/opensearch-keystore add-file plugins.query.federation.datasources.config $OPENSEARCH_HOME/datasources.json | ||
|
||
if [ $SECURITY_ENABLED == "true" ] | ||
then | ||
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 | ||
else | ||
curl --request POST --url http://$BIND_ADDRESS:$BIND_PORT/_nodes/reload_secure_settings --header 'content-type: application/json' --data '{"secure_settings_password":""}' | ||
fi | ||
|
||
|
||
./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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add option to pass rest of the command line to
gradlew
. It allows you to specify test filter (--tests "..."
) or debug flag-Dtest.debug
and so on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied from https://github.com/opensearch-project/opensearch-build/blob/main/scripts/default/integtest.sh. The intent is to customize the script to include datasource creation.
They always default on parameters. we can expand the functionality whenever we need.