OSDN Git Service

Add DHC Test scripts
[ultramonkey-l7/ultramonkey-l7-v3.git] / test / script / PT / B / B-56.sh
1 #!/bin/bash
2
3 # set config file
4 . ${SET_DEFAULT_CONF}
5
6 #copy config file
7 \cp -f materials/B-56-l7vs.cf ${L7VSD_CONF_DIR}/l7vs.cf
8
9 #Start snmptrapd
10 ${SNMPTRAPD} -c ./materials/B-56-snmptrapd.conf -Lf ${L7VS_LOG_DIR}/B-56-snmptrapd.log
11
12 #check service snmpd is running
13 RET=`pgrep snmpd`
14 if [ -z "${RET}" ]
15 then
16     echo "Test failed: snmp is not running"
17     exit 1
18 fi
19
20
21 #Start L7VAD Service
22 $L7VSD
23 if [ $? -ne 0 ]
24 then
25         echo "Test failed: $L7VSD"
26         exit 1
27 fi
28
29 usleep 100000
30
31 #Set Trap Log Level
32 $L7VSADM -S -t 1 -l warn
33 if [ $? -ne 0 ]
34 then
35         echo "Test failed: $L7VSADM -S -t 1 -l warn"
36         exit 1
37 fi
38
39 #Add virtual Service
40 $L7VSADM -A -t 127.0.0.1:40001 -m sessionless
41 if [ $? -ne 0 ]
42 then
43         echo "Test failed: $L7VSADM -A -t 127.0.0.1:40001 -m sessionless"
44         exit 1
45 fi
46 #Add virtual Service Again
47 $L7VSADM -A -t 127.0.0.1:40001 -m sessionless
48
49 #need time to write log file
50 usleep 1000000
51
52
53 #Check Trap Log
54 RET=`cat  ${L7VS_LOG_DIR}/B-56-snmptrapd.log | grep -e  "SNMPv2-SMI::enterprises.32132.1.0.3.3 = STRING: \"[0-9]\{4\}/[0-9]\{2\}/[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\},VSD3.*"`
55 if [ -z "${RET}" ]
56 then
57         echo "Test failed: cat ${L7VS_LOG_DIR}/B-56-snmptrapd.log"
58         exit 1
59 fi
60
61 #Check MIB
62 RET=`snmpwalk -v 2c -c public localhost  ULTRAMONKEY-L7-MIB::ultramonkey-l7`
63 EXPECT="ULTRAMONKEY-L7-MIB::l7vsVsNumber.0 = INTEGER: 1
64 ULTRAMONKEY-L7-MIB::l7vsVsIndex.1 = INTEGER: 1
65 ULTRAMONKEY-L7-MIB::l7vsVsProtocol.1 = INTEGER: tcp(1)
66 ULTRAMONKEY-L7-MIB::l7vsVsAddrType.1 = INTEGER: IPv4(1)
67 ULTRAMONKEY-L7-MIB::l7vsVsAddr.1 = STRING: \"127.0.0.1\"
68 ULTRAMONKEY-L7-MIB::l7vsVsPort.1 = Gauge32: 40001
69 ULTRAMONKEY-L7-MIB::l7vsVsProtocolModuleName.1 = STRING: sessionless
70 ULTRAMONKEY-L7-MIB::l7vsVsProtocolModuleOptions.1 = STRING: 
71 ULTRAMONKEY-L7-MIB::l7vsVsScheduleModuleName.1 = STRING: rr
72 ULTRAMONKEY-L7-MIB::l7vsVsScheduleModuleOptions.1 = STRING:  
73 ULTRAMONKEY-L7-MIB::l7vsVsSorryAddrType.1 = INTEGER: IPv4(1)
74 ULTRAMONKEY-L7-MIB::l7vsVsSorryAddr.1 = STRING: \"0.0.0.0\"
75 ULTRAMONKEY-L7-MIB::l7vsVsSorryPort.1 = Gauge32: 0
76 ULTRAMONKEY-L7-MIB::l7vsVsSorryConnLimit.1 = Counter64: 0 Connections
77 ULTRAMONKEY-L7-MIB::l7vsVsSorryForceEnabled.1 = INTEGER: off(2)
78 ULTRAMONKEY-L7-MIB::l7vsVsThroughputUp.1 = Counter64: 0 B/s
79 ULTRAMONKEY-L7-MIB::l7vsVsThroughputDown.1 = Counter64: 0 B/s
80 ULTRAMONKEY-L7-MIB::l7vsVsThroughputUpQoS.1 = Counter64: 0 B/s
81 ULTRAMONKEY-L7-MIB::l7vsVsThroughputDownQos.1 = Counter64: 0 B/s
82 ULTRAMONKEY-L7-MIB::l7vsVsSslFlag.1 = INTEGER: 0
83 ULTRAMONKEY-L7-MIB::l7vsVsSessionPoolCount.1 = INTEGER: 31
84 ULTRAMONKEY-L7-MIB::l7vsVsSessionActiveCount.1 = INTEGER: 0
85 ULTRAMONKEY-L7-MIB::l7vsVsSessionWaitCount.1 = INTEGER: 1
86 ULTRAMONKEY-L7-MIB::l7vsVsHttpTotalCount.1 = Counter64: 0
87 ULTRAMONKEY-L7-MIB::l7vsVsHttpGetCount.1 = Counter64: 0
88 ULTRAMONKEY-L7-MIB::l7vsVsHttpPostCount.1 = Counter64: 0
89 ULTRAMONKEY-L7-MIB::l7vsVsRsNumber.1 = INTEGER: 0
90 ULTRAMONKEY-L7-MIB::l7vsReplicationMode.0 = INTEGER: single(1)"
91
92 if [ "${RET}" != "${EXPECT}" ]
93 then
94         echo "Test failed: snmpwalk -v 2c -c public localhost  ULTRAMONKEY-L7-MIB::ultramonkey-l7"
95         exit 1
96 fi
97
98 #restart snmpd
99 ${INIT_SNMPD} stop
100 sleep 2
101 ${INIT_SNMPD} start
102 sleep 2
103
104 #Add virtual Service Again
105 #warnning log trap 
106 $L7VSADM -A -t 127.0.0.1:40001 -m sessionless
107 sleep 1
108
109 RET=`cat ${L7VS_LOG_DIR}/B-56-snmptrapd.log | grep -e "SNMPv2-SMI::enterprises.32132.1.0.3.3 = STRING: \"[0-9]\{4\}/[0-9]\{2\}/[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\},VSD3.*" | wc -l`
110 echo "TEST:: $RET"
111 if [ "${RET}" != "2" ]
112 then
113         echo "Test failed: cat ${L7VS_LOG_DIR}/B-56-snmptrapd.log"
114         exit 1
115 fi
116
117 sleep 20
118
119 #Check MIB
120 RET=`snmpwalk -v 2c -c public localhost  ULTRAMONKEY-L7-MIB::ultramonkey-l7`
121 EXPECT="ULTRAMONKEY-L7-MIB::l7vsVsNumber.0 = INTEGER: 1
122 ULTRAMONKEY-L7-MIB::l7vsVsIndex.1 = INTEGER: 1
123 ULTRAMONKEY-L7-MIB::l7vsVsProtocol.1 = INTEGER: tcp(1)
124 ULTRAMONKEY-L7-MIB::l7vsVsAddrType.1 = INTEGER: IPv4(1)
125 ULTRAMONKEY-L7-MIB::l7vsVsAddr.1 = STRING: \"127.0.0.1\"
126 ULTRAMONKEY-L7-MIB::l7vsVsPort.1 = Gauge32: 40001
127 ULTRAMONKEY-L7-MIB::l7vsVsProtocolModuleName.1 = STRING: sessionless
128 ULTRAMONKEY-L7-MIB::l7vsVsProtocolModuleOptions.1 = STRING: 
129 ULTRAMONKEY-L7-MIB::l7vsVsScheduleModuleName.1 = STRING: rr
130 ULTRAMONKEY-L7-MIB::l7vsVsScheduleModuleOptions.1 = STRING:  
131 ULTRAMONKEY-L7-MIB::l7vsVsSorryAddrType.1 = INTEGER: IPv4(1)
132 ULTRAMONKEY-L7-MIB::l7vsVsSorryAddr.1 = STRING: \"0.0.0.0\"
133 ULTRAMONKEY-L7-MIB::l7vsVsSorryPort.1 = Gauge32: 0
134 ULTRAMONKEY-L7-MIB::l7vsVsSorryConnLimit.1 = Counter64: 0 Connections
135 ULTRAMONKEY-L7-MIB::l7vsVsSorryForceEnabled.1 = INTEGER: off(2)
136 ULTRAMONKEY-L7-MIB::l7vsVsThroughputUp.1 = Counter64: 0 B/s
137 ULTRAMONKEY-L7-MIB::l7vsVsThroughputDown.1 = Counter64: 0 B/s
138 ULTRAMONKEY-L7-MIB::l7vsVsThroughputUpQoS.1 = Counter64: 0 B/s
139 ULTRAMONKEY-L7-MIB::l7vsVsThroughputDownQos.1 = Counter64: 0 B/s
140 ULTRAMONKEY-L7-MIB::l7vsVsSslFlag.1 = INTEGER: 0
141 ULTRAMONKEY-L7-MIB::l7vsVsSessionPoolCount.1 = INTEGER: 31
142 ULTRAMONKEY-L7-MIB::l7vsVsSessionActiveCount.1 = INTEGER: 0
143 ULTRAMONKEY-L7-MIB::l7vsVsSessionWaitCount.1 = INTEGER: 1
144 ULTRAMONKEY-L7-MIB::l7vsVsHttpTotalCount.1 = Counter64: 0
145 ULTRAMONKEY-L7-MIB::l7vsVsHttpGetCount.1 = Counter64: 0
146 ULTRAMONKEY-L7-MIB::l7vsVsHttpPostCount.1 = Counter64: 0
147 ULTRAMONKEY-L7-MIB::l7vsVsRsNumber.1 = INTEGER: 0
148 ULTRAMONKEY-L7-MIB::l7vsReplicationMode.0 = INTEGER: single(1)"
149
150 echo "$EXPECT" > /tmp/1.txt
151 echo "$RET" > /tmp/2.txt
152 diff /tmp/1.txt /tmp/2.txt
153
154 if [ "${RET}" != "${EXPECT}" ]
155 then
156         echo "Test failed: snmpwalk -v 2c -c public localhost  ULTRAMONKEY-L7-MIB::ultramonkey-l7"
157         exit 1
158 fi
159
160
161
162 exit 0