-
Notifications
You must be signed in to change notification settings - Fork 22
/
smoke_test.sh
executable file
·100 lines (89 loc) · 2.64 KB
/
smoke_test.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
#!/bin/bash
#
# Copyright (C) 2024 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
#
RESULT_DIR=./results
# a quick spot test script to smoke testing some of pipeline profiles
#
# setup:
setup() {
echo "Clean existing Docker containers"
make clean-all || true
echo "Build Automated Self Checkout image"
make build
}
teardown() {
make down
make clean-results || true
}
# $1 is the profile name
# $2 is the status code from caller
verifyStatusCode() {
status_code=$1
if [ "$status_code" -eq 0 ]
then
echo "=== Automated Self Checkout smoke test status code PASSED"
else
echo "=== Automated Self Checkout smoke test status code FAILED"
fi
}
# $1 is the profile name
verifyNonEmptyPipelineLog() {
if [ $(ls $RESULT_DIR/pipeline*.log 2> /dev/null | wc -l) -ge 1 ]
then
echo "=== Automated Self Checkout smoke test pipeline log PASSED"
else
echo "=== Automated Self Checkout smoke test pipeline log FAILED"
fi
}
waitForLogFile() {
max_wait_time=300
sleep_increments=10
total_wait_time=0
pipeline_logs=0
echo "Waiting for log file to generate"
while [ $pipeline_logs -le 0 ]
do
pipeline_logs=$(ls $RESULT_DIR/pipeline*.log 2> /dev/null | wc -l)
echo $pipeline_logs
ls $RESULT_DIR/pipeline*.log 2> /dev/null | wc -l
if [ "$total_wait_time" -gt "$max_wait_time" ]
then
echo "FAILED: exceeding the max wait time $max_wait_time while waiting for pipeline0.log file, stop waiting"
return
fi
echo "could not find pipeline log file yet, sleep for $sleep_increments and retry it again"
sleep $sleep_increments
total_wait_time=$(( total_wait_time + sleep_increments ))
done
echo "total wait time = $total_wait_time seconds"
}
# initial setup
setup
# 1. test Automated Self Checkout: should run and exit without any error
echo "Running Automated Self Checkout..."
make run
status_code=$?
verifyStatusCode $status_code
# test profile currently doesn't have logfile output
teardown
# 2. Automated Self Checkout CPU results: should see non-empty pipeline0.log contents
echo "Running Automated Self Checkout CPU with logs..."
make run
status_code=$?
verifyStatusCode $status_code
# allowing some time to process
waitForLogFile
verifyNonEmptyPipelineLog
teardown
# 3. Automated Self Checkout GPU results: should see non-empty pipeline0.log contents
echo "Running Automated Self Checkout GPU with logs..."
make run DEVICE_ENV=res/yolov5-gpu.env DEVICE=GPU
status_code=$?
verifyStatusCode $status_code
# allowing some time to process
waitForLogFile
verifyNonEmptyPipelineLog
teardown