Merge "Integrated PMS 2.0 to test env and test cases"
[nonrtric.git] / test / auto-test / FTC10.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 TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap"
21
22 #App names to include in the test, space separated list
23 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
24
25 . ../common/testcase_common.sh $@
26 . ../common/agent_api_functions.sh
27 . ../common/ricsimulator_api_functions.sh
28
29 #### TEST BEGIN ####
30
31 generate_uuid
32
33 #Local vars in test script
34 ##########################
35 # Path to callback receiver
36 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
37
38 use_cr_http
39 use_simulator_http
40 use_mr_http
41 use_agent_rest_http
42
43
44 clean_containers
45
46 start_ric_simulators  ricsim_g1 3 OSC_2.1.0
47
48 start_ric_simulators  ricsim_g2 5 STD_1.1.3
49
50 if [ "$PMS_VERSION" == "V2" ]; then
51     start_ric_simulators ricsim_g3 1  STD_2.0.0
52 fi
53
54 start_mr
55
56 start_cr
57
58 start_consul_cbs
59
60 prepare_consul_config      NOSDNC  ".consul_config.json"
61 consul_config_app                  ".consul_config.json"
62
63 start_control_panel
64
65 start_policy_agent
66
67 set_agent_debug
68
69 use_agent_rest_http
70
71 api_get_status 200
72
73 sim_print ricsim_g1_1 interface
74
75 sim_print ricsim_g2_1 interface
76
77 if [ "$PMS_VERSION" == "V2" ]; then
78     sim_print ricsim_g3_1 interface
79 fi
80
81 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
82
83 if [ "$PMS_VERSION" == "V2" ]; then
84     api_equal json:policy-types 2 60
85 else
86     api_equal json:policy_types 2 60
87 fi
88
89 # Create policies
90
91 if [ "$PMS_VERSION" == "V2" ]; then
92     notificationurl="http://localhost:80"
93 else
94     notificationurl=""
95 fi
96
97 use_agent_rest_http
98
99 api_put_service 201 "service1" 3600 "$CR_PATH/1"
100
101 api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
102
103 sim_equal ricsim_g1_1 num_instances 1
104
105
106 use_agent_dmaap_http
107
108 api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
109
110 sim_equal ricsim_g1_1 num_instances 2
111
112
113 use_agent_rest_http
114
115 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
116
117 sim_equal ricsim_g2_1 num_instances 1
118
119
120 use_agent_dmaap_http
121
122 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
123
124 sim_equal ricsim_g2_1 num_instances 2
125
126
127 #Update policies
128 use_agent_rest_http
129
130 api_put_service 200 "service1" 3600 "$CR_PATH/1"
131
132 api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
133
134 sim_equal ricsim_g1_1 num_instances 2
135
136
137 use_agent_dmaap_http
138
139 api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
140
141 sim_equal ricsim_g1_1 num_instances 2
142
143
144 use_agent_rest_http
145
146
147 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
148
149 sim_equal ricsim_g2_1 num_instances 2
150
151
152 use_agent_dmaap_http
153
154 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
155
156 sim_equal ricsim_g2_1 num_instances 2
157
158 # Check policies
159 if [ "$PMS_VERSION" == "V2" ]; then
160     api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
161     api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
162     api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
163     api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
164 else
165     api_get_policy 200 2000 testdata/OSC/pi1_template.json
166     api_get_policy 200 3000 testdata/OSC/pi1_template.json
167     api_get_policy 200 2100 testdata/STD/pi1_template.json
168     api_get_policy 200 3100 testdata/STD/pi1_template.json
169 fi
170
171 # Remove policies
172
173 use_agent_dmaap_http
174 api_delete_policy 204 2000
175 use_agent_rest_http
176 api_delete_policy 204 3000
177 use_agent_dmaap_http
178 api_delete_policy 204 2100
179 use_agent_rest_http
180 api_delete_policy 204 3100
181
182 sim_equal ricsim_g1_1 num_instances 0
183 sim_equal ricsim_g2_1 num_instances 0
184
185 if [ "$PMS_VERSION" == "V2" ]; then
186     sim_equal ricsim_g3_1 num_instances 0
187 fi
188
189 # Check remote host access to simulator
190
191 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
192 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
193 if [ "$PMS_VERSION" == "V2" ]; then
194     sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
195 fi
196
197 # Check policy removal
198 use_agent_rest_http
199 api_get_policy 404 2000
200 api_get_policy 404 3000
201 api_get_policy 404 2100
202 api_get_policy 404 3100
203
204 # Remove the service
205 use_agent_dmaap_http
206 api_delete_services 204 "service1"
207
208 api_get_services 404 "service1"
209
210
211
212 check_policy_agent_logs
213
214 #### TEST COMPLETE ####
215
216 store_logs          END
217
218 print_result
219
220 auto_clean_containers