/
common_functions.sh
executable file
·217 lines (185 loc) · 5.53 KB
/
common_functions.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Supported JVMs
supported_jvms="hotspot openj9"
# Supported distros
# Distros Not Included: windowsservercore-ltsc2016
supported_os="ubuntu ubi"
# Supported packges
supported_packages="jdk jre"
# Supported builds
supported_builds="full"
# Supported tests
supported_tests="external_custom camel criu-functional criu-portable-checkpoint criu-portable-restore criu-ubi-portable-checkpoint criu-ubi-portable-restore derby elasticsearch jacoco jenkins functional-test kafka lucene-solr openliberty-mp-tck payara-mp-tck quarkus quarkus_quickstarts scala system-test tomcat tomee wildfly wycheproof netty spring zookeeper"
function check_os() {
os=$1
for current_os in ${supported_os}
do
if [[ "${os}" == "${current_os}" ]]; then
return 1
fi
done
return 0
}
# Set a valid os
function set_os() {
os=$1
if (check_os ${os}); then
echo "ERROR: Invalid OS: ${os}"
echo "Usage: $0 [${supported_os}]"
exit 1
fi
}
function check_test() {
test=$1
for current_test in ${supported_tests}
do
if [[ "${test}" == "${current_test}" ]]; then
return 1
fi
done
return 0
}
# Set a valid test
function set_test() {
test=$1
if (check_test ${test}); then
echo "ERROR: Invalid Test: ${test}"
echo "Usage: $0 [${supported_tests}]"
exit 1
fi
}
function check_vm() {
vm=$1
for current_vm in ${supported_jvms}
do
if [[ "${vm}" == "${current_vm}" ]]; then
return 1
fi
done
return 0
}
# Set a valid vm
function set_vm() {
vm=$1
if (check_vm ${vm}); then
echo "ERROR: Invalid VM: ${vm}"
echo "Usage: $0 [${supported_jvms}]"
exit 1
fi
}
function check_package() {
package=$1
for current_package in ${supported_packages}
do
if [[ "${package}" == "${current_package}" ]]; then
return 1
fi
done
return 0
}
# Set a valid package
function set_package() {
package=$1
if (check_package ${package}); then
echo "ERROR: Invalid Package: ${package}"
echo "Usage: $0 [${supported_packages}]"
exit 1
fi
}
function check_build() {
build=$1
for current_build in ${supported_builds}
do
if [[ "${build}" == "${current_build}" ]]; then
return 1
fi
done
return 0
}
# Set a valid build
function set_build() {
build=$1
if (check_build ${build}); then
echo "ERROR: Invalid Build: ${build}"
echo "Usage: $0 [${supported_builds}]"
exit 1
fi
}
# Set a platform
function set_platform() {
# TO-DO: Add supported_platforms when portable tests support more platforms
platform=$1
}
# Set base_docker_registry_url
function set_base_docker_registry_url() {
base_docker_registry_url="$1"
}
# Set base_docker_registry_dir
function set_base_docker_registry_dir() {
base_docker_registry_dir="$1"
}
# Reading properties of test.properties file
function getProperty() {
PROP_KEY=$1
PROP_VALUE=`cat $PROPERTY_FILE | grep "$PROP_KEY" | cut -d'=' -f 2-`
echo `sed -e 's/^"//' -e 's/"$//' <<<"$PROP_VALUE"`
}
# Used for external_custom tests
function set_external_custom_test_info(){
test=$1
check_external_custom_test=$2
github_url="${EXTERNAL_CUSTOM_REPO}"
test_command="${EXTERNAL_TEST_CMD}"
test_results="testResults"
tag_version="${EXTERNAL_REPO_BRANCH}"
environment_variable="MODE=java"
ubuntu_packages="git"
maven_version="3.8.5"
}
# Set the valid OSes for the current architectures.
function set_test_info() {
test=$1
check_external_custom_test=$2
cd ../
path_to_file=$(pwd)
echo ${path_to_file}
PROPERTY_FILE=${path_to_file}/${test}/test.properties
github_url=$(getProperty "github_url")
test_options=$(getProperty "test_options")
test_results=$(getProperty "test_results")
ant_version=$(getProperty "ant_version")
ant_contrib_version=$(getProperty "ant_contrib_version")
ivy_version=$(getProperty "ivy_version")
jdk_install=$(getProperty "jdk_install")
tag_version=$(getProperty "tag_version")
gradle_version=$(getProperty "gradle_version")
sbt_version=$(getProperty "sbt_version")
bazel_version=$(getProperty "bazel_version")
openssl_version=$(getProperty "openssl_version")
python_version=$(getProperty "python_version")
criu_version=$(getProperty "criu_version")
maven_version=$(getProperty "maven_version")
environment_variable=$(getProperty "environment_variable")
localPropertyFile=$(getProperty "localPropertyFile")
ubuntu_packages=$(getProperty "ubuntu_packages")
ubi_packages=$(getProperty "ubi_packages")
}
function cleanup_images() {
# Delete any old containers that have exited.
docker rm $(docker ps -a | grep "Exited" | awk '{ print $1 }') 2>/dev/null
# Delete any old images for our target_repo on localhost.
docker rmi -f $(docker images | grep -e "adoptopenjdk" | awk '{ print $3 }' | sort | uniq) 2>/dev/null
}