Merge "Adding owner to jobInfo"
[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-MASTER ORAN-CHERRY"
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_rapp_catalogue
76
77 start_cr
78
79 start_prod_stub
80
81 start_ecs
82
83 start_rapp_catalogue
84
85 set_agent_trace
86
87 set_ecs_trace
88
89
90 rapp_cat_api_get_services 200 EMPTY
91
92 rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
93
94 rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
95
96 api_get_status 200
97
98 # Print the A1 version for STD 2.X
99 for ((i=1; i<=$STD_NUM_RICS; i++))
100 do
101     sim_print $RIC_SIM_PREFIX"_g3_"$i interface
102 done
103 # Load the polictypes in std
104 for ((i=1; i<=$STD_NUM_RICS; i++))
105 do
106     sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
107     sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
108 done
109
110 #Check the number of schemas and the individual schemas in STD
111 api_equal json:policy-types 2 120
112
113 for ((i=1; i<=$STD_NUM_RICS; i++))
114 do
115     api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
116 done
117
118 # Check the schemas in STD
119 for ((i=1; i<=$STD_NUM_RICS; i++))
120 do
121     api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-agent-modified.json
122     api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-agent-modified.json
123 done
124
125 #Check the number of types
126 api_equal json:policy-types 2 120
127
128 api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1"
129
130 # Create policies in STD
131 for ((i=1; i<=$STD_NUM_RICS; i++))
132 do
133     generate_uuid
134     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
135     generate_uuid
136     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
137 done
138
139
140 # Check the number of policies in STD
141 for ((i=1; i<=$STD_NUM_RICS; i++))
142 do
143     sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
144 done
145
146
147
148 FLAT_A1_EI="1"
149
150 CB_JOB="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/job"
151 CB_SV="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/supervision"
152 TARGET1="$RIC_SIM_HTTPX://ricsim_g3_1:$RIC_SIM_PORT/datadelivery"
153 TARGET2="$RIC_SIM_HTTPX://ricsim_g3_2:$RIC_SIM_PORT/datadelivery"
154
155 STATUS1="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job1-status"
156 STATUS2="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job2-status"
157
158 prodstub_arm_producer 200 prod-a
159 prodstub_arm_type 200 prod-a type1
160 prodstub_arm_job_create 200 prod-a job1
161 prodstub_arm_job_create 200 prod-a job2
162
163
164 ### ecs status
165 ecs_api_service_status 200
166
167
168
169 ## Setup prod-a
170 ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
171
172 ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
173
174 ecs_api_edp_get_producer_status 200 prod-a ENABLED
175
176
177 ## Create a job for prod-a
178 ## job1 - prod-a
179 if [  -z "$FLAT_A1_EI" ]; then
180     ecs_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
181 else
182     ecs_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ecs/job-template.json
183 fi
184
185 # Check the job data in the producer
186 prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 testdata/ecs/job-template.json
187
188
189 ## Create a second job for prod-a
190 ## job2 - prod-a
191 if [  -z "$FLAT_A1_EI" ]; then
192     ecs_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
193 else
194     ecs_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ecs/job-template.json
195 fi
196
197 # Check the job data in the producer
198 prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 testdata/ecs/job-template.json
199
200
201
202
203 check_policy_agent_logs
204 check_ecs_logs
205 check_sdnc_logs
206
207 #### TEST COMPLETE ####
208
209 store_logs          END
210
211 print_result