OSDN Git Service

trunk整理
[ultramonkey-l7/ultramonkey-l7-v3.git] / test / script / l7vsadm / l7vsadm-13-1-25.sh
1 #!/bin/bash
2
3 . ${SET_DEFAULT_CONF}
4
5 #Add Service
6 $L7VSD
7 if [ $? -ne 0 ]
8 then
9         echo "Test failed: $L7VSD"
10         exit 1
11 fi
12
13 usleep 100000
14
15 #Run http server
16 RealServer1=RealServer1
17 RealServer1_ADDR=127.0.0.1
18 RealServer1_PORT=50001
19 start_lighttpd -s $RealServer1 -a $RealServer1_ADDR -p $RealServer1_PORT
20 if [ $? -ne 0 ]
21 then
22         echo "Test failed: start_lighttpd RealServer1"
23         exit 1
24 fi
25
26 RealServer2=RealServer2
27 RealServer2_ADDR=127.0.0.1
28 RealServer2_PORT=50002
29 start_lighttpd -s $RealServer2 -a $RealServer2_ADDR -p $RealServer2_PORT
30 if [ $? -ne 0 ]
31 then
32         echo "Test failed: start_lighttpd RealServer2"
33         exit 1
34 fi
35
36 $L7VSADM -A -t 127.0.0.1:40001 -m sessionless --statistic 1 -F 
37 if [ $? -ne 0 ]
38 then
39         echo "Test failed: $L7VSADM -A -t 127.0.0.1:40001 -m sessionless --statistic 1 -F"
40         exit 1
41 fi
42
43 $L7VSADM -a -t 127.0.0.1:40001 -m sessionless -r ${RealServer1_ADDR}:${RealServer1_PORT}
44 if [ $? -ne 0 ]
45 then
46         echo "Test failed: $L7VSADM -a -t 127.0.0.1:40001 -m sessionless -r ${RealServer1_ADDR}:${RealServer1_PORT}"
47         exit 1
48 fi
49
50 $L7VSADM -A -t 127.0.0.1:40002 -m sessionless --statistic 1 -F 
51 if [ $? -ne 0 ]
52 then
53         echo "Test failed: $L7VSADM -A -t 127.0.0.1:40001 -m sessionless --statistic 1 -F"
54         exit 1
55 fi
56
57 $L7VSADM -a -t 127.0.0.1:40002 -m sessionless -r ${RealServer2_ADDR}:${RealServer2_PORT}
58 if [ $? -ne 0 ]
59 then
60         echo "Test failed: $L7VSADM -a -t 127.0.0.1:40002 -m sessionless -r ${RealServer2_ADDR}:${RealServer2_PORT}"
61         exit 1
62 fi
63
64
65 #Connect
66 GET_REQ="GET / HTTP/1.0\r\n\r\n"
67 POST_REQ="POST / HTTP/1.0\r\n\r\n"
68 for ((I=0; I<100;I++)) 
69 {
70     echo -e -n "${GET_REQ}" | nc 127.0.0.1 40001 >/dev/null 2>&1
71     echo -e -n "${GET_REQ}" | nc 127.0.0.1 40002 >/dev/null 2>&1
72 }
73
74 for ((I=0; I<200;I++)) 
75 {
76     echo -e -n "${POST_REQ}" | nc 127.0.0.1 40001 >/dev/null 2>&1
77     echo -e -n "${POST_REQ}" | nc 127.0.0.1 40002 >/dev/null 2>&1
78 }
79
80
81 #HTTP Total Requests check
82 RET=`$L7VSADM -V -n | grep "HTTP Total Requests" | awk '{ print $4}'`
83 EXPECT="300
84 300"
85 if [ "${RET}" != "${EXPECT}" ]
86 then
87         echo "Test failed: $L7VSADM -V -n | grep "HTTP Total Requests" | awk '{print $4}'"
88         exit 1
89 fi
90
91 #HTTP GET Requests check
92 RET=`$L7VSADM -V -n | grep "HTTP GET Requests" | awk '{print $4}'`
93 EXPECT="100
94 100"
95 if [ "${RET}" != "${EXPECT}" ]
96 then
97         echo "Test failed: $L7VSADM -V -n | grep "HTTP GET Requests" | awk '{print $4}'"
98         exit 1
99 fi
100
101 #HTTP POST Requests check
102 RET=`$L7VSADM -V -n | grep "HTTP POST Requests" | awk '{print $4}'`
103 EXPECT="200
104 200"
105 if [ "${RET}" != "${EXPECT}" ]
106 then
107         echo "Test failed: $L7VSADM -V -n | grep "HTTP POST Requests" | awk '{print $4}"
108         exit 1
109 fi
110
111 #clear statistic
112 $L7VSADM -S -r
113 if [ $? -ne 0 ]
114 then
115         echo "Test failed: $L7VSADM -S -r"
116         exit 1
117 fi
118
119 #HTTP Total Requests check
120 RET=`$L7VSADM -V -n | grep "HTTP Total Requests" | awk '{print $4}'`
121 EXPECT="0
122 0"
123 if [ "${RET}" != "${EXPECT}" ]
124 then
125         echo "Test failed: $L7VSADM -V -n | grep "HTTP Total Requests" | awk '{print $4}'"
126         exit 1
127 fi
128
129 #HTTP GET Requests check
130 RET=`$L7VSADM -V -n | grep "HTTP GET Requests" | awk '{print $4}'`
131 EXPECT="0
132 0"
133
134 if [ "${RET}" != "${EXPECT}" ]
135 then
136         echo "Test failed: $L7VSADM -V -n | grep "HTTP GET Requests" | awk '{print $4}'"
137         exit 1
138 fi
139
140 #HTTP POST Requests check
141 RET=`$L7VSADM -V -n | grep "HTTP POST Requests" | awk '{print $4}'`
142 EXPECT="0
143 0"
144 if [ "${RET}" != "${EXPECT}" ]
145 then
146         echo "Test failed: $L7VSADM -V -n | grep "HTTP POST Requests" | awk '{print $4}"
147         exit 1
148 fi
149
150
151 exit 0
152