-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-go-rpa-tests.sh
executable file
·255 lines (242 loc) · 12.9 KB
/
run-go-rpa-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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
TIMESTAMP=$(date)
clear
if [ "$1" == "Stop-Containers-And-Build-Docker-Container-With-Compose" ]; then
echo
echo "------------------------------------[[[[ Stop-Containers-And-Build-Docker-Container-With-Compose ]]]]------------------------------------"
echo
echo "This will build the Docker image defined in the docker-compose.yml file. This run started on $TIMESTAMP."
echo
echo "Use this command to get Docker container IP addresses..."
echo "docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' name-of-the-docker-container"
echo
echo "If you start running out of disk space, consider running this docker command. WARNING: Only use this command if you understand the risk..."
echo "docker system prune -a"
echo
rm -rf ./resources/api-application.log
rm -rf ./resources/go-test-output.json
rm -rf ./resources/httpstat-*
rm -rf ./resources/toxiproxy.log
rm -rf ./resources/*test.dat
rm -rf ./resources/GraphwalkerPath.csv
rm -rf ./resources/__pycache__
rm -rf ./results/*.*
rm -rf ./1
rm -rf ./*.bin
docker stop $(docker ps -a -q) &&
docker rm $(docker ps -a -q)
docker compose -f docker-compose.yml down
docker compose -f docker-compose.yml rm -f
docker compose -f docker-compose.yml build
TIMESTAMP2=$(date)
echo "This build ended on $TIMESTAMP2."
fi
if [ "$1" == "Run-Specific-Tests-Inside-Docker" ]; then
echo
echo "------------------------------------[[[[ Run-Specific-Tests-Inside-Docker ]]]]------------------------------------"
echo
echo "This Run-Specific-Tests-Inside-Docker script is running. This run started on $TIMESTAMP."
echo
echo
docker-compose -f docker-compose.yml down
docker-compose -f docker-compose.yml rm -f
docker-compose -f docker-compose.yml build
docker-compose run docker-test-runner run-go-rpa-tests.sh "$2" "$3"
## Un-comment the line below to manually explore or debug any tests in the Go Language files or the API mock/proxy tools. Please comment out the line above if you need to only run the tesing and debugging script below.
#docker-compose run docker-test-runner run-go-rpa-tests.sh Manual-Scripted-Tests-In-Docker
docker stop $(docker ps -a -q) &&
docker rm $(docker ps -a -q)
docker compose -f docker-compose.yml down
docker compose -f docker-compose.yml rm -f
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
if [ "$1" == "Start-Chaos-Proxy-Model-Based-Tests" ]; then
echo
echo "------------------------------------[[[[ Start-Chaos-Proxy-Model-Based-Tests ]]]]------------------------------------"
echo
echo "This Start-Chaos-Proxy-Model-Based-Tests script is running inside a Docker container. This run started on $TIMESTAMP."
echo
cd /tests
robot --include Tests_Setup --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log test-setup-log.html --output test-setup-output.xml -d ./results ./generic-automation.robot
sleep 3
ls -la
go version
go get
sleep 3
robot --include Model-Based_Tests --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log chaos-proxy-model-based-tests-log.html --output chaos-proxy-model-based-tests-output.xml -d ./results ./generic-automation.robot
rm -rf ./*.bin
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
if [ "$1" == "Start-Chaos-Proxy-Load-Tests" ]; then
echo
echo "------------------------------------[[[[ Start-Chaos-Proxy-Load-Tests ]]]]------------------------------------"
echo
echo "This Start-Chaos-Proxy-Load-Tests script is running inside a Docker container. This run started on $TIMESTAMP."
echo
rm -rf ./*.bin
cd /tests
robot --include Tests_Setup --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log test-setup-log.html --output test-setup-output.xml -d ./results ./generic-automation.robot
sleep 3
ls -la
go version
go get
sleep 3
robot --include Load_Tests --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log chaos-proxy-load-tests-log.html --output chaos-proxy-load-tests-output.xml -d ./results ./generic-automation.robot
rm -rf ./*.bin
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
if [ "$1" == "Start-Go-Language-Functional-Tests" ]; then
echo
echo "------------------------------------[[[[ Start-Go-Language-Functional-Tests ]]]]------------------------------------"
echo
echo "This Start-Go-Language-Functional-Tests script is running inside a Docker container. This run started on $TIMESTAMP."
echo
rm -rf ./resources/go-test-output.json
rm -rf ./resources/go-test-console-results.log
cd /tests
robot --include Tests_Setup --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log test-setup-log.html --output test-setup-output.xml -d ./results ./generic-automation.robot
sleep 3
ls -la
go version
go get
go test -v -json functional-tests_test.go > /tests/resources/go-test-output.json
sleep 3
cat ./resources/go-test-output.json | jq | grep ": Test" > /tests/resources/go-test-console-results.log
cat /tests/resources/go-test-console-results.log
cp /tests/resources/go-test-console-results.log /tests/results/go-test-console-results.log
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
if [ "$1" == "Analyze-Functional-Tests-Generate-HTML-Logs" ]; then
echo
echo "------------------------------------[[[[ Analyze-Functional-Tests-Generate-HTML-Logs ]]]]------------------------------------"
echo
echo "This Analyze-Functional-Tests-Generate-HTML-Logs script is running inside a Docker container. This run started on $TIMESTAMP."
echo
cd /tests
ls -la
robot --include Functional_Tests_Analysis --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log go-test-api-functional-test-log.html --output go-test-api-functional-test-output.xml -d ./results ./generic-automation.robot
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
if [ "$1" == "Start-All-Tests" ]; then
echo
echo "------------------------------------[[[[ Start-All-Tests ]]]]------------------------------------"
echo
echo "This Start-All-Tests script is running inside a Docker container. This run started on $TIMESTAMP."
echo
rm -rf ./*.bin
cd /tests
robot --include Tests_Setup --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log test-setup-log.html --output test-setup-output.xml -d ./results ./generic-automation.robot
sleep 3
ls -la
go version
go get
sleep 3
robot --include Run_All_Tests --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log combined-test-results-log.html --output combined-test-results-output.xml -d ./results ./generic-automation.robot
rm -rf ./*.bin
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
if [ "$1" == "Start-With-Test-ID-Or-Jira-ID" ]; then
echo
echo "------------------------------------[[[[ Start-With-Test-ID-Or-Jira-ID ]]]]------------------------------------"
echo
echo "This Start-With-Test-ID-Or-Jira-ID "$2" script is running inside a Docker container. This run started on $TIMESTAMP."
echo
rm -rf ./*.bin
cd /tests
robot --include Tests_Setup --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log test-setup-log.html --output test-setup-output.xml -d ./results ./generic-automation.robot
sleep 3
ls -la
go version
go get
sleep 3
robot --include "$2" --listener ./resources/DurationTrackingListener.py --doc "CI_PIPELINE_URL : https://github.com/jg8481/go-language-rpa-tests/actions" --report NONE --log specific-test-results-"$2"-log.html --output specific-test-results-"$2"-output.xml -d ./results ./generic-automation.robot
rm -rf ./*.bin
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
if [ "$1" == "Manual-Scripted-Tests-In-Docker" ]; then
echo
echo "------------------------------------[[[[ Manual-Scripted-Tests-In-Docker ]]]]------------------------------------"
echo
echo "This Manual-Scripted-Tests-In-Docker script is running inside a Docker container. This run started on $TIMESTAMP."
echo
rm -rf /tests/resources/api-application.log
curl -L https://raw.githack.com/stoplightio/prism/master/install | sh
prism -h
nohup prism mock -h 0.0.0.0 /tests/petstore.oas3.yaml > /tests/resources/api-application.log &
sleep 3
toxiproxy-server > /tests/resources/toxiproxy.log 2>1 &
toxiproxy-cli create exploratory-testing-proxy -l 127.0.0.1:8080 -u 0.0.0.0:4010 >> /tests/resources/toxiproxy.log 2>1 &
toxiproxy-cli toxic add -t bandwidth -a rate=100 exploratory-testing-proxy >> /tests/resources/toxiproxy.log 2>1 &
# toxiproxy-cli toxic add -t slow_close -a delay=1000 exploratory-testing-proxy >> /tests/resources/toxiproxy.log 2>1 &
# toxiproxy-cli toxic add -t reset_peer -a timeout=1000000 exploratory-testing-proxy >> /tests/resources/toxiproxy.log 2>1 &
sleep 3
cd /tests
ls -la
echo '{"id": 1, "username": "user1", "firstName": "John", "lastName": "Doe", "email": "[email protected]", "password": "123456", "phone": "1234567890", "userStatus": 1}' | radamsa > /tests/resources/radamsa-exploratory-fuzz-test.dat
go version
go get
go run httpstat-test-runner.go -url http://0.0.0.0:4010/user/vitae -method GET
# go run httpstat-test-runner.go -url http://0.0.0.0:4010/store/order -method POST -body '{"id": 10, "petId": 1, "quantity": 1, "shipDate": "2023-01-01T23:59:59.999Z", "status": "placed", "complete": true}' > /tests/resources/httpstat-exploratory-test-output.log
# go run vegeta-load-test-runner.go -url http://0.0.0.0:8080/user/vitae
# curl http://0.0.0.0:4010/user/!@#$
# curl http://0.0.0.0:4010/user/vitae
# curl -vv -X GET http://0.0.0.0:4010/no_auth/pets/findByStatus?status=available
# curl -vv -X GET http://0.0.0.0:4010/pets
# curl -vv -X GET http://0.0.0.0:4010/store/order/9
# httpstat -o ./resources/httpstat-response-output.json http://0.0.0.0:8080/user/vitae
# httpstat -o ./resources/httpstat-temporary-response-body-output.log http://0.0.0.0:4010/user/vitae
# httpstat -o ./resources/httpstat-temporary-response-body-output.log -X POST -H "Content-Type: application/json" -d @resources/test-data2.json http://0.0.0.0:4010/user
# httpstat -o ./resources/httpstat-response-output.json -X POST -H Content-Type: application/json -d @resources/test-data1.json http://0.0.0.0:4010/store/order
# httpstat -o ./resources/httpstat-response-output.json -X POST -H 'Content-Type: application/json' -d @resources/test-data2.json http://0.0.0.0:4010/user
# httpstat -o ./resources/httpstat-response-output.json http://0.0.0.0:4010/user/vitae
TIMESTAMP2=$(date)
echo "This test run ended on $TIMESTAMP2."
fi
usage_explanation() {
echo
echo
echo "------------------------------------[[[[ Tool Runner Script ]]]]------------------------------------"
echo
echo
echo "This tool runner script REQUIRES BOTH DOCKER AND DOCKER-COMPOSE to be installed on your machine, and can be used to run the following commands."
echo
echo "You can view just this help menu again (without triggering any automation) by running 'bash ./run-go-rpa-tests.sh -h' or 'bash ./run-go-rpa-tests.sh --help'."
echo
echo "Installation instructions for Docker can be found here... https://docs.docker.com/"
echo
echo "bash ./run-go-rpa-tests.sh Stop-Containers-And-Build-Docker-Container-With-Compose"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Start-Go-Language-Functional-Tests"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Start-Chaos-Proxy-Model-Based-Tests"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Start-Chaos-Proxy-Load-Tests"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Analyze-Functional-Tests-Generate-HTML-Logs"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Start-All-Tests"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Start-With-Test-ID-Or-Jira-ID Test_ID3"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Start-With-Test-ID-Or-Jira-ID Jira_ID2"
echo "bash ./run-go-rpa-tests.sh Run-Specific-Tests-Inside-Docker Manual-Scripted-Tests-In-Docker"
echo
echo
}
error_handler() {
local error_message="$@"
echo "${error_message}" 1>&2;
}
argument="$1"
if [[ -z $argument ]] ; then
usage_explanation
else
case $argument in
-h|--help)
usage_explanation
;;
*)
usage_explanation
;;
esac
fi