OSDN Git Service

trunk整理
[ultramonkey-l7/ultramonkey-l7-v3.git] / test / script / module-protocol-ip / ip-56.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 start_lighttpd -s $RealServer1 -a $RealServer1_ADDR -p $RealServer1_PORT
26 if [ $? -ne 0 ]
27 then
28         echo "Test failed: start_lighttpd RealServer1"
29         exit 1
30 fi
31
32 $L7VSADM -A -t 127.0.0.1:40001 -m ip --statistic 1 -F
33 if [ $? -ne 0 ]
34 then
35         echo "Test failed: $L7VSADM -A -t 127.0.0.1:40001 -m ip --statistic 1 -F"
36         exit 1
37 fi
38
39 $L7VSADM -a -t 127.0.0.1:40001 -m ip -r 127.0.0.1:50001
40 if [ $? -ne 0 ]
41 then
42         echo "Test failed: $L7VSADM -a -t 127.0.0.1:40001 -m ip -r $RealServer1_ADDR:$RealServer1_PORT"
43         exit 1
44 fi
45
46 #Connect
47 echo -e -n "GET / HTTP/1.0\r\n\r\n" | nc 127.0.0.1 40001
48 echo -e -n "POST / HTTP/1.0\r\n\r\n" | nc 127.0.0.1 40001
49
50 #HTTP Total Requests check
51 RET=`$L7VSADM -V -n | grep "HTTP Total Requests" | awk '{print $4}'`
52 EXPECT="2"
53 if [ "${RET}" != "${EXPECT}" ]
54 then
55         echo "Test failed: $L7VSADM -V -n"
56         exit 1
57 fi
58
59 #HTTP GET Requests check
60 RET=`$L7VSADM -V -n | grep "HTTP GET Requests" | awk '{print $4}'`
61 EXPECT="1"
62 if [ "${RET}" != "${EXPECT}" ]
63 then
64         echo "Test failed: $L7VSADM -V -n"
65         exit 1
66 fi
67
68 #HTTP POST Requests check
69 RET=`$L7VSADM -V -n | grep "HTTP POST Requests" | awk '{print $4}'`
70 EXPECT="1"
71 if [ "${RET}" != "${EXPECT}" ]
72 then
73         echo "Test failed: $L7VSADM -V -n"
74         exit 1
75 fi
76
77
78
79 exit 0
80