OSDN Git Service

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