Merge "Change to use checked exceptions in rAPP Catalogue"
[nonrtric.git] / test / auto-test / PM_EI_DEMO.sh
1 #!/usr/bin/env 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 TC_ONELINE_DESCR="Preparation demo setup  - policy management and enrichment information"
21
22 #App names to include in the test, space separated list
23 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC ECS PRODSTUB RC"
24
25 #SUPPORTED TEST ENV FILE
26 SUPPORTED_PROFILES="ONAP-HONOLULU  ORAN-CHERRY ORAN-DAWN"
27
28 . ../common/testcase_common.sh $@
29 . ../common/agent_api_functions.sh
30 . ../common/ricsimulator_api_functions.sh
31 . ../common/ecs_api_functions.sh
32 . ../common/prodstub_api_functions.sh
33 . ../common/cr_api_functions.sh
34 . ../common/rapp_catalogue_api_functions.sh
35
36 #### TEST BEGIN ####
37
38 #Local vars in test script
39 ##########################
40
41 use_cr_https
42 use_agent_rest_https
43 use_sdnc_https
44 use_simulator_https
45 use_ecs_rest_https
46 use_prod_stub_https
47 use_rapp_catalogue_http # https not yet supported
48
49 if [ "$PMS_VERSION" == "V2" ]; then
50     notificationurl=$CR_PATH"/test"
51 else
52    echo "PMS VERSION 2 (V2) is required"
53    exit 1
54 fi
55
56 clean_containers
57
58 STD_NUM_RICS=2
59
60 start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0
61
62 start_mr #Just to prevent errors in the agent log...
63
64 start_control_panel
65
66 start_sdnc
67
68 start_consul_cbs
69
70 prepare_consul_config      SDNC  ".consul_config.json"
71 consul_config_app                  ".consul_config.json"
72
73 start_policy_agent
74
75 start_cr
76
77 start_prod_stub
78
79 start_ecs
80
81 start_rapp_catalogue
82
83 set_agent_trace
84
85 set_ecs_trace
86
87
88 rapp_cat_api_get_services 200 EMPTY
89
90 rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
91
92 rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
93
94 api_get_status 200
95
96 # Print the A1 version for STD 2.X
97 for ((i=1; i<=$STD_NUM_RICS; i++))
98 do
99     sim_print $RIC_SIM_PREFIX"_g3_"$i interface
100 done
101 # Load the polictypes in std
102 for ((i=1; i<=$STD_NUM_RICS; i++))
103 do
104     sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
105     sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
106 done
107
108 #Check the number of schemas and the individual schemas in STD
109 api_equal json:policy-types 2 120
110
111 for ((i=1; i<=$STD_NUM_RICS; i++))
112 do
113     api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
114 done
115
116 # Check the schemas in STD
117 for ((i=1; i<=$STD_NUM_RICS; i++))
118 do
119     api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-agent-modified.json
120     api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-agent-modified.json
121 done
122
123 #Check the number of types
124 api_equal json:policy-types 2 120
125
126 api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1"
127
128 # Create policies in STD
129 for ((i=1; i<=$STD_NUM_RICS; i++))
130 do
131     generate_uuid
132     api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 $((2300+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
133     generate_uuid
134     api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i 'STD_QOS2_0.1.0' $((2400+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
135 done
136
137
138 # Check the number of policies in STD
139 for ((i=1; i<=$STD_NUM_RICS; i++))
140 do
141     sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
142 done
143
144
145
146 FLAT_A1_EI="1"
147
148 CB_JOB="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/job"
149 CB_SV="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/supervision"
150 TARGET1="$RIC_SIM_HTTPX://ricsim_g3_1:$RIC_SIM_PORT/datadelivery"
151 TARGET2="$RIC_SIM_HTTPX://ricsim_g3_2:$RIC_SIM_PORT/datadelivery"
152
153 STATUS1="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job1-status"
154 STATUS2="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job2-status"
155
156 prodstub_arm_producer 200 prod-a
157 prodstub_arm_type 200 prod-a type1
158 prodstub_arm_job_create 200 prod-a job1
159 prodstub_arm_job_create 200 prod-a job2
160
161
162 ### ecs status
163 ecs_api_service_status 200
164
165
166
167 ## Setup prod-a
168 ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
169
170 ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
171
172 ecs_api_edp_get_producer_status 200 prod-a ENABLED
173
174
175 ## Create a job for prod-a
176 ## job1 - prod-a
177 if [  -z "$FLAT_A1_EI" ]; then
178     ecs_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
179 else
180     ecs_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ecs/job-template.json
181 fi
182
183 # Check the job data in the producer
184 prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
185
186
187 ## Create a second job for prod-a
188 ## job2 - prod-a
189 if [  -z "$FLAT_A1_EI" ]; then
190     ecs_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
191 else
192     ecs_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ecs/job-template.json
193 fi
194
195 # Check the job data in the producer
196 prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
197
198
199
200
201 check_policy_agent_logs
202 check_ecs_logs
203 check_sdnc_logs
204
205 #### TEST COMPLETE ####
206
207 store_logs          END
208
209 print_result