]> git.stg.codes - stg.git/blob - functest/test_services.sh
Use common functions in admin tests and service tests.
[stg.git] / functest / test_services.sh
1 #!/bin/sh
2
3 source `dirname $0`/functions
4
5 BASEPATH=$1
6
7 SGCONFPATH="$BASEPATH/stg/projects/sgconf"
8
9 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
10
11 if [ "$?" != "0" ]
12 then
13     printf "Failed to get services list. Result:\n$RES\n"
14     exit 0
15 fi
16
17 NAMES=`getFields "name" "$RES"`
18
19 printf "Names:\n$NAMES\n"
20
21 NUM=`count "$NAMES"`
22
23 printf -- "--------\n$NUM\n\n"
24
25 if [ "$NUM" != "0" ]
26 then
27     printf "Services list should be empty.\n"
28     exit 0
29 fi
30
31 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --add-service test`
32
33 if [ "$?" != "0" ]
34 then
35     printf "Failed to add new service. Result:\n$RES\n"
36     exit 0
37 fi
38
39 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
40
41 if [ "$?" != "0" ]
42 then
43     printf "Failed to get services list. Result:\n$RES\n"
44     exit 0
45 fi
46
47 NAMES=`getFields "name" "$RES"`
48
49 printf "Names:\n$NAMES\n"
50
51 NUM=`count "$NAMES"`
52
53 printf -- "--------\n$NUM\n\n"
54
55 if [ "$NUM" != "1" ]
56 then
57     printf "Services list should have exactly one entry.\n"
58     exit 0
59 fi
60
61 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --del-service test`
62
63 if [ "$?" != "0" ]
64 then
65     printf "Failed to delete a service. Result:\n$RES\n"
66     exit 0
67 fi
68
69 RES=`"$SGCONFPATH/sgconf" -s localhost -p 5555 -u admin -w 123456 --get-services`
70
71 if [ "$?" != "0" ]
72 then
73     printf "Failed to get services list. Result:\n$RES\n"
74     exit 0
75 fi
76
77 NAMES=`getFields "name" "$RES"`
78
79 printf "Names:\n$NAMES\n"
80
81 NUM=`count "$NAMES"`
82
83 printf -- "--------\n$NUM\n\n"
84
85 if [ "$NUM" != "0" ]
86 then
87     printf "Services list should be empty.\n"
88     exit 0
89 fi