-
Notifications
You must be signed in to change notification settings - Fork 115
/
integtest.sh
executable file
·144 lines (125 loc) · 4.54 KB
/
integtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
set -e
. ./browser_downloader.sh
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 "-t TEST_COMPONENTS\t(OpenSearch-Dashboards reportsDashboards etc.), optional, specify test components, separate with space, else test everything."
echo -e "-v VERSION\t, no defaults, indicates the OpenSearch version to test."
echo -e "-o OPTION\t, no defaults, determine the TEST_TYPE value among(default, manifest) in test_finder.sh, optional."
echo -e "-r REMOTE_CYPRESS_ENABLED\t(true | false), defaults to true. Feature flag set to specify remote cypress orchestrator runs are enabled or not."
echo -e "-h\tPrint this message."
echo "--------------------------------------------------------------------------"
}
while getopts ":hb:p:s:c:t:v:o:r:" arg; do
case $arg in
h)
usage
exit 1
;;
b)
BIND_ADDRESS=$OPTARG
;;
p)
BIND_PORT=$OPTARG
;;
s)
SECURITY_ENABLED=$OPTARG
;;
c)
CREDENTIAL=$OPTARG
;;
t)
TEST_COMPONENTS=$OPTARG
;;
v)
VERSION=$OPTARG
;;
o)
OPTION=$OPTARG
;;
r)
REMOTE_CYPRESS_ENABLED=$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="5601"
fi
if [ -z "$SECURITY_ENABLED" ]
then
SECURITY_ENABLED="true"
fi
if [ -z "$REMOTE_CYPRESS_ENABLED" ]
then
REMOTE_CYPRESS_ENABLED="true"
fi
if [ -z "$CREDENTIAL" ]
then
# Starting in 2.12.0, security demo configuration script requires an initial admin password
CREDENTIAL="admin:myStrongPassword123!"
fi
USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'`
PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'`
# User can send custom browser path through env variable
if [ -z "$BROWSER_PATH" ]
then
# chromium@1108766 is version 112 with revision r1108766
# Please keep this version until cypress upgrade or test will freeze: https://github.com/opensearch-project/opensearch-build/issues/4241
BROWSER_PATH=`download_chromium | head -n 1 | cut -d ' ' -f1`
fi
. ./test_finder.sh
npm install
TEST_FILES=`get_test_list $TEST_COMPONENTS`
echo -e "Test Files List:"
echo $TEST_FILES | tr ',' '\n'
echo "BROWSER_PATH: $BROWSER_PATH"
## WARNING: THIS LOGIC NEEDS TO BE THE LAST IN THIS FILE! ##
# Cypress returns back the test failure count in the error code
# The CI outputs the error code as test failure count.
#
# We need to ensure the cypress tests are the last execute process to
# the error code gets passed to the CI.
if [ "$DISABLE_VIDEO" = "true" ]; then
echo "Disable video recording when running tests in Cypress"
jq '. + {"video": false}' cypress.json > cypress_new.json # jq does not allow reading and writing on same file
mv -v cypress_new.json cypress.json
fi
# Windows does not set timezone even when you specify `env TZ=America/Los_Angeles`
# Using powershell to force the timezone change to PST which is same as America/Los_Angeles
if [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "win32" ]; then
powershell -Command "Set-TimeZone -Id 'Pacific Standard Time' -PassThru"
fi
if [ "$SECURITY_ENABLED" = "true" ]
then
echo "run security enabled tests"
yarn cypress:run-with-security --browser "$BROWSER_PATH" --spec "$TEST_FILES"
else
echo "run security disabled tests"
yarn cypress:run-without-security --browser "$BROWSER_PATH" --spec "$TEST_FILES"
fi