7b8478ddf80b708cf9b9de80c17d9254494adcd1
[nonrtric.git] / test / auto-test / FTC100.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="Full a1pms API walkthrough using a1pms REST/DMAAP and with/without SDNC A1 Controller"
22
23 USE_ISTIO=0
24
25 #App names to include in the test when running docker, space separated list
26 DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR A1PMS RICSIM SDNC NGW KUBEPROXY"
27
28 #App names to include in the test when running kubernetes, space separated list
29 if [ $USE_ISTIO -eq 0 ]; then
30     KUBE_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM SDNC KUBEPROXY NGW"
31 else
32     KUBE_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM SDNC KUBEPROXY NGW KEYCLOAK ISTIO AUTHSIDECAR"
33 fi
34 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
35 KUBE_PRESTARTED_IMAGES=""
36
37 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
38 #the image is not configured in the supplied env_file
39 #Used for images not applicable to all supported profile
40 CONDITIONALLY_IGNORED_IMAGES="CBS CONSUL NGW"
41
42 #Supported test environment profiles
43 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ONAP-JAKARTA ONAP-KOHN ONAP-LONDON  ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE ORAN-G-RELEASE ORAN-H-RELEASE"
44 #Supported run modes
45 SUPPORTED_RUNMODES="DOCKER KUBE"
46
47 . ../common/testcase_common.sh $@
48
49 setup_testenvironment
50
51 #### TEST BEGIN ####
52
53 generate_policy_uuid
54
55 if [ $USE_ISTIO -eq 0 ]; then
56     # Tested variants of REST/DMAAP/SDNC config
57     TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
58
59     #Test a1pms and simulator protocol versions (others are http only)
60     TESTED_PROTOCOLS="HTTP HTTPS"
61 else
62     if [ $USE_ISTIO -eq 1 ]; then
63         echo -e $RED"#########################################"$ERED
64         echo -e $RED"# No test of https when running with istio"$ERED
65         echo -e $RED"# No test of SDNC when running with istio"$ERED
66         echo -e $RED"#########################################"$ERED
67     fi
68     # Tested variants of REST/DMAAP/SDNC config
69     TESTED_VARIANTS="REST   DMAAP"
70
71     #Test a1pms and simulator protocol versions (others are http only)
72     TESTED_PROTOCOLS="HTTP"
73 fi
74
75 for __httpx in $TESTED_PROTOCOLS ; do
76     for interface in $TESTED_VARIANTS ; do
77
78         echo "#####################################################################"
79         echo "#####################################################################"
80         echo "### Testing a1pms: $interface using $__httpx"
81         echo "#####################################################################"
82         echo "#####################################################################"
83
84         # Clean container and start all needed containers #
85         clean_environment
86
87         if [ $RUNMODE != "KUBE" ]; then
88             USE_ISTIO=0
89             echo "ISTIO not supported by docker - setting USE-ISTIO=0"
90         fi
91
92         if [ $USE_ISTIO -eq 1 ]; then
93             echo -e $RED"#########################################"$ERED
94             echo -e $RED"# Work around istio jwks cache"$ERED
95             echo -e $RED"# Cycle istiod down and up to clear cache"$ERED
96             echo ""
97             __kube_scale deployment istiod istio-system 0
98             __kube_scale deployment istiod istio-system 1
99             echo -e $RED"# Cycle istiod done"
100             echo -e $RED"#########################################"$ERED
101
102             istio_enable_istio_namespace $KUBE_SIM_NAMESPACE
103             istio_enable_istio_namespace $KUBE_NONRTRIC_NAMESPACE
104             istio_enable_istio_namespace $KUBE_A1SIM_NAMESPACE
105         fi
106
107
108         start_kube_proxy
109
110         if [ $USE_ISTIO -eq 1 ]; then
111             start_keycloak
112
113             keycloak_api_obtain_admin_token
114
115             keycloak_api_create_realm                   nrtrealm   true   60
116             keycloak_api_create_confidential_client     nrtrealm   a1pmsc
117             keycloak_api_generate_client_secret         nrtrealm   a1pmsc
118             keycloak_api_get_client_secret              nrtrealm   a1pmsc
119             keycloak_api_create_client_roles            nrtrealm   a1pmsc nrtrole
120             keycloak_api_map_client_roles               nrtrealm   a1pmsc nrtrole
121
122             keycloak_api_get_client_token               nrtrealm   a1pmsc
123
124             CLIENT_TOKEN=$(keycloak_api_read_client_token nrtrealm   a1pmsc)
125             echo "CLIENT_TOKEN: "$CLIENT_TOKEN
126
127             A1PMS_SEC=$(keycloak_api_read_client_secret nrtrealm   a1pmsc)
128             echo "A1PMS_SEC: "$A1PMS_SEC
129
130             # Protect ricsim-g3
131             istio_req_auth_by_jwks              ricsim-g1 $KUBE_A1SIM_NAMESPACE KUBEPROXY "$KUBE_PROXY_ISTIO_JWKS_KEYS"
132             istio_auth_policy_by_issuer         ricsim-g1 $KUBE_A1SIM_NAMESPACE KUBEPROXY
133
134             istio_req_auth_by_jwksuri           ricsim-g1 $KUBE_A1SIM_NAMESPACE nrtrealm
135             istio_auth_policy_by_realm          ricsim-g1 $KUBE_A1SIM_NAMESPACE nrtrealm a1pmsc nrtrole
136
137             # Protect ricsim-g2
138             istio_req_auth_by_jwks              ricsim-g2 $KUBE_A1SIM_NAMESPACE KUBEPROXY "$KUBE_PROXY_ISTIO_JWKS_KEYS"
139             istio_auth_policy_by_issuer         ricsim-g2 $KUBE_A1SIM_NAMESPACE KUBEPROXY
140
141             istio_req_auth_by_jwksuri           ricsim-g2 $KUBE_A1SIM_NAMESPACE nrtrealm
142             istio_auth_policy_by_realm          ricsim-g2 $KUBE_A1SIM_NAMESPACE nrtrealm a1pmsc nrtrole
143
144             # Protect ricsim-g3
145             istio_req_auth_by_jwks              ricsim-g3 $KUBE_A1SIM_NAMESPACE KUBEPROXY "$KUBE_PROXY_ISTIO_JWKS_KEYS"
146             istio_auth_policy_by_issuer         ricsim-g3 $KUBE_A1SIM_NAMESPACE KUBEPROXY
147
148             istio_req_auth_by_jwksuri           ricsim-g3 $KUBE_A1SIM_NAMESPACE nrtrealm
149             istio_auth_policy_by_realm          ricsim-g3 $KUBE_A1SIM_NAMESPACE nrtrealm a1pmsc nrtrole
150
151             # Protect CR
152             istio_req_auth_by_jwks              $CR_APP_NAME $KUBE_SIM_NAMESPACE KUBEPROXY "$KUBE_PROXY_ISTIO_JWKS_KEYS"
153             istio_auth_policy_by_issuer         $CR_APP_NAME $KUBE_SIM_NAMESPACE KUBEPROXY
154
155             istio_req_auth_by_jwksuri           $CR_APP_NAME $KUBE_SIM_NAMESPACE nrtrealm
156             istio_auth_policy_by_realm          $CR_APP_NAME $KUBE_SIM_NAMESPACE nrtrealm a1pmsc nrtrole
157
158             a1pms_configure_sec nrtrealm a1pmsc $A1PMS_SEC
159         fi
160
161         if [ $__httpx == "HTTPS" ]; then
162             use_cr_https
163             use_a1pms_rest_https
164         else
165             use_a1pms_rest_http
166             use_cr_http
167         fi
168
169         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
170
171         set_a1pms_debug
172
173         # Create service to be able to receive events when rics becomes available
174         # Must use rest towards the a1pms since dmaap is not configured yet
175         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
176
177
178         if [ $__httpx == "HTTPS" ]; then
179             use_simulator_https
180             use_mr_https
181             if [[ $interface = *"SDNC"* ]]; then
182                 use_sdnc_https
183             fi
184             if [[ $interface = *"DMAAP"* ]]; then
185                 use_a1pms_dmaap_https
186             else
187                 use_a1pms_rest_https
188             fi
189         else
190             use_simulator_http
191             use_mr_http
192             if [[ $interface = *"SDNC"* ]]; then
193                 use_sdnc_http
194             fi
195             if [[ $interface = *"DMAAP"* ]]; then
196                 use_a1pms_dmaap_http
197             else
198                 use_a1pms_rest_http
199             fi
200         fi
201
202         start_ric_simulators ricsim_g1 1  OSC_2.1.0
203         start_ric_simulators ricsim_g2 1  STD_1.1.3
204
205         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
206         sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
207
208         if [ "$A1PMS_VERSION" == "V2" ]; then
209             start_ric_simulators ricsim_g3 1  STD_2.0.0
210             sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
211             sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
212         fi
213
214         start_mr
215
216         start_cr 1
217
218         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
219
220         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
221             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
222         fi
223
224         __CONFIG_HEADER="NOHEADER"
225         if [ $RUNMODE == "KUBE" ]; then
226             __CONFIG_HEADER="HEADER"
227         else
228             if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
229                 __CONFIG_HEADER="HEADER"
230             fi
231         fi
232         if [[ $interface = *"SDNC"* ]]; then
233             start_sdnc
234             prepare_consul_config      SDNC    ".consul_config.json" $__CONFIG_HEADER
235         else
236             prepare_consul_config      NOSDNC  ".consul_config.json" $__CONFIG_HEADER
237         fi
238
239         if [ $RUNMODE == "KUBE" ]; then
240             a1pms_load_config                       ".consul_config.json"
241         else
242             if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
243                 #Temporary switch to http/https if dmaap use. Otherwise it is not possibble to push config
244                 if [ $__httpx == "HTTPS" ]; then
245                     use_a1pms_rest_https
246                 else
247                     use_a1pms_rest_http
248                 fi
249
250                 if [[ $interface != *"DMAAP"* ]]; then
251                     echo "{}" > ".consul_config_incorrect.json"
252                     a1pms_api_put_configuration 400 ".consul_config_incorrect.json"
253                 fi
254
255                 a1pms_api_put_configuration 200 ".consul_config.json"
256                 a1pms_api_get_configuration 200 ".consul_config.json"
257                 if [ $__httpx == "HTTPS" ]; then
258                     if [[ $interface = *"DMAAP"* ]]; then
259                         use_a1pms_dmaap_https
260                     else
261                         use_a1pms_rest_https
262                     fi
263                 else
264                     if [[ $interface = *"DMAAP"* ]]; then
265                         use_a1pms_dmaap_http
266                     else
267                         use_a1pms_rest_http
268                     fi
269                 fi
270
271             else
272                 start_consul_cbs
273                 consul_config_app                   ".consul_config.json"
274             fi
275         fi
276
277         if [ "$A1PMS_VERSION" == "V2" ]; then
278             a1pms_equal json:rics 3 300
279
280             a1pms_equal json:policy-types 5 120
281
282             a1pms_equal json:policies 0
283
284             a1pms_equal json:policy-instances 0
285         else
286             a1pms_equal json:rics 2 300
287
288             a1pms_equal json:policy_schemas 3 120
289
290             a1pms_equal json:policy_types 3
291
292             a1pms_equal json:policies 0
293
294             a1pms_equal json:policy_ids 0
295         fi
296
297         if [ "$A1PMS_VERSION" == "V2" ]; then
298             cr_equal 0 received_callbacks 3 120
299             cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
300         fi
301         mr_equal requests_submitted 0
302
303
304         echo "############################################"
305         echo "############## Health check ################"
306         echo "############################################"
307
308         sleep_wait 120 "Let A1PMS cofiguration take effect"
309
310         a1pms_api_get_status 200
311
312         a1pms_api_get_status_root 200
313
314         echo "############################################"
315         echo "##### Service registry and supervision #####"
316         echo "############################################"
317
318         a1pms_api_get_services 404 "service1"
319
320         a1pms_api_put_service 201 "service1" 1000 "$CR_SERVICE_APP_PATH_0/1"
321
322         a1pms_api_put_service 200 "service1" 2000 "$CR_SERVICE_APP_PATH_0/1"
323
324
325         a1pms_api_put_service 400 "service2" -1 "$CR_SERVICE_APP_PATH_0/2"
326
327         a1pms_api_put_service 400 "service2" "wrong" "$CR_SERVICE_APP_PATH_0/2"
328
329         a1pms_api_put_service 400 "service2" 100 "/test"
330
331         a1pms_api_put_service 400 "service2" 100 "test-path"
332
333         a1pms_api_put_service 201 "service2" 300 "ftp://localhost:80/test"
334
335         a1pms_api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_APP_PATH_0/1"
336
337         a1pms_api_get_service_ids 200 "service1" "service2" "ric-registration"
338
339
340         a1pms_api_put_service 201 "service3" 5000 "$CR_SERVICE_APP_PATH_0/3"
341
342
343         a1pms_api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
344
345
346         a1pms_api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_APP_PATH_0/1"
347
348         a1pms_api_get_services 200 NOSERVICE "service1" 2000 "$CR_SERVICE_APP_PATH_0/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_SERVICE_APP_PATH_0/3"  "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
349
350         a1pms_api_get_services 200
351
352         deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
353         #The below should work, keept here until fixed or other decision made
354         #a1pms_api_put_services_keepalive 201 "service1"
355         #Using the below until decision
356         a1pms_api_put_services_keepalive 200 "service1"
357
358         deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
359         #The below should work, keept here until fixed or other decision made
360         #a1pms_api_put_services_keepalive 201 "service3"
361         #Using the below until decision
362         a1pms_api_put_services_keepalive 200 "service3"
363
364         a1pms_api_put_services_keepalive 200 "service1"
365
366         a1pms_api_put_services_keepalive 200 "service3"
367
368         a1pms_api_put_services_keepalive 404 "service5"
369
370         a1pms_api_get_service_ids 200 "service1" "service2" "service3"  "ric-registration"
371
372         a1pms_api_delete_services 204 "service1"
373
374         a1pms_api_get_service_ids 200 "service2" "service3" "ric-registration"
375
376
377         a1pms_api_put_service 201 "service1" 50 "$CR_SERVICE_APP_PATH_0/1"
378
379         a1pms_api_get_service_ids 200 "service1" "service2" "service3"  "ric-registration"
380
381
382         a1pms_api_delete_services 204 "service1"
383         a1pms_api_delete_services 204 "service3"
384
385         a1pms_equal json:services 2
386
387         a1pms_api_delete_services 204 "service2"
388
389         a1pms_equal json:services 1
390
391
392         echo "############################################"
393         echo "############## RIC Repository ##############"
394         echo "############################################"
395
396         if [ "$A1PMS_VERSION" == "V2" ]; then
397             a1pms_api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
398         else
399             a1pms_api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
400         fi
401         a1pms_api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
402
403         a1pms_api_get_rics 404 47
404
405         a1pms_api_get_rics 404 "test"
406
407         if [ "$A1PMS_VERSION" == "V2" ]; then
408             a1pms_api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
409
410             a1pms_api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
411
412             a1pms_api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
413
414             a1pms_api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
415
416             a1pms_api_get_ric 200 me1_ricsim_g3_1 NORIC "ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
417
418             a1pms_api_get_ric 200 me2_ricsim_g3_1 NORIC "ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
419
420             a1pms_api_get_ric 200 NOME      ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
421
422             a1pms_api_get_ric 200 NOME      ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
423
424             a1pms_api_get_ric 200 NOME      ricsim_g3_1 "ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
425
426             a1pms_api_get_ric 404 NOME test1
427
428             a1pms_api_get_ric 404 test NORIC
429
430             a1pms_api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
431
432             a1pms_api_get_ric 400 me1_ricsim_g1_1 TESTRIC
433
434             a1pms_api_get_ric 400 TESTME ricsim_g1_1
435
436         else
437             a1pms_api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
438
439             a1pms_api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
440
441             a1pms_api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
442
443             a1pms_api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
444
445             a1pms_api_get_ric 404 test
446         fi
447
448         echo "############################################"
449         echo "########### A1 Policy Management ###########"
450         echo "############################################"
451
452         if [ "$A1PMS_VERSION" == "V2" ]; then
453             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
454             #Behaviour accepted for now
455             a1pms_api_get_policy_type 200 1 testdata/OSC/1-a1pms-modified.json
456             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
457             #Behaviour accepted for now
458             a1pms_api_get_policy_type 200 2 testdata/OSC/2-a1pms-modified.json
459             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
460             #Behaviour accepted for now
461             a1pms_api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-a1pms-modified.json
462             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
463             #Behaviour accepted for now
464             a1pms_api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-a1pms-modified.json
465
466             a1pms_api_get_policy_type 404 3
467         else
468             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
469             #Behaviour accepted for now
470             a1pms_api_get_policy_schema 200 1 testdata/OSC/1-a1pms-modified.json
471             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
472             #Behaviour accepted for now
473             a1pms_api_get_policy_schema 200 2 testdata/OSC/2-a1pms-modified.json
474
475             a1pms_api_get_policy_schema 404 3
476         fi
477
478         if [ "$A1PMS_VERSION" == "V2" ]; then
479             a1pms_api_get_policy_schemas 404
480         else
481             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
482             #Behaviour accepted for now
483             a1pms_api_get_policy_schemas 200 NORIC testdata/OSC/1-a1pms-modified.json testdata/OSC/2-a1pms-modified.json NOFILE
484             deviation "TR9 - a1pms modify the type with type id - test combo $interface and $__httpx"
485             #Behaviour accepted for now
486             a1pms_api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-a1pms-modified.json testdata/OSC/2-a1pms-modified.json
487
488             a1pms_api_get_policy_schemas 200 ricsim_g2_1 NOFILE
489
490             a1pms_api_get_policy_schemas 404 test
491         fi
492
493
494         if [ "$A1PMS_VERSION" == "V2" ]; then
495             a1pms_api_get_policy_types 200 NORIC 1 2 EMPTY STD_QOS_0_2_0 STD_QOS2_0.1.0
496         else
497             a1pms_api_get_policy_types 200 NORIC 1 2 EMPTY
498         fi
499
500         a1pms_api_get_policy_types 200 ricsim_g1_1 1 2
501
502         a1pms_api_get_policy_types 200 ricsim_g2_1 EMPTY
503
504         if [ "$A1PMS_VERSION" == "V2" ]; then
505             a1pms_api_get_policy_types 200 ricsim_g3_1 STD_QOS_0_2_0 STD_QOS2_0.1.0
506         fi
507
508         a1pms_api_get_policy_types 404 dummy-ric
509
510
511
512         a1pms_api_put_service 201 "service10" 3600 "$CR_SERVICE_APP_PATH_0/1"
513
514         if [ "$A1PMS_VERSION" == "V2" ]; then
515             notificationurl=$CR_SERVICE_APP_PATH_0"/test"
516         else
517             notificationurl=""
518         fi
519         if [[ $interface != *"DMAAP"* ]]; then
520             # Badly formatted json is not possible to send via dmaap
521             a1pms_api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi_bad_template.json
522         fi
523         deviation "TR10 - a1pms allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
524         #Kept until decison
525         #a1pms_api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
526         #Allow 201 for now
527         a1pms_api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
528
529         a1pms_api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
530         a1pms_api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
531
532         a1pms_api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
533         a1pms_api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
534
535         a1pms_api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
536         a1pms_api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
537
538         a1pms_api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
539         a1pms_api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
540
541         if [ "$A1PMS_VERSION" == "V2" ]; then
542             a1pms_api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
543             a1pms_api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
544
545             a1pms_api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 true $notificationurl testdata/STD2/pi_qos2_template.json
546             a1pms_api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 false $notificationurl testdata/STD2/pi_qos2_template.json
547         fi
548
549         a1pms_api_get_policy_status 404 1
550         a1pms_api_get_policy_status 404 2
551         VAL='NOT IN EFFECT'
552         a1pms_api_get_policy_status 200 5000 OSC "$VAL" "false"
553         a1pms_api_get_policy_status 200 5100 STD "UNDEFINED"
554         if [ "$A1PMS_VERSION" == "V2" ]; then
555             a1pms_api_get_policy_status 200 5200 STD2 EMPTY EMPTY
556         fi
557
558
559         deviation "TR10 - a1pms allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
560         #kept until decision
561         #a1pms_equal json:policies 2
562         #Allow 3 for now
563         if [ "$A1PMS_VERSION" == "V2" ]; then
564             a1pms_equal json:policies 4
565         else
566             a1pms_equal json:policies 3
567         fi
568
569         deviation "TR10 - a1pms allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
570         #kept until decision
571         #a1pms_equal json:policy_ids 2
572         #Allow 3 for now
573         if [ "$A1PMS_VERSION" == "V2" ]; then
574             a1pms_equal json:policy-instances 4
575         else
576             a1pms_equal json:policy_ids 3
577         fi
578
579         deviation "TR10 - a1pms allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
580         #kept until decision
581         #a1pms_api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
582         #Allow policy create with unregistered service for now
583         if [ "$A1PMS_VERSION" == "V2" ]; then
584             a1pms_api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000 5200
585         else
586             a1pms_api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
587         fi
588
589         deviation "TR10 - a1pms allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
590         #kept until decision
591         #a1pms_api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
592         #Allow policy create with unregistered service for now
593         if [ "$A1PMS_VERSION" == "V2" ]; then
594             a1pms_api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
595
596             a1pms_api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
597
598             a1pms_api_get_policy_ids 200 ricsim_g3_1 NOSERVICE NOTYPE 5200
599
600             a1pms_api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100 5200
601         else
602             a1pms_api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
603
604             a1pms_api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
605
606
607             a1pms_api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
608         fi
609
610         deviation "TR10 - a1pms allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
611         #kept until decision
612         #a1pms_api_get_policy_ids 200 NORIC NOSERVICE 1 5000
613         #Allow policy create with unregistered service for now
614
615         a1pms_api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
616
617         a1pms_api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
618
619         if [ "$A1PMS_VERSION" == "V2" ]; then
620             a1pms_api_get_policy_ids 200 NORIC NOSERVICE STD_QOS2_0.1.0 5200
621         fi
622
623         a1pms_api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
624
625         if [ "$A1PMS_VERSION" == "V2" ]; then
626             a1pms_api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
627
628             a1pms_api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
629
630             a1pms_api_get_policy 200 5200 testdata/STD2/pi_qos2_template.json "service10" ricsim_g3_1 STD_QOS2_0.1.0 false $notificationurl
631
632             a1pms_api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
633         else
634             a1pms_api_get_policy 200 5000 testdata/OSC/pi1_template.json
635
636             a1pms_api_get_policy 200 5100 testdata/STD/pi1_template.json
637
638             a1pms_api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
639         fi
640
641         deviation "TR10 - a1pms allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
642         #kept until decision
643         #a1pms_api_delete_policy 404 2000
644         #Allow policy create with unregistered service for now
645         a1pms_api_delete_policy 204 2000
646
647         a1pms_api_delete_policy 404 1500
648
649         a1pms_api_delete_policy 204 5000
650
651         if [ "$A1PMS_VERSION" == "V2" ]; then
652
653             a1pms_api_delete_policy 204 5200
654         fi
655
656         a1pms_equal json:policies 1
657
658
659         if [ "$A1PMS_VERSION" == "V2" ]; then
660             a1pms_equal json:policy-instances 1
661         else
662             a1pms_equal json:policy_ids 1
663         fi
664
665         a1pms_api_delete_policy 204 5100
666
667         a1pms_equal json:policies 0
668
669         if [ "$A1PMS_VERSION" == "V2" ]; then
670             a1pms_equal json:policy-instances 0
671         else
672             a1pms_equal json:policy_ids 0
673         fi
674
675         if [ "$A1PMS_VERSION" == "V2" ]; then
676             cr_equal 0 received_callbacks 3
677         fi
678
679         if [[ $interface = *"DMAAP"* ]]; then
680             mr_greater requests_submitted 0
681             VAL=$(mr_read requests_submitted)
682             mr_equal requests_fetched $VAL
683             mr_equal responses_submitted $VAL
684             mr_equal responses_fetched $VAL
685             mr_equal current_requests 0
686             mr_equal current_responses 0
687         else
688             mr_equal requests_submitted 0
689         fi
690         if [ $USE_ISTIO -eq 0 ]; then
691             if [[ $interface = *"SDNC"* ]]; then
692                 sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
693                 sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
694                 if [ "$A1PMS_VERSION" == "V2" ]; then
695                     sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
696                 fi
697             else
698                 sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
699                 sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
700                 if [ "$A1PMS_VERSION" == "V2" ]; then
701                     sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
702                 fi
703             fi
704         fi
705
706         check_a1pms_logs
707
708         if [[ $interface = *"SDNC"* ]]; then
709             check_sdnc_logs
710         fi
711
712         store_logs          "${__httpx}__${interface}"
713
714     done
715
716 done
717
718 #### TEST COMPLETE ####
719
720
721 print_result
722
723 auto_clean_environment