forked from artyom-beilis/cppcms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice_test
More file actions
executable file
·103 lines (95 loc) · 2.31 KB
/
Copy pathservice_test
File metadata and controls
executable file
·103 lines (95 loc) · 2.31 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
#!/usr/bin/env bash
############################################################################
#
# Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
#
# See accompanying file COPYING.TXT file for licensing details.
#
############################################################################
EXE=$2/cppcms_service_test
LOCK=$2/lock.pid
GET_PID="$1 `dirname $0`/service_test.py"
if killall cppcms_service_test &>/dev/null
then
echo "Some cppcms_service_test processes exists before the test"
exit 1
fi
for N in 0 1 5
do
echo "- Testing for worker_processes=$N"
if [ "$N" != "0" ]
then
PROC=--service-worker_processes=$N
else
PROC=
fi
if ! $EXE --service-api=http --http-script=/test $PROC --daemon-enable=true --daemon-lock=$LOCK
then
echo "Failed to start service"
exit 1
else
echo "-- Service started sucessefully"
fi
if ! [ -e $LOCK ]
then
echo "Lock file was not created"
exit 1
else
echo "-- Lock file created"
fi
sleep 1
if ! kill -0 `cat $LOCK`
then
echo "The process does not exists"
exit 1
else
echo "-- process exists"
fi
PROC_PID=`cat $LOCK`
RES_PID=`$GET_PID`
if ([ "$N" == "0" ] && [ "$PROC_PID" == "$RES_PID" ] ) || ( [ "$N" != "0" ] && [ "$PROC_PID" != "$RES_PID" ] )
then
echo "-- fork/non-fork PID ok"
else
echo "Invalid PID!"
exit 1
fi
if ! kill `cat $LOCK`
then
echo "Failed to kill the process"
exit 1
else
echo "-- stopper process ok"
fi
sleep 1
if [ -e $LOCK ]
then
echo "Lock file was not removed!"
exit 1
else
echo "-- Lock file removed"
fi
if killall cppcms_service_test &>/dev/null
then
echo "Some cppcms_service_test processes exists after we killed it"
exit 1
else
echo "-- no processes exist"
fi
echo >$LOCK
if $EXE --service-api=http --service-worker_processes=$N --daemon-enable=true --daemon-lock=$LOCK
then
echo "Process started regardless lock file!"
exit 1
else
echo "-- process does not start if lock file exists"
fi
if killall cppcms_service_test &>/dev/null
then
echo "Some cppcms_service_test processes exists even when $LOCK exists"
exit 1
else
echo "-- process does not start if lock file exists (really)"
fi
rm $LOCK
done