1 | #!/bin/bash |
---|
2 | |
---|
3 | Usage=$(cat <<EOF |
---|
4 | Please use the following syntaxe: |
---|
5 | |
---|
6 | ./run.sh <WPSInstance> <ServiceName> |
---|
7 | |
---|
8 | where <WPSInstance> should be the url to a WPS Server and <ServiceName> should |
---|
9 | be the service name you want to run tests with. |
---|
10 | |
---|
11 | For instance to test the Buffer service on a localhost WPS server, use the |
---|
12 | following command: |
---|
13 | |
---|
14 | ./run.sh http://localhost/cgi-bin/zoo_loader.cgi Buffer |
---|
15 | |
---|
16 | EOF |
---|
17 | ) |
---|
18 | |
---|
19 | if [ -z "$1" ] || [ -z "$2" ]; then |
---|
20 | echo "$Usage" |
---|
21 | exit |
---|
22 | fi |
---|
23 | |
---|
24 | WPSInstance=$1 |
---|
25 | ServiceName=$2 |
---|
26 | NBRequests=1000 |
---|
27 | NBConcurrents=50 |
---|
28 | |
---|
29 | function kvpRequest { |
---|
30 | echo " **" |
---|
31 | echo " * Simple KVP request start on $(date)" |
---|
32 | echo " * [$1] " |
---|
33 | echo " **" |
---|
34 | |
---|
35 | RESP=$(curl -v -o "$2" "$1" 2> tmp/temp.log; grep "< HTTP" tmp/temp.log | cut -d' ' -f3) |
---|
36 | if [ "${3}" == "owsExceptionReport" ]; then |
---|
37 | echo " *********************************" |
---|
38 | if [ "$RESP" == "200" ]; then |
---|
39 | echo " ! Invalid response code ($RESP)" |
---|
40 | else |
---|
41 | echo " * Valid response code ($RESP)" |
---|
42 | fi |
---|
43 | echo " *********************************" |
---|
44 | echo " * Checking for ${3} response XML validity..." |
---|
45 | echo " * Schema: [http://schemas.opengis.net/ows/1.1.0/${3}.xsd]" |
---|
46 | echo " *********************************" |
---|
47 | xmllint --noout --schema http://schemas.opengis.net/ows/1.1.0/${3}.xsd "$2" |
---|
48 | echo " *********************************" |
---|
49 | echo "Verifying that the missing / wrong argument was referenced in locator and the exceptionCode take the corresponding value ..." |
---|
50 | echo -n " *********************************" |
---|
51 | xsltproc ./extractExceptionInfo.xsl "$2" |
---|
52 | echo " *********************************" |
---|
53 | else |
---|
54 | if [ "$RESP" == "200" ]; then |
---|
55 | echo " * Valid response code ($RESP)" |
---|
56 | else |
---|
57 | echo " ! Invalid response code ($RESP)" |
---|
58 | fi |
---|
59 | echo " * Checking for ${3} response XML validity..." |
---|
60 | echo " * Schema: [http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd]" |
---|
61 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd "$2" |
---|
62 | fi |
---|
63 | echo " **" |
---|
64 | echo " * Sending 10000 ${3} requests starting on $(date) ..." |
---|
65 | echo " **" |
---|
66 | ab -n "$NBRequests" -c "$NBConcurrents" "$1" |
---|
67 | echo " ** Ending on $(date)" |
---|
68 | } |
---|
69 | |
---|
70 | function postRequest { |
---|
71 | echo " **" |
---|
72 | echo " * Simple POST request started on $(date)" |
---|
73 | echo " **" |
---|
74 | echo " * Checking for ${3} request XML validity..." |
---|
75 | echo " * Schema: http://schemas.opengis.net/wps/1.0.0/wps${3}_request.xsd" |
---|
76 | echo " *********************************" |
---|
77 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_request.xsd "$4" |
---|
78 | echo " *********************************" |
---|
79 | curl -H "Content-type: text/xml" -d@"$4" -o "$2" "$1" |
---|
80 | echo " * Checking for ${3} response XML validity on $(date) ..." |
---|
81 | echo " * Schema: http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd" |
---|
82 | echo " *********************************" |
---|
83 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd "$2" |
---|
84 | echo " *********************************" |
---|
85 | if [ -z "$5" ]; then |
---|
86 | echo "" |
---|
87 | else |
---|
88 | echo " * Schema: http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd" |
---|
89 | echo " *********************************" |
---|
90 | xmllint --noout --schema http://schemas.opengis.net/wps/1.0.0/wps${3}_response.xsd "$(xsltproc ./extractStatusLocation.xsl $2)" |
---|
91 | echo " *********************************" |
---|
92 | fi |
---|
93 | echo " * Sending 10000 ${3} XML requests on $(date) ..." |
---|
94 | ab -T "text/xml" -p "$4" -n "$NBRequests" -c "$NBConcurrents" "$1" |
---|
95 | echo " ** Ending on $(date)" |
---|
96 | } |
---|
97 | |
---|
98 | function kvpRequestWrite { |
---|
99 | suffix="" |
---|
100 | cnt=0 |
---|
101 | cnt0=0 |
---|
102 | for i in $2; do |
---|
103 | if [ ! $1 -eq $cnt0 ]; then |
---|
104 | if [ $cnt -gt 0 ]; then |
---|
105 | suffix="$suffix&$(echo $i | sed 's:\"::g')" |
---|
106 | else |
---|
107 | suffix="$(echo $i | sed 's:\"::g')" |
---|
108 | fi |
---|
109 | cnt=$(expr $cnt + 1) |
---|
110 | fi |
---|
111 | cnt0=$(expr $cnt0 + 1) |
---|
112 | done |
---|
113 | echo $suffix |
---|
114 | } |
---|
115 | |
---|
116 | function kvpWrongRequestWrite { |
---|
117 | suffix="" |
---|
118 | cnt=0 |
---|
119 | cnt0=0 |
---|
120 | for i in $2; do |
---|
121 | if [ ! $1 -eq $cnt0 ]; then |
---|
122 | if [ $cnt -gt 0 ]; then |
---|
123 | suffix="$suffix&$(echo $i | sed 's:\"::g')" |
---|
124 | else |
---|
125 | suffix="$(echo $i | sed 's:\"::g')" |
---|
126 | fi |
---|
127 | cnt=$(expr $cnt + 1) |
---|
128 | else |
---|
129 | cnt1=0 |
---|
130 | for j in $3; do |
---|
131 | if [ $cnt1 -eq $1 ]; then |
---|
132 | suffix="$suffix&$(echo $j | sed 's:\"::g')" |
---|
133 | fi |
---|
134 | cnt1=$(expr $cnt1 + 1) |
---|
135 | done |
---|
136 | fi |
---|
137 | cnt0=$(expr $cnt0 + 1) |
---|
138 | done |
---|
139 | echo $suffix |
---|
140 | } |
---|
141 | |
---|
142 | |
---|
143 | # |
---|
144 | # Tests for GetCapabilities using KVP (including wrong requests) and POST requests |
---|
145 | # |
---|
146 | kvpRequest "${WPSInstance}?REQUEST=GetCapabilities&SERVICE=WPS" "tmp/outputGC1.xml" "GetCapabilities" |
---|
147 | |
---|
148 | params='"request=GetCapabilities" "service=WPS"' |
---|
149 | |
---|
150 | suffix=$(kvpRequestWrite -1 "$params") |
---|
151 | kvpRequest "${WPSInstance}?$suffix" "tmp/outputGC2.xml" "GetCapabilities" |
---|
152 | |
---|
153 | for j in 0 1; do |
---|
154 | suffix=$(kvpRequestWrite $j "$params") |
---|
155 | kvpRequest "${WPSInstance}?$suffix" "tmp/outputGC$(expr $j + 3).xml" "owsExceptionReport" |
---|
156 | done |
---|
157 | |
---|
158 | paramsw='"request=GetCapabilitie" "service=WXS"' |
---|
159 | for j in 0 1; do |
---|
160 | suffix=$(kvpWrongRequestWrite $j "$params" "$paramsw") |
---|
161 | kvpRequest "${WPSInstance}?$suffix" "tmp/outputGC$(expr $j + 5).xml" "owsExceptionReport" |
---|
162 | done |
---|
163 | |
---|
164 | echo "Check if differences between upper case and lower case parameter names" |
---|
165 | diff -ru tmp/outputGC1.xml tmp/outputGC2.xml |
---|
166 | |
---|
167 | echo "" |
---|
168 | |
---|
169 | curl -o tmp/10_wpsGetCapabilities_request.xml http://schemas.opengis.net/wps/1.0.0/examples/10_wpsGetCapabilities_request.xml |
---|
170 | postRequest "${WPSInstance}" "tmp/outputGCp.xml" "GetCapabilities" "tmp/10_wpsGetCapabilities_request.xml" |
---|
171 | echo "" |
---|
172 | |
---|
173 | # |
---|
174 | # Tests for DescribeProcess using KVP and POST requests |
---|
175 | # |
---|
176 | kvpRequest "${WPSInstance}?request=DescribeProcess&service=WPS&version=1.0.0&Identifier=ALL" "tmp/outputDPall.xml" "DescribeProcess" |
---|
177 | |
---|
178 | params='"request=DescribeProcess" "service=WPS" "version=1.0.0" "Identifier='${ServiceName}'"' |
---|
179 | |
---|
180 | suffix=$(kvpRequestWrite -1 "$params") |
---|
181 | kvpRequest "${WPSInstance}?$suffix" "tmp/outputDPb1.xml" "DescribeProcess" |
---|
182 | |
---|
183 | for j in 0 1 2 3; do |
---|
184 | suffix=$(kvpRequestWrite $j "$params") |
---|
185 | kvpRequest "${WPSInstance}?$suffix" "tmp/outputDPb$(expr $j + 2).xml" "owsExceptionReport" |
---|
186 | done |
---|
187 | |
---|
188 | paramsw='"request=DescribeProces" "service=WXS" "version=1.2.0" "Identifier=Undefined"' |
---|
189 | |
---|
190 | for j in 0 1 2 3; do |
---|
191 | suffix=$(kvpWrongRequestWrite $j "$params") |
---|
192 | kvpRequest "${WPSInstance}?$suffix" "tmp/outputDPb$(expr $j + 6).xml" "owsExceptionReport" |
---|
193 | done |
---|
194 | |
---|
195 | |
---|
196 | cat requests/dp.xml | sed "s:ServiceName:${ServiceName}:g" > tmp/dp1.xml |
---|
197 | postRequest "${WPSInstance}" "tmp/outputDPp.xml" "DescribeProcess" "tmp/dp1.xml" |
---|
198 | echo "" |
---|
199 | |
---|
200 | # |
---|
201 | # Tests for Execute using KVP and POST requests |
---|
202 | # |
---|
203 | for i in ijson_o igml_o ir_o ir_o_async ir_or ir_or_async irb_o irb_o_async irb_or irb_or_async; |
---|
204 | do |
---|
205 | cat requests/${i}.xml | sed "s:ServiceName:${ServiceName}:g" > tmp/${i}1.xml |
---|
206 | if [ -z "$(echo $i | grep async)" ]; then |
---|
207 | postRequest "${WPSInstance}" "tmp/outputE${i}.xml" "Execute" "tmp/${i}1.xml" |
---|
208 | else |
---|
209 | postRequest "${WPSInstance}" "tmp/outputE${i}.xml" "Execute" "tmp/${i}1.xml" "async" |
---|
210 | fi |
---|
211 | echo "" |
---|
212 | done |
---|
213 | |
---|
214 | echo "" |
---|