forked from igorolhovskiy/volts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·644 lines (570 loc) · 19.9 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·644 lines (570 loc) · 19.9 KB
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
#!/bin/bash
# Main user controlled variables
# Report type to provide
REPORT_TYPE='table_full'
# Log level on console
LOG_LEVEL=0
# Timezone
TIMEZONE=$(readlink /etc/localtime | sed 's|.*/zoneinfo/||')
# Maximum time single test is allowed to run in seconds. (10 min)
MAX_SINGLE_TEST_TIME=600
# Docker registry to pull images from
REGISTRY="ihorolkhovskyi"
# TLS-WSS proxy port parameters, change them only if you know what you are doing
OPENSIPS_TLS_PORT=6051
OPENSIPS_WSS_PORT=9443
# HEP Source port
OPENSIPS_HEPS_PORT=8887
# HEP Destination port
OPENSIPS_HEPD_PORT=8888
print_running_char() {
case "${rc}" in
"-"|".-")
rc="\\"
;;
"\\")
rc="|"
;;
"|")
rc="/"
;;
"/")
rc=".-"
;;
esac
echo -en "\b \b${rc}"
}
wait_background_container() {
# Declare counter(i), process_counter(pc) and running_character(rc)
i=0
pc=`docker ps | grep ${1} | wc -l`
rc='-'
echo -n "Running ${CURRENT_SCENARIO} ${2} ${rc}"
TIME_TEST_START=`date +%s`
ERROR_STRING=""
MAX_CYCLES=$(( ${MAX_SINGLE_TEST_TIME} * 2 ))
# Limit with maximum time
while [ $i -le ${MAX_CYCLES} ] && [ $pc -ge 1 ]; do
((i++))
sleep 0.5
pc=`docker ps | grep ${1} | wc -l`
print_running_char
done
if [ $pc -ge 1 ]; then
docker stop ${1} >> /dev/null
ERROR_STRING="\n[WARNING] Container ${1} was forcefully stopped"
fi
TIME_TEST_END=`date +%s`
echo -e "\b\b \b\b. Done in $((${TIME_TEST_END} - ${TIME_TEST_START}))s${ERROR_STRING}"
}
control_opensips() {
if [ "${1}" = "start" ]; then
echo "Websocket proxy starting... "
docker run --name=${PROXY_CONTAINER_NAME} \
--env OPENSIPS_TLS_PORT=`echo ${OPENSIPS_TLS_PORT}` \
--env OPENSIPS_WSS_PORT=`echo ${OPENSIPS_WSS_PORT}` \
--env OPENSIPS_HEPS_PORT=`echo ${OPENSIPS_HEPS_PORT}` \
--env OPENSIPS_HEPD_PORT=`echo ${OPENSIPS_HEPD_PORT}` \
--env VP_TLS_PORT=`echo $[${VP_PORT} + 1]` \
--net=host \
--rm \
--platform linux/amd64 \
-d \
${PROXY_IMAGE} >> /dev/null
# Give a time to start the container and push it a bit
sleep 1
cleanup_opensips_cache
else
echo "Websocket proxy stopping..."
docker stop ${PROXY_CONTAINER_NAME} >> /dev/null 2>&1
fi
}
run_voip_patrol() {
if [ ! -f "${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/voip_patrol.xml" ]; then
return
fi
BG_RUN=""
OUT_REDIRECT=""
if [ ${LOG_LEVEL} -eq 0 ]; then
BG_RUN="-d"
OUT_REDIRECT=">> /dev/null"
fi
docker rm ${VP_CONTAINER_NAME} >> /dev/null 2>&1
eval docker run --name=${VP_CONTAINER_NAME} \
--env XML_CONF=`echo ${CURRENT_SCENARIO}` \
--env PORT=`echo ${VP_PORT}` \
--env RESULT_FILE=`echo ${VP_RESULT_FILE}` \
--env LOG_LEVEL=`echo ${LOG_LEVEL}` \
--env LOG_LEVEL_FILE=`echo ${LOG_LEVEL_FILE}` \
--env TZ=`echo ${TIMEZONE}` \
--volume ${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/voip_patrol.xml:/xml/${CURRENT_SCENARIO}.xml${VOLUME_SUFFIX} \
--volume ${DIR_PREFIX}/tmp/output:/output${VOLUME_SUFFIX} \
--volume ${DIR_PREFIX}/voice_ref_files:/voice_ref_files${VOLUME_SUFFIX} \
--net=host \
--rm \
--platform linux/amd64 \
${BG_RUN} \
${VP_IMAGE} ${OUT_REDIRECT}
if [ ${LOG_LEVEL} -eq 0 ]; then
wait_background_container ${VP_CONTAINER_NAME} voip_patrol
fi
}
run_prepare() {
# Join scenarios array with commas for prepare container
local SCENARIO_LIST=""
if [ ${#SCENARIOS[@]} -gt 0 ]; then
SCENARIO_LIST=$(IFS=,; echo "${SCENARIOS[*]}")
fi
docker run --name=${P_CONTAINER_NAME} \
--env SCENARIO_NAME=`echo ${SCENARIO_LIST}` \
--env OPENSIPS_TLS_PORT=`echo ${OPENSIPS_TLS_PORT}` \
--env LOG_LEVEL=`echo ${LOG_LEVEL}` \
--env TAG=`echo ${PREPARE_TAG}` \
--env TZ=`echo ${TIMEZONE}` \
--volume ${DIR_PREFIX}/scenarios:/opt/input/${VOLUME_SUFFIX} \
--volume ${DIR_PREFIX}/tmp/input:/opt/output${VOLUME_SUFFIX} \
--net=none \
--rm \
--platform linux/amd64 \
${P_IMAGE}
}
run_report() {
docker run --name=${R_CONTAINER_NAME} \
--env VP_RESULT_FILE=`echo ${VP_RESULT_FILE}` \
--env D_RESULT_FILE=`echo ${D_RESULT_FILE}` \
--env M_RESULT_FILE=`echo ${M_RESULT_FILE}` \
--env SIPP_RESULT_FILE=`echo ${SIPP_RESULT_FILE}` \
--env REPORT_TYPE=`echo ${REPORT_TYPE}` \
--env TZ=`echo ${TIMEZONE}` \
--volume ${DIR_PREFIX}/tmp/input:/opt/scenarios/${VOLUME_SUFFIX} \
--volume ${DIR_PREFIX}/tmp/output:/opt/report${VOLUME_SUFFIX} \
--net=none \
--rm \
--platform linux/amd64 \
${R_IMAGE}
}
run_database() {
if [ ! -f "${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/database.xml" ]; then
return
fi
docker run --name=${D_CONTAINER_NAME} \
--env SCENARIO=`echo ${CURRENT_SCENARIO}` \
--env RESULT_FILE=`echo ${D_RESULT_FILE}` \
--env LOG_LEVEL=`echo ${LOG_LEVEL}` \
--env STAGE=`echo ${1}` \
--env TZ=`echo ${TIMEZONE}` \
--env TEST_START_TIME="`echo ${TEST_START_TIME}`" \
--env TEST_END_TIME="`echo ${TEST_END_TIME}`" \
--volume ${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/database.xml:/xml/${CURRENT_SCENARIO}.xml${VOLUME_SUFFIX} \
--volume ${DIR_PREFIX}/tmp/output:/output${VOLUME_SUFFIX} \
--rm \
--platform linux/amd64 \
${D_IMAGE}
}
run_sipp() {
if [ ! -f "${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/sipp.xml" ]; then
return
fi
BG_RUN=""
OUT_REDIRECT=""
if [ ${LOG_LEVEL} -eq 0 ]; then
BG_RUN="-d"
OUT_REDIRECT=">> /dev/null"
fi
eval docker run --name=${SIPP_CONTAINER_NAME} \
--env SCENARIO=`echo ${CURRENT_SCENARIO}` \
--env RESULT_FILE=`echo ${SIPP_RESULT_FILE}` \
--env LOG_LEVEL=`echo ${LOG_LEVEL}` \
--volume ${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/sipp.xml:/xml/${CURRENT_SCENARIO}.xml${VOLUME_SUFFIX} \
--volume ${DIR_PREFIX}/tmp/output:/output${VOLUME_SUFFIX} \
--rm \
--platform linux/amd64 \
${BG_RUN} \
${SIPP_IMAGE} ${OUT_REDIRECT}
if [ ${LOG_LEVEL} -eq 0 ]; then
wait_background_container ${SIPP_CONTAINER_NAME} sipp
fi
}
run_media() {
if [ ! -f "${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/media_check.xml" ]; then
return
fi
docker run --name=${M_CONTAINER_NAME} \
--env SCENARIO=`echo ${CURRENT_SCENARIO}` \
--env RESULT_FILE=`echo ${M_RESULT_FILE}` \
--env LOG_LEVEL=`echo ${LOG_LEVEL}` \
--volume ${DIR_PREFIX}/tmp/input/${CURRENT_SCENARIO}/media_check.xml:/xml/${CURRENT_SCENARIO}.xml${VOLUME_SUFFIX} \
--volume ${DIR_PREFIX}/tmp/output:/output${VOLUME_SUFFIX} \
--net=none \
--rm \
--platform linux/amd64 \
${M_IMAGE}
}
cleanup_opensips_cache() {
docker exec ${PROXY_CONTAINER_NAME} /usr/bin/opensips-cli -x mi cache_remove_chunk "*" >> /dev/null 2>&1
}
check_images() {
missing=""
for comp in $COMPONENTS; do
if ! docker image inspect "${IMAGE_PREFIX}volts_$comp:latest" > /dev/null 2>&1; then
missing="$missing $comp"
fi
done
[ -z "$missing" ] && return 0
echo "Missing local images:$missing"
echo "Attempting to pull from registry..."
failed=""
for comp in $missing; do
echo -n " Pulling $comp... "
if docker pull "$REGISTRY/$comp" > /dev/null 2>&1; then
docker tag "$REGISTRY/$comp" "${IMAGE_PREFIX}volts_$comp:latest"
echo "OK"
else
failed="$failed $comp"
echo "FAILED"
fi
done
if [ -n "$failed" ]; then
echo "Could not pull the following images:$failed"
echo "Build them locally with: ./build.sh"
exit 1
fi
}
delete_containers() {
docker stop ${M_CONTAINER_NAME} >> /dev/null 2>&1
docker stop ${SIPP_CONTAINER_NAME} >> /dev/null 2>&1
docker stop ${D_CONTAINER_NAME} >> /dev/null 2>&1
docker stop ${R_CONTAINER_NAME} >> /dev/null 2>&1
docker stop ${P_CONTAINER_NAME} >> /dev/null 2>&1
docker stop ${VP_CONTAINER_NAME} >> /dev/null 2>&1
docker stop ${PROXY_CONTAINER_NAME} >> /dev/null 2>&1
docker rm ${M_CONTAINER_NAME} >> /dev/null 2>&1
docker rm ${SIPP_CONTAINER_NAME} >> /dev/null 2>&1
docker rm ${D_CONTAINER_NAME} >> /dev/null 2>&1
docker rm ${R_CONTAINER_NAME} >> /dev/null 2>&1
docker rm ${P_CONTAINER_NAME} >> /dev/null 2>&1
docker rm ${VP_CONTAINER_NAME} >> /dev/null 2>&1
docker rm ${PROXY_CONTAINER_NAME} >> /dev/null 2>&1
}
run_scenario() {
TEST_START_TIME=$(date '+%Y-%m-%d %H:%M:%S')
run_database pre
run_voip_patrol
run_sipp
TEST_END_TIME=$(date '+%Y-%m-%d %H:%M:%S')
run_database post
run_media
if [ -f ${DIR_PREFIX}/tmp/input/websocket.need ]; then
cleanup_opensips_cache
fi
}
# Help function
show_help() {
cat << EOF
VOLTS (Voip Open Linear Tester Suite) - VoIP Functional Testing Framework
Usage: $0 [OPTIONS] [SCENARIO]
SCENARIO:
<scenario_name>... Run one or more scenarios, space- and/or comma-separated
(e.g., 001-register 002-call-echo or 001-register,002-call-echo)
tag=<tags> Run scenarios with specific tags (e.g., tag=set1,set2)
stop Stop tests and delete all containers
sngrep Launch SIP packet capture tool
dbclean Clean up test data from databases
report-only Skip test execution and only generate report from existing data
OPTIONS:
-h, --help Show this help message
-l, --log-level N Set log level (0=silent, 1=normal, 2=verbose, 3=debug) [default: $LOG_LEVEL]
-r, --report TYPE Set report type (table|json|table_full|json_full) [default: $REPORT_TYPE]
-t, --timeout N Set maximum single test time in seconds [default: $MAX_SINGLE_TEST_TIME]
-v, --verbose Enable verbose output (equivalent to -l 2)
-d, --debug Enable debug output (equivalent to -l 3)
--tls-port N Set OpenSIPS TLS port [default: $OPENSIPS_TLS_PORT]
--wss-port N Set OpenSIPS WSS port [default: $OPENSIPS_WSS_PORT]
--heps-port N Set HEP source port [default: $OPENSIPS_HEPS_PORT]
--hepd-port N Set HEP destination port [default: $OPENSIPS_HEPD_PORT]
EXAMPLES:
$0 Run all scenarios
$0 001-register Run specific scenario
$0 001-register 002-call-echo Run multiple scenarios (space-separated)
$0 001-register,002-call-echo Run multiple scenarios (comma-separated)
$0 scenarios/001-register.xml Run specific scenario with full path
$0 tag=sipp,media Run scenarios tagged as sipp or media
$0 -l 3 001-register Run scenario with debug logging
$0 -r json -v Run all scenarios with JSON output and verbose logging
$0 --timeout 300 001-register Run scenario with 5-minute timeout
$0 stop Stop all containers
$0 sngrep Launch SIP packet capture
$0 dbclean Clean up databases
$0 report-only Re-generate report from previous run
ENVIRONMENT VARIABLES:
REPORT_TYPE Override default report type
LOG_LEVEL Override default log level
MAX_SINGLE_TEST_TIME Override default timeout
EOF
}
# Parse command line arguments
parse_arguments() {
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
exit 0
;;
-l|--log-level)
if [[ -n "$2" && "$2" =~ ^[0-3]$ ]]; then
LOG_LEVEL="$2"
shift 2
else
echo "Error: --log-level requires a number between 0-3" >&2
exit 1
fi
;;
-r|--report)
if [[ -n "$2" && "$2" =~ ^(table|json|table_full|json_full)$ ]]; then
REPORT_TYPE="$2"
shift 2
else
echo "Error: --report must be one of: table, json, table_full, json_full" >&2
exit 1
fi
;;
-t|--timeout)
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
MAX_SINGLE_TEST_TIME="$2"
shift 2
else
echo "Error: --timeout requires a positive number" >&2
exit 1
fi
;;
-v|--verbose)
LOG_LEVEL=2
shift
;;
-d|--debug)
LOG_LEVEL=3
shift
;;
--tls-port)
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
OPENSIPS_TLS_PORT="$2"
shift 2
else
echo "Error: --tls-port requires a valid port number" >&2
exit 1
fi
;;
--wss-port)
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
OPENSIPS_WSS_PORT="$2"
shift 2
else
echo "Error: --wss-port requires a valid port number" >&2
exit 1
fi
;;
--heps-port)
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
OPENSIPS_HEPS_PORT="$2"
shift 2
else
echo "Error: --heps-port requires a valid port number" >&2
exit 1
fi
;;
--hepd-port)
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
OPENSIPS_HEPD_PORT="$2"
shift 2
else
echo "Error: --hepd-port requires a valid port number" >&2
exit 1
fi
;;
stop|sngrep|dbclean|report-only)
# Special commands - must be standalone
if [[ ${#SCENARIOS[@]} -gt 0 ]]; then
echo "Error: Cannot combine '${1}' with scenarios" >&2
exit 1
fi
SCENARIOS=("$1")
shift
;;
tag=*|-tag=*|--tag=*)
# Tag specification - must be standalone
if [[ ${#SCENARIOS[@]} -gt 0 ]]; then
echo "Error: Cannot combine tags with scenarios" >&2
exit 1
fi
SCENARIOS=("$1")
shift
;;
-*)
echo "Error: Unknown option $1" >&2
echo "Use $0 --help for usage information" >&2
exit 1
;;
*)
# Regular scenario name - allow multiple, space- and/or
# comma-separated (e.g. "a b", "a,b,c" or "a, b, c").
IFS=',' read -ra SCENARIO_PARTS <<< "$1"
for part in "${SCENARIO_PARTS[@]}"; do
# Trim surrounding whitespace and skip empty pieces
part="${part#"${part%%[![:space:]]*}"}"
part="${part%"${part##*[![:space:]]}"}"
[[ -n "$part" ]] && SCENARIOS+=("$part")
done
shift
;;
esac
done
}
clean_tmp() {
rm -rf tmp/input/*
rm -rf tmp/input/*
}
# Script controlled variables
DIR_PREFIX=`pwd`
SCENARIOS=()
COMPONENTS="prepare vp report database media sipp opensips"
# Determine if we're running script using podman or docker.
if docker --version 2>/dev/null | grep -qi "podman"; then
VOLUME_SUFFIX=":z"
IMAGE_PREFIX="localhost/"
else
VOLUME_SUFFIX=""
IMAGE_PREFIX=""
fi
# Parse command line arguments
parse_arguments "$@"
mkdir -p tmp/input
mkdir -p tmp/output
# prepare
P_IMAGE=${IMAGE_PREFIX}volts_prepare:latest
P_CONTAINER_NAME=volts_prepare
# database
D_IMAGE=${IMAGE_PREFIX}volts_database:latest
D_CONTAINER_NAME=volts_database
D_RESULT_FILE="database.jsonl"
# voip_patrol
VP_IMAGE=${IMAGE_PREFIX}volts_vp:latest
VP_CONTAINER_NAME=volts_vp
#VP_IMAGE=${IMAGE_PREFIX}voip_patrol_local:latest
#VP_CONTAINER_NAME=voip_patrol_local
VP_PORT=5060
VP_RESULT_FILE="voip_patrol.jsonl"
LOG_LEVEL_FILE=${LOG_LEVEL}
# media
M_IMAGE=${IMAGE_PREFIX}volts_media:latest
M_CONTAINER_NAME=volts_media
M_RESULT_FILE="media_check.jsonl"
# sipp
SIPP_CONTAINER_NAME=volts_sipp
SIPP_IMAGE=${IMAGE_PREFIX}volts_sipp:latest
SIPP_RESULT_FILE="sipp.jsonl"
# opensips
PROXY_CONTAINER_NAME=volts_opensips
PROXY_IMAGE=${IMAGE_PREFIX}volts_opensips:latest
# report
R_IMAGE=${IMAGE_PREFIX}volts_report:latest
R_CONTAINER_NAME=volts_report
# Handle special commands first
if [ ${#SCENARIOS[@]} -eq 1 ]; then
if [ "x${SCENARIOS[0]}" == "xstop" ]; then
echo -n "Stopping and deleting containers..."
delete_containers
echo " Done"
exit 0
fi
if [ "x${SCENARIOS[0]}" == "xsngrep" ]; then
if [ `docker ps | grep -c ${PROXY_CONTAINER_NAME}` == 1 ]; then
echo "Starting sngrep in docker..."
docker exec -it ${PROXY_CONTAINER_NAME} sngrep -L udp:127.0.0.1:${OPENSIPS_HEPD_PORT}
echo "Done"
else
echo "Cannot find ${PROXY_CONTAINER_NAME}. Make sure you have VOLTS running"
fi
exit 0
fi
if [ "x${SCENARIOS[0]}" == "xdbclean" ]; then
echo -n "Cleaning up database(s)"
clean_tmp
SCENARIOS=()
run_prepare
for D in ${DIR_PREFIX}/tmp/input/*; do
CURRENT_SCENARIO=`basename ${D}`
run_database post
echo -n .
done
echo " Done."
exit 0
fi
if [ "x${SCENARIOS[0]}" == "xreport-only" ]; then
echo -n "Running only report"
run_report
VOLTS_EXIT=$?
delete_containers
exit ${VOLTS_EXIT}
fi
fi
# Handle tag specification
if [ ${#SCENARIOS[@]} -eq 1 ]; then
FIRST_SCENARIO="${SCENARIOS[0]}"
if [ "`echo ${FIRST_SCENARIO} | cut -c1-4`" == "tag=" ]; then
PREPARE_TAG=`echo ${FIRST_SCENARIO} | cut -c5-`
SCENARIOS=()
elif [ "`echo ${FIRST_SCENARIO} | cut -c1-5`" == "-tag=" ]; then
PREPARE_TAG=`echo ${FIRST_SCENARIO} | cut -c6-`
SCENARIOS=()
elif [ "`echo ${FIRST_SCENARIO} | cut -c1-6`" == "--tag=" ]; then
PREPARE_TAG=`echo ${FIRST_SCENARIO} | cut -c7-`
SCENARIOS=()
fi
fi
# Process scenario names - extract basename without extension
PROCESSED_SCENARIOS=()
for S in "${SCENARIOS[@]}"; do
PROCESSED_SCENARIOS+=("$(basename ${S} | cut -f 1 -d .)")
done
SCENARIOS=("${PROCESSED_SCENARIOS[@]}")
check_images
clean_tmp
run_prepare
if [ ! -f ${DIR_PREFIX}/tmp/input/scenarios.done ]; then
echo "Scenarios are not prepared, please check for the errors"
exit 1
fi
TIME_TOTAL_START=`date +%s`
rm -f ${DIR_PREFIX}/tmp/output/*
delete_containers
# Start WSS-TLS proxy
if [ -f ${DIR_PREFIX}/tmp/input/websocket.need ]; then
control_opensips start
fi
if [ ${#SCENARIOS[@]} -eq 0 ]; then
# No specific scenarios - run all prepared scenarios
for D in ${DIR_PREFIX}/tmp/input/*; do
CURRENT_SCENARIO=`basename ${D}`
run_scenario
done
else
# Run specified scenarios
for CURRENT_SCENARIO in "${SCENARIOS[@]}"; do
run_scenario
done
fi
# Stop WSS-TLS proxy
if [ -f ${DIR_PREFIX}/tmp/input/websocket.need ]; then
control_opensips stop
fi
run_report
VOLTS_EXIT=$?
delete_containers
TIME_TOTAL_END=`date +%s`
TIME_TOTAL_RUN=$((${TIME_TOTAL_END} - ${TIME_TOTAL_START}))
HMS_TOTAL_RUN=$(printf '%02d:%02d:%02d' \
$(( TIME_TOTAL_RUN / 3600 )) \
$(( (TIME_TOTAL_RUN % 3600) / 60 )) \
$(( TIME_TOTAL_RUN % 60 )))
echo "Total time taken: ${HMS_TOTAL_RUN}"
exit ${VOLTS_EXIT}