Adding owner to jobInfo
[nonrtric.git] / test / auto-test / FTC1100.sh
1 #!/bin/bash
2
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
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
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=================================================
18 #
19
20
21 TC_ONELINE_DESCR="Experimental ECS test case"
22
23 #App names to include in the test, space separated list
24 INCLUDED_IMAGES="ECS PRODSTUB"
25
26 . ../common/testcase_common.sh  $@
27 . ../common/ecs_api_functions.sh
28 . ../common/prodstub_api_functions.sh
29
30 #### TEST BEGIN ####
31
32 FLAT_A1_EI="1"
33
34 clean_containers
35
36 use_ecs_rest_http
37
38 use_prod_stub_http
39
40 start_ecs
41
42 start_prod_stub
43
44 set_ecs_debug
45
46 set_ecs_trace
47
48 # Setup prodstub sim to accept calls for producers, types and jobs
49 prodstub_arm_producer 200 prod-a
50 prodstub_arm_producer 200 prod-b
51 prodstub_arm_producer 200 prod-c
52
53 prodstub_arm_producer 200 prod-d
54 prodstub_arm_type 200 prod-d type4
55 prodstub_arm_job_create 200 prod-d job8
56
57 prodstub_arm_type 200 prod-a type1
58 prodstub_arm_type 200 prod-b type2
59 prodstub_arm_type 200 prod-b type3
60
61 prodstub_disarm_type 200 prod-b type3
62 prodstub_arm_type 200 prod-b type1
63 prodstub_disarm_type 200 prod-b type1
64
65 prodstub_arm_job_create 200 prod-a job1
66 prodstub_arm_job_create 200 prod-a job2
67 prodstub_arm_job_create 200 prod-b job3
68
69 prodstub_arm_job_delete 200 prod-a job1
70 prodstub_arm_job_delete 200 prod-a job2
71 prodstub_arm_job_delete 200 prod-b job3
72
73 prodstub_arm_job_create 200 prod-b job4
74 prodstub_arm_job_create 200 prod-a job4
75
76 prodstub_arm_job_create 200 prod-b job5
77 prodstub_arm_job_create 200 prod-a job5
78 prodstub_arm_job_delete 200 prod-a job5
79
80 prodstub_arm_job_create 200 prod-b job6
81
82 # ecs status
83 ecs_api_service_status 200
84
85 # Initial tests - no config made
86 ecs_api_a1_get_type_ids 200 EMPTY
87 ecs_api_a1_get_type 404 test-type
88
89 ecs_api_edp_get_type_ids 200 EMPTY
90 ecs_api_edp_get_type 404 test-type
91
92 ecs_api_edp_get_producer_ids 200 EMPTY
93 ecs_api_edp_get_producer 404 test-prod
94
95 ecs_api_edp_get_producer_status 404 test-prod
96
97 ecs_api_edp_delete_producer 404 test-prod
98
99 if [  -z "$FLAT_A1_EI" ]; then
100     ecs_api_a1_get_job_ids 404 test-type NOWNER
101     ecs_api_a1_get_job_ids 404 test-type test-owner
102
103     ecs_api_a1_get_job 404 test-type test-job
104
105     ecs_api_a1_get_job_status 404 test-type test-job
106 else
107     ecs_api_a1_get_job_ids 200 test-type NOWNER EMPTY
108     ecs_api_a1_get_job_ids 200 test-type test-owner EMPTY
109
110     ecs_api_a1_get_job 404 test-job
111
112     ecs_api_a1_get_job_status 404 test-job
113 fi
114
115 if [  -z "$FLAT_A1_EI" ]; then
116     ecs_api_a1_delete_job 404 test-type test-job
117 else
118     ecs_api_a1_delete_job 404 test-job
119 fi
120
121 ecs_api_edp_get_producer_jobs 404 test-prod
122
123
124 # Setup of producer/job and test apis
125 #prod-a
126 ecs_api_edp_put_producer 201 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
127 ecs_api_edp_put_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
128
129 ecs_api_a1_get_type_ids 200 type1
130 if [  -z "$FLAT_A1_EI" ]; then
131     ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json
132 else
133     ecs_api_a1_get_type 200 type1 testdata/ecs/empty-type.json
134 fi
135
136 ecs_api_edp_get_type_ids 200 type1
137 ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a
138
139 ecs_api_edp_get_producer_ids 200 prod-a
140 ecs_api_edp_get_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
141
142 ecs_api_edp_get_producer_status 200 prod-a ENABLED
143
144 ecs_api_a1_get_job_ids 200 type1 NOWNER EMPTY
145 ecs_api_a1_get_job_ids 200 type1 test-owner EMPTY
146
147 if [  -z "$FLAT_A1_EI" ]; then
148     ecs_api_a1_get_job 404 type1 test-job
149
150     ecs_api_a1_get_job_status 404 type1 test-job
151 else
152     ecs_api_a1_get_job 404 test-job
153
154     ecs_api_a1_get_job_status 404 test-job
155 fi
156
157 ecs_api_edp_get_producer_jobs 200 prod-a EMPTY
158
159
160 #job1 - prod-a
161 if [  -z "$FLAT_A1_EI" ]; then
162     ecs_api_a1_put_job 201 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json
163 else
164     ecs_api_a1_put_job 201 job1 type1 http://localhost:80/target1 ric1 http://localhost:80/status1 testdata/ecs/job-template.json
165 fi
166
167 prodstub_check_jobdata 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json
168
169 ecs_api_a1_get_job_ids 200 type1 NOWNER job1
170 ecs_api_a1_get_job_ids 200 type1 ric1 job1
171 if [ ! -z "$FLAT_A1_EI" ]; then
172     ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1
173 fi
174
175 if [  -z "$FLAT_A1_EI" ]; then
176     ecs_api_a1_get_job 200 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json
177
178     ecs_api_a1_get_job_status 200 type1 job1 ENABLED
179 else
180     ecs_api_a1_get_job 200 job1 type1 http://localhost:80/target1 ric1 http://localhost:80/status1 testdata/ecs/job-template.json
181
182     ecs_api_a1_get_job_status 200 job1 ENABLED
183 fi
184
185 ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json
186
187
188 #job2 - prod-a
189 if [  -z "$FLAT_A1_EI" ]; then
190     ecs_api_a1_put_job 201 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json
191 else
192     ecs_api_a1_put_job 201 job2 type1 http://localhost:80/target2 ric2 http://localhost:80/status2 testdata/ecs/job-template.json
193 fi
194
195 prodstub_check_jobdata 200 prod-a job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json
196
197 ecs_api_a1_get_job_ids 200 type1 NOWNER job1 job2
198 ecs_api_a1_get_job_ids 200 type1 ric1 job1
199 ecs_api_a1_get_job_ids 200 type1 ric2 job2
200 if [ ! -z "$FLAT_A1_EI" ]; then
201     ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2
202 fi
203
204 if [  -z "$FLAT_A1_EI" ]; then
205     ecs_api_a1_get_job 200 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json
206
207     ecs_api_a1_get_job_status 200 type1 job2 ENABLED
208 else
209     ecs_api_a1_get_job 200 job2 type1 http://localhost:80/target2 ric2 http://localhost:80/status2 testdata/ecs/job-template.json
210
211     ecs_api_a1_get_job_status 200 job2 ENABLED
212 fi
213
214 ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json
215
216
217 #prod-b
218 ecs_api_edp_put_producer 201 prod-b http://producer-stub:8092/callbacks/create/prod-b http://producer-stub:8092/callbacks/delete/prod-b http://producer-stub:8092/callbacks/supervision/prod-b type2 testdata/ecs/ei-type-2.json
219
220 ecs_api_a1_get_type_ids 200 type1 type2
221 if [  -z "$FLAT_A1_EI" ]; then
222     ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json
223     ecs_api_a1_get_type 200 type2 testdata/ecs/ei-type-2.json
224 else
225     ecs_api_a1_get_type 200 type1 testdata/ecs/empty-type.json
226     ecs_api_a1_get_type 200 type2 testdata/ecs/empty-type.json
227 fi
228
229 ecs_api_edp_get_type_ids 200 type1 type2
230 ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a
231 ecs_api_edp_get_type 200 type2 testdata/ecs/ei-type-2.json prod-b
232
233 ecs_api_edp_get_producer_ids 200 prod-a prod-b
234 ecs_api_edp_get_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
235 ecs_api_edp_get_producer 200 prod-b http://producer-stub:8092/callbacks/create/prod-b http://producer-stub:8092/callbacks/delete/prod-b http://producer-stub:8092/callbacks/supervision/prod-b type2 testdata/ecs/ei-type-2.json
236
237 ecs_api_edp_get_producer_status 200 prod-b ENABLED
238
239
240 #job3 - prod-b
241 if [  -z "$FLAT_A1_EI" ]; then
242     ecs_api_a1_put_job 201 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json
243 else
244     ecs_api_a1_put_job 201 job3 type2 http://localhost:80/target3 ric3 http://localhost:80/status3 testdata/ecs/job-template.json
245 fi
246
247 prodstub_check_jobdata 200 prod-b job3 type2 http://localhost:80/target3 testdata/ecs/job-template.json
248
249 ecs_api_a1_get_job_ids 200 type1 NOWNER job1 job2
250 ecs_api_a1_get_job_ids 200 type2 NOWNER job3
251 ecs_api_a1_get_job_ids 200 type1 ric1 job1
252 ecs_api_a1_get_job_ids 200 type1 ric2 job2
253 ecs_api_a1_get_job_ids 200 type2 ric3 job3
254
255 if [  -z "$FLAT_A1_EI" ]; then
256     ecs_api_a1_get_job 200 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json
257
258     ecs_api_a1_get_job_status 200 type2 job3 ENABLED
259 else
260     ecs_api_a1_get_job 200 job3 type2 http://localhost:80/target3 ric3 http://localhost:80/status3 testdata/ecs/job-template.json
261
262     ecs_api_a1_get_job_status 200 job3 ENABLED
263 fi
264
265 ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json
266 ecs_api_edp_get_producer_jobs 200 prod-b job3 type2 http://localhost:80/target3 testdata/ecs/job-template.json
267
268
269 #prod-c (no types)
270 ecs_api_edp_put_producer 201 prod-c http://producer-stub:8092/callbacks/create/prod-c http://producer-stub:8092/callbacks/delete/prod-c http://producer-stub:8092/callbacks/supervision/prod-c NOTYPE
271
272 ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c
273 ecs_api_edp_get_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json
274 ecs_api_edp_get_producer 200 prod-b http://producer-stub:8092/callbacks/create/prod-b http://producer-stub:8092/callbacks/delete/prod-b http://producer-stub:8092/callbacks/supervision/prod-b type2 testdata/ecs/ei-type-2.json
275 ecs_api_edp_get_producer 200 prod-c http://producer-stub:8092/callbacks/create/prod-c http://producer-stub:8092/callbacks/delete/prod-c http://producer-stub:8092/callbacks/supervision/prod-c EMPTY
276
277 ecs_api_edp_get_producer_status 200 prod-c ENABLED
278
279 if [  -z "$FLAT_A1_EI" ]; then
280     ecs_api_a1_delete_job 204 type2 job3
281 else
282     ecs_api_a1_delete_job 204 job3
283 fi
284
285 ecs_api_edp_delete_producer 204 prod-b
286
287
288 prodstub_equal create/prod-d/job8 0
289 prodstub_equal delete/prod-d/job8 0
290
291 ecs_api_edp_put_producer 201 prod-d http://producer-stub:8092/callbacks/create/prod-d http://producer-stub:8092/callbacks/delete/prod-d http://producer-stub:8092/callbacks/supervision/prod-d type4 testdata/ecs/ei-type-1.json
292
293 ecs_api_a1_get_job_ids 200 type4 NOWNER EMPTY
294
295 if [  -z "$FLAT_A1_EI" ]; then
296     ecs_api_a1_put_job 201 type4 job8 http://localhost:80/target8 ric4 testdata/ecs/job-template.json
297 else
298     ecs_api_a1_put_job 201 job8 type4 http://localhost:80/target8 ric4 http://localhost:80/status4 testdata/ecs/job-template.json
299 fi
300 read -p "<continue>"
301 prodstub_equal create/prod-d/job8 1
302 prodstub_equal delete/prod-d/job8 0
303
304 ecs_api_a1_get_job_ids 200 type4 NOWNER job8
305
306 ecs_api_edp_put_producer 200 prod-d http://producer-stub:8092/callbacks/create/prod-d http://producer-stub:8092/callbacks/delete/prod-d http://producer-stub:8092/callbacks/supervision/prod-d NOTYPE
307
308 if [  -z "$FLAT_A1_EI" ]; then
309     ecs_api_a1_get_job_ids 404 type4 NOWNER
310 else
311     ecs_api_a1_get_job_ids 200 type4 NOWNER EMPTY
312     ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 job8
313 fi
314
315 prodstub_equal create/prod-d/job8 1
316 prodstub_equal delete/prod-d/job8 0
317
318
319
320 ecs_api_edp_put_producer 200 prod-d http://producer-stub:8092/callbacks/create/prod-d http://producer-stub:8092/callbacks/delete/prod-d http://producer-stub:8092/callbacks/supervision/prod-d type4 testdata/ecs/ei-type-1.json
321
322 if [  -z "$FLAT_A1_EI" ]; then
323     ecs_api_a1_get_job_ids 404 type4 NOWNER
324 else
325     ecs_api_a1_get_job_ids 200 type4 NOWNER EMPTY
326     ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 job8
327 fi
328
329
330
331
332
333
334 check_sdnc_logs
335
336 check_ecs_logs
337
338 store_logs END
339
340 #### TEST COMPLETE ####
341
342
343 print_result
344
345 auto_clean_containers