forked from MauroDataMapper/mdm-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-all-tests.sh
executable file
·217 lines (194 loc) · 6.5 KB
/
run-all-tests.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
#!/bin/zsh
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-u|--unit-test)
UNIT=true
shift # past argument
;;
-i|--integration-test)
INTEGRATION=true
shift # past argument
;;
-f|--functional-test)
FUNCTIONAL=true
shift # past argument
;;
-e|--e2e-test)
E2E=true
shift # past argument
;;
-r|--build-report)
E2E=true
shift # past argument
;;
-p|--plugin)
PLUGIN="$2"
shift # past argument
shift # past value
;;
-h|--help)
USAGE=true
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
USAGE="${USAGE:-false}"
UNIT="${UNIT:-false}"
INTEGRATION="${INTEGRATION:-false}"
FUNCTIONAL="${FUNCTIONAL:-false}"
E2E="${E2E:-false}"
REPORT="${REPORT:-false}"
if $UNIT || $INTEGRATION || $FUNCTIONAL || $E2E
then
echo 'Restricted testing mode'
else
echo 'Testing everything'
UNIT=true
INTEGRATION=true
FUNCTIONAL=true
E2E=true
fi
function unitTest(){
echo ">> Unit Tests <<"
./gradlew --build-cache test
}
function integrationTest(){
echo ">> Integration Tests <<"
./gradlew --build-cache -Dgradle.integrationTest=true -Dgradle.parallel=true \
:mdm-core:integrationTest \
:mdm-plugin-authentication-apikey:integrationTest \
:mdm-plugin-authentication-basic:integrationTest \
:mdm-plugin-dataflow:integrationTest \
:mdm-plugin-datamodel:integrationTest \
:mdm-plugin-email-proxy:integrationTest \
:mdm-plugin-federation:integrationTest \
:mdm-plugin-profile:integrationTest \
:mdm-plugin-referencedata:integrationTest \
:mdm-plugin-terminology:integrationTest
# :mdm-security:integrationTest
./gradlew --build-cache -Dgradle.integrationTest=true -Dgradle.nonParallel=true \
:mdm-core:integrationTest \
:mdm-plugin-authentication-apikey:integrationTest \
:mdm-plugin-authentication-basic:integrationTest \
:mdm-plugin-dataflow:integrationTest \
:mdm-plugin-datamodel:integrationTest \
:mdm-plugin-email-proxy:integrationTest \
:mdm-plugin-federation:integrationTest \
:mdm-plugin-profile:integrationTest \
:mdm-plugin-referencedata:integrationTest \
:mdm-plugin-terminology:integrationTest \
:mdm-security:integrationTest
}
function functionalTest(){
echo ">> Functional Tests <<"
./gradlew --build-cache -Dgradle.functionalTest=true \
:mdm-core:integrationTest \
:mdm-plugin-authentication-apikey:integrationTest \
:mdm-plugin-authentication-basic:integrationTest \
:mdm-plugin-dataflow:integrationTest \
:mdm-plugin-datamodel:integrationTest \
:mdm-plugin-email-proxy:integrationTest \
:mdm-plugin-federation:integrationTest \
:mdm-plugin-profile:integrationTest \
:mdm-plugin-referencedata:integrationTest \
:mdm-plugin-terminology:integrationTest \
:mdm-security:integrationTest
}
function e2eTest(){
echo ">> E2E Tests <<"
./gradlew --build-cache -Dgradle.test.package=core :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=security :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=authentication :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=datamodel :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=terminology :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=referencedata :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=profile :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=dataflow :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=federation :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=facet :mdm-testing-functional:integrationTest
./gradlew --build-cache -Dgradle.test.package=versionedfolder :mdm-testing-functional:integrationTest
}
function initialReport(){
echo ">> Info <<"
./gradlew -v
pushd mdm-core || exit
./gradlew -v
popd || exit
}
function compile() {
echo ">> Compile <<"
./gradlew --build-cache compile
exit_on_error $?
echo ">> License Check <<"
./gradlew --build-cache license
}
exit_on_error() {
exit_code=$1
last_command=${@:2}
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
}
# enable !! command completion
#set -o history -o histexpand
########################################################################################################
# This executes all the commands Jenkinsfile executes in the same order and format that Jenkins does
# The hope is that we can repeat the tests locally and get the same instability
function usage(){
echo
echo "Usage: ./run-all-tests.sh [OPTIONS]"
echo "
Build and test the mdm-core.
If no options provided then all tests will be run, if options are provided then only the tests stated by the options will be run.
If the tests run then a HTML report will be generated and will automatically open in your default browser.
"
echo "
Options:
-r, --report Output the initial report which details the build environment.
-u, --unit-test Run the unit tests
-i, --integration-test Run the integration tests
-f, --functional-test Run the functional tests
-e, --e2e-test Run the end-to-end tests which are contained inside the MTF module
-h, --help This help
"
}
if $USAGE
then
usage
else
if [ -n "$PLUGIN" ]
then
echo "Testing plugin $PLUGIN only"
./gradlew jenkinsClean
if $UNIT; then ./gradlew --build-cache -Dgradle.integrationTest=true ":${PLUGIN}:test"; fi;
if $INTEGRATION; then ./gradlew --build-cache -Dgradle.integrationTest=true ":${PLUGIN}:integrationTest"; fi;
if $FUNCTIONAL; then ./gradlew --build-cache -Dgradle.functionalTest=true ":${PLUGIN}:integrationTest"; fi;
./gradlew --build-cache rootTestReport
else
if $REPORT; then initialReport; fi;
if $UNIT || $INTEGRATION || $FUNCTIONAL || $E2E
then
./gradlew jenkinsClean
# compile
fi
if $UNIT; then unitTest; fi;
if $INTEGRATION; then integrationTest; fi;
if $FUNCTIONAL; then functionalTest; fi;
if $E2E; then e2eTest; fi;
fi
if $UNIT || $INTEGRATION || $FUNCTIONAL || $E2E
then
echo ">> Root Test Report <<"
./gradlew --build-cache rootTestReport
fi
fi
#./gradlew --build-cache jacocoTestReport
#./gradlew --build-cache staticCodeAnalysis