Enhanced ECS function tests
[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"
24
25 #SUPPORTED TEST ENV FILE
26 SUPPORTED_PROFILES="ONAP-MASTER ORAN-MASTER"
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
35 #### TEST BEGIN ####
36
37 #Local vars in test script
38 ##########################
39
40 use_cr_https
41 use_agent_rest_https
42 use_sdnc_https
43 use_simulator_https
44 use_ecs_rest_https
45 use_prod_stub_https
46
47 if [ "$PMS_VERSION" == "V2" ]; then
48     notificationurl=$CR_PATH"/test"
49 else
50    echo "PMS VERSION 2 (V2) is required"
51    exit 1
52 fi
53
54 clean_containers
55
56 STD_NUM_RICS=2
57
58 start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0
59
60 start_mr #Just to prevent errors in the agent log...
61
62 start_control_panel
63
64 start_sdnc
65
66 start_consul_cbs
67
68 prepare_consul_config      SDNC  ".consul_config.json"
69 consul_config_app                  ".consul_config.json"
70
71 start_policy_agent
72
73 start_cr
74
75 start_prod_stub
76
77 start_ecs
78
79 set_agent_trace
80
81 set_ecs_trace
82
83 api_get_status 200
84
85 # Print the A1 version for STD 2.X
86 for ((i=1; i<=$STD_NUM_RICS; i++))
87 do
88     sim_print $RIC_SIM_PREFIX"_g3_"$i interface
89 done
90 # Load the polictypes in std
91 for ((i=1; i<=$STD_NUM_RICS; i++))
92 do
93     sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
94     sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
95 done
96
97 #Check the number of schemas and the individual schemas in STD
98 api_equal json:policy-types 2 120
99
100 for ((i=1; i<=$STD_NUM_RICS; i++))
101 do
102     api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
103 done
104
105 # Check the schemas in STD
106 for ((i=1; i<=$STD_NUM_RICS; i++))
107 do
108     api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-agent-modified.json
109     api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-agent-modified.json
110 done
111
112 #Check the number of types
113 api_equal json:policy-types 2 120
114
115 api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1"
116
117 # Create policies in STD
118 for ((i=1; i<=$STD_NUM_RICS; i++))
119 do
120     generate_uuid
121     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
122     generate_uuid
123     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
124 done
125
126
127 # Check the number of policies in STD
128 for ((i=1; i<=$STD_NUM_RICS; i++))
129 do
130     sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
131 done
132
133
134
135 FLAT_A1_EI="1"
136
137 CB_JOB="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/job"
138 CB_SV="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/supervision"
139 TARGET1="$RIC_SIM_HTTPX://ricsim_g3_1:$RIC_SIM_PORT/datadelivery"
140 TARGET2="$RIC_SIM_HTTPX://ricsim_g3_2:$RIC_SIM_PORT/datadelivery"
141
142 STATUS1="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job1-status"
143 STATUS2="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job2-status"
144
145 prodstub_arm_producer 200 prod-a
146 prodstub_arm_type 200 prod-a type1
147 prodstub_arm_job_create 200 prod-a job1
148 prodstub_arm_job_create 200 prod-a job2
149
150
151 ### ecs status
152 ecs_api_service_status 200
153
154
155
156 ## Setup prod-a
157 ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
158
159 ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
160
161 ecs_api_edp_get_producer_status 200 prod-a ENABLED
162
163
164 ## Create a job for prod-a
165 ## job1 - prod-a
166 if [  -z "$FLAT_A1_EI" ]; then
167     ecs_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
168 else
169     ecs_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ecs/job-template.json
170 fi
171
172 # Check the job data in the producer
173 prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 testdata/ecs/job-template.json
174
175
176 ## Create a second job for prod-a
177 ## job2 - prod-a
178 if [  -z "$FLAT_A1_EI" ]; then
179     ecs_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
180 else
181     ecs_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ecs/job-template.json
182 fi
183
184 # Check the job data in the producer
185 prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 testdata/ecs/job-template.json
186
187
188
189
190 check_policy_agent_logs
191 check_ecs_logs
192 check_sdnc_logs
193
194 #### TEST COMPLETE ####
195
196 store_logs          END
197
198 print_result