forked from intel-retail/loss-prevention
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke_test.sh
executable file
·122 lines (109 loc) · 3.38 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/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 Loss Prevention image"
make build
echo "Download models"
make download-models
}
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 "=== Loss Prevention smoke test status code PASSED"
else
echo "=== Loss Prevention 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 "=== Loss Prevention smoke test pipeline log PASSED"
else
echo "=== Loss Prevention 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 Loss Prevention: should run and exit without any error
echo "Running Loss Prevention..."
make run
status_code=$?
verifyStatusCode $status_code
# test profile currently doesn't have logfile output
teardown
# 2. Loss Prevention CPU results: should see non-empty pipeline0.log contents
echo "Running Loss Prevention CPU with logs..."
make run
status_code=$?
verifyStatusCode $status_code
# allowing some time to process
waitForLogFile
verifyNonEmptyPipelineLog
teardown
# 3. Loss Prevention GPU results: should see non-empty pipeline0.log contents
echo "Running Loss Prevention GPU with logs..."
make run DEVICE_ENV=res/all-gpu.env DEVICE=GPU
status_code=$?
verifyStatusCode $status_code
# allowing some time to process
waitForLogFile
verifyNonEmptyPipelineLog
teardown
# 4. Yolov8s pipeine: should see non-empty pipeline0.log contents
echo "Running YOLOv8s pipeline with logs..."
INPUTSRC=https://github.com/intel-iot-devkit/sample-videos/raw/master/people-detection.mp4 PIPELINE_SCRIPT=yolov8s_roi.sh docker compose -f src/docker-compose.yml up -d
status_code=$?
verifyStatusCode $status_code
# allowing some time to process
waitForLogFile
verifyNonEmptyPipelineLog
teardown
# 5. Age pipeline: should see non-empty pipeline0.log contents
echo "Running Age Classification pipeline with logs..."
INPUTSRC=https://www.pexels.com/download/video/3248275 PIPELINE_SCRIPT=age_recognition.sh docker compose -f src/docker-compose.yml up -d
status_code=$?
verifyStatusCode $status_code
# allowing some time to process
waitForLogFile
verifyNonEmptyPipelineLog
teardown