3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
20 # Automated test script for producer stub container
23 echo "Usage: ./basic_test.sh nonsecure|secure"
26 if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
27 echo "Usage: ./basic_test.sh nonsecure|secure"
31 if [ $1 == "nonsecure" ]; then
32 #Default http port for the simulator
37 #Default https port for the simulator
43 # source function to do curl and check result
44 . ../common/do_curl_function.sh
47 echo "=== hello world ==="
53 do_curl GET /reset 200
57 do_curl GET /status 200
61 echo "=== check supervision counter ==="
63 do_curl GET /counter/supervision/prod-x 200
65 echo "=== check create counter ==="
67 do_curl GET /counter/create/prod-x/job-x 200
69 echo "=== check delete counter ==="
71 do_curl GET /counter/delete/prod-x/job-x 200
73 ## Create/update a producer
75 echo "=== create producer ==="
76 RESULT="Unknown query parameter(s)"
77 do_curl PUT /arm/supervision/prod-x?test=201 400
79 echo "=== create producer ==="
81 do_curl PUT /arm/supervision/prod-x?response=201 200
83 echo "=== update producer ==="
85 do_curl PUT /arm/supervision/prod-x?response=400 200
87 echo "=== update producer ==="
89 do_curl PUT /arm/supervision/prod-x 200
91 ## Add types to a producere
93 echo "=== add type 10 ==="
95 do_curl PUT /arm/type/prod-x/10 200
97 echo "=== add type 15 ==="
99 do_curl PUT /arm/type/prod-x/15 200
103 echo "=== status ==="
104 RESULT="json:{\"prod-x\": {\"supervision_response\": 200, \"supervision_counter\": 0, \"types\": [\"10\", \"15\"]}}"
105 do_curl GET /status 200
108 echo "=== add type 20 ==="
110 do_curl PUT /arm/type/prod-x/20 200
112 echo "=== status ==="
113 RESULT="json:{\"prod-x\": {\"supervision_response\": 200, \"supervision_counter\": 0, \"types\": [\"10\", \"15\", \"20\"]}}"
114 do_curl GET /status 200
117 echo "=== remove type 20 ==="
119 do_curl DELETE /arm/type/prod-x/20 200
121 echo "=== status ==="
122 RESULT="json:{\"prod-x\": {\"supervision_response\": 200, \"supervision_counter\": 0, \"types\": [\"10\", \"15\"]}}"
123 do_curl GET /status 200
125 ## producer supervision
126 echo "=== check supervision counter ==="
128 do_curl GET /counter/supervision/prod-x 200
130 echo "=== supervision producer ==="
132 do_curl GET /callbacks/supervision/prod-x 200
134 echo "=== update producer ==="
136 do_curl PUT /arm/supervision/prod-x?response=400 200
138 echo "=== callback supervision producer ==="
139 RESULT="returning configured response code"
140 do_curl GET /callbacks/supervision/prod-x 400
144 echo "=== status ==="
145 RESULT="json:{\"prod-x\": {\"supervision_response\": 400, \"supervision_counter\": 2, \"types\": [\"10\", \"15\"]}}"
146 do_curl GET /status 200
150 echo "=== add job ==="
152 do_curl PUT /arm/create/prod-x/job-y 200
154 echo "=== update job ==="
156 do_curl PUT /arm/create/prod-x/job-y?response=405 200
160 echo "=== status ==="
161 RESULT="json:{\"prod-x\": {\"supervision_response\": 400, \"supervision_counter\": 2, \"types\": [\"10\", \"15\"], \"job-y\": {\"create_response\": 405, \"delete_response\": 404, \"json\": null, \"create_counter\": 0, \"delete_counter\": 0, \"delivering\": \"stopped\", \"delivery_attempts\": 0}}}"
162 do_curl GET /status 200
164 ## add delete response for job
166 echo "=== update job ==="
168 do_curl PUT /arm/delete/prod-x/job-y?response=407 200
172 echo "=== status ==="
173 RESULT="json:{\"prod-x\": {\"supervision_response\": 400, \"supervision_counter\": 2, \"types\": [\"10\", \"15\"], \"job-y\": {\"create_response\": 405, \"delete_response\": 407, \"json\": null, \"create_counter\": 0, \"delete_counter\": 0, \"delivering\": \"stopped\", \"delivery_attempts\": 0}}}"
174 do_curl GET /status 200
177 echo "=== job data ==="
179 do_curl GET /jobdata/prod-x/job-y 204
183 echo "=== add job ==="
185 do_curl PUT /arm/create/prod-x/job-1 200
187 do_curl PUT /arm/delete/prod-x/job-1 200
189 echo "=== callback create job ==="
191 echo "{\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\",\"ei_type_identity\": \"10\"}" > .p.json
192 do_curl POST /callbacks/job/prod-x 201 .p.json
194 echo "=== callback create job -update ==="
196 echo "{\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\",\"ei_type_identity\": \"10\"}" > .p.json
197 do_curl POST /callbacks/job/prod-x 200 .p.json
200 echo "=== job data ==="
201 RESULT="json:{\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\", \"ei_type_identity\": \"10\"}"
202 do_curl GET /jobdata/prod-x/job-1 200
206 echo "=== status ==="
207 RESULT="json:{\"prod-x\": {\"supervision_response\": 400, \"supervision_counter\": 2, \"types\": [\"10\", \"15\"], \"job-y\": {\"create_response\": 405, \"delete_response\": 407, \"json\": null, \"create_counter\": 0, \"delete_counter\": 0, \"delivering\": \"stopped\", \"delivery_attempts\": 0}, \"job-1\": {\"create_response\": 200, \"delete_response\": 204, \"json\": {\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\", \"ei_type_identity\": \"10\"}, \"create_counter\": 2, \"delete_counter\": 0, \"delivering\": \"delivering\", \"delivery_attempts\": 0}}}"
208 do_curl GET /status 200
210 # create and delete job tests
211 echo "=== set job create response ==="
213 do_curl PUT /arm/create/prod-x/job-1?response=404 200
215 echo "=== callback create job -update ==="
216 RESULT="returning configured response code"
217 echo "{\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\",\"ei_type_identity\": \"10\"}" > .p.json
218 do_curl POST /callbacks/job/prod-x 404 .p.json
220 echo "=== set job delete response ==="
222 do_curl PUT /arm/delete/prod-x/job-1?response=404 200
224 echo "=== callback delete job==="
225 RESULT="returning configured response code"
226 echo "{\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\",\"ei_type_identity\": \"10\"}" > .p.json
227 do_curl DELETE /callbacks/job/prod-x/job-1 404 .p.json
229 echo "=== set job delete response ==="
231 do_curl PUT /arm/delete/prod-x/job-1 200
233 echo "=== callback delete job==="
235 echo "{\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\",\"ei_type_identity\": \"10\"}" > .p.json
236 do_curl DELETE /callbacks/job/prod-x/job-1 204 .p.json
240 echo "=== status ==="
241 RESULT="json:{\"prod-x\": {\"supervision_response\": 400, \"supervision_counter\": 2, \"types\": [\"10\", \"15\"], \"job-y\": {\"create_response\": 405, \"delete_response\": 407, \"json\": null, \"create_counter\": 0, \"delete_counter\": 0, \"delivering\": \"stopped\", \"delivery_attempts\": 0}, \"job-1\": {\"create_response\": 404, \"delete_response\": 404, \"json\": null, \"create_counter\": 3, \"delete_counter\": 2, \"delivering\": \"stopped\", \"delivery_attempts\": 0}}}"
242 do_curl GET /status 200
247 echo "=== update producer ==="
249 do_curl PUT /arm/create/prod-x/job-1 200
251 echo "=== callback create job ==="
253 echo "{\"ei_job_identity\": \"job-1\", \"ei_job_data\": {}, \"target_uri\": \"http://localhost:80\",\"ei_type_identity\": \"10\"}" > .p.json
254 do_curl POST /callbacks/job/prod-x 201 .p.json
256 echo "=== data delivery start ==="
257 RESULT="job not found"
258 do_curl POST /jobdata/prod-x/job-x?action=START 404
260 echo "=== data delivery start ==="
262 do_curl POST /jobdata/prod-x/job-1?action=START 200
267 echo "=== data delivery stop ==="
269 do_curl POST /jobdata/prod-x/job-1?action=STOP 200
271 echo "********************"
272 echo "*** All tests ok ***"
273 echo "********************"