]> git.stg.codes - stg.git/blob - functest/test.sh
Ticket12. The StopOnError parameter is comment out.
[stg.git] / functest / test.sh
1 #!/bin/sh
2
3 BASEPATH=$1
4
5 source `dirname $0`/functions
6
7 if [ "$BASEPATH" == "" ]
8 then
9     printf "Usage: $0 <path>\n"
10     exit -1
11 fi
12
13 if [ ! -d "$BASEPATH" ]
14 then
15     printf "Path '$BASEPATH' does not exist or not a directory.\n"
16     exit -1
17 fi
18
19 STGPATH="$BASEPATH/stg/projects/stargazer"
20
21 cp "stuff/stargazer-files.conf" "$STGPATH/stargazer.conf"
22 cp "stuff/rules" "$STGPATH/"
23 cp "stuff/OnConnect" "$STGPATH/"
24 cp "stuff/OnDisconnect" "$STGPATH/"
25 cp "stuff/OnChange" "$STGPATH/"
26 cp -R "stuff/db-stub" "$STGPATH/db"
27
28 GROUP=root
29 groups | grep root > /dev/null 2> /dev/null
30 if [ "$?" != "0" ]
31 then
32     groups | grep wheel > /dev/null 2> /dev/null
33     if [ "$?" != "0" ]
34     then
35         printf "Can't find neither 'root' nor 'wheel' group.\n"
36         exit -1
37     fi
38     GROUP=wheel
39 fi
40
41 subst "-STG-PATH-" "$STGPATH" "$STGPATH/stargazer.conf"
42 subst "-STG-GROUP-" "$GROUP" "$STGPATH/stargazer.conf"
43
44 CURPATH=`pwd`
45 LOGFILE="$CURPATH/"`date "+%Y-%m-%d-%H%M%S.console.log"`
46
47 cd "$STGPATH"
48
49 printf "Starting Stargazer... "
50
51 "$STGPATH/stargazer" "$STGPATH" >> "$LOGFILE" 2>&1 &
52
53 COUNT=""
54 while true
55 do
56     grep "Stg started successfully" "$STGPATH/stargazer.log" > /dev/null 2> /dev/null
57     if [ "$?" == "0" ]
58     then
59         break
60     fi
61     COUNT="$COUNT."
62     if [ "$COUNT" == "....." ]
63     then
64         printf "Failed to start stg in 5 sec.\n"
65         exit -1
66     fi
67     sleep 1
68 done
69
70 PID=`cat "$STGPATH/stargazer.pid"`
71 printf "Started with pid $PID\n"
72
73 printf "\nTesting server info:\n"
74 "$CURPATH/test_server_info.sh" "$BASEPATH"
75 printf "\nTesting admins:\n"
76 "$CURPATH/test_admins.sh" "$BASEPATH"
77 printf "\nTesting services:\n"
78 "$CURPATH/test_services.sh" "$BASEPATH"
79 printf "\n"
80
81 printf "Stopping... "
82 kill $PID
83
84 COUNT=""
85 while true
86 do
87     grep "Stg stopped successfully" "$STGPATH/stargazer.log" > /dev/null 2> /dev/null
88     if [ "$?" == "0" ]
89     then
90         break
91     fi
92     COUNT="$COUNT."
93     if [ "$COUNT" == "....." ]
94     then
95         printf "Failed to stop stg in 5 sec.\n"
96         exit -1
97     fi
98     sleep 1
99 done
100
101 printf "Stopped.\n"