Merge changes Id5e8969d,I56437e93
[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 exclude checking pulling images for, space separated list
23 EXCLUDED_IMAGES="SDNC SDNC_ONAP"
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 use_cr_http
38
39 clean_containers
40
41 start_ric_simulators  ricsim_g1 3 OSC_2.1.0
42
43 start_ric_simulators  ricsim_g2 5 STD_1.1.3
44
45 start_mr
46
47 start_cr
48
49 start_consul_cbs
50
51 prepare_consul_config      NOSDNC  ".consul_config.json"
52 consul_config_app                  ".consul_config.json"
53
54 start_control_panel
55
56 start_policy_agent
57
58 set_agent_debug
59
60 use_agent_rest_http
61
62 api_get_status 200
63
64 sim_print ricsim_g1_1 interface
65
66 sim_print ricsim_g2_1 interface
67
68 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
69
70 api_equal json:policy_types 2 60
71
72
73 # Create policies
74 use_agent_rest_http
75
76 api_put_service 201 "service1" 3600 "$CR_PATH/1"
77
78 api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
79
80 sim_equal ricsim_g1_1 num_instances 1
81
82
83 use_agent_dmaap_http
84
85 api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
86
87 sim_equal ricsim_g1_1 num_instances 2
88
89
90 use_agent_rest_http
91
92 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
93
94 sim_equal ricsim_g2_1 num_instances 1
95
96
97 use_agent_dmaap_http
98
99 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
100
101 sim_equal ricsim_g2_1 num_instances 2
102
103
104 #Update policies
105 use_agent_rest_http
106
107 api_put_service 200 "service1" 3600 "$CR_PATH/1"
108
109 api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
110
111 sim_equal ricsim_g1_1 num_instances 2
112
113
114 use_agent_dmaap_http
115
116 api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
117
118 sim_equal ricsim_g1_1 num_instances 2
119
120
121 use_agent_rest_http
122
123
124 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
125
126 sim_equal ricsim_g2_1 num_instances 2
127
128
129 use_agent_dmaap_http
130
131 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
132
133 sim_equal ricsim_g2_1 num_instances 2
134
135 # Check policies
136 api_get_policy 200 2000 testdata/OSC/pi1_template.json
137 api_get_policy 200 3000 testdata/OSC/pi1_template.json
138 api_get_policy 200 2100 testdata/STD/pi1_template.json
139 api_get_policy 200 3100 testdata/STD/pi1_template.json
140
141 # Remove policies
142
143 use_agent_dmaap_http
144 api_delete_policy 204 2000
145 use_agent_rest_http
146 api_delete_policy 204 3000
147 use_agent_dmaap_http
148 api_delete_policy 204 2100
149 use_agent_rest_http
150 api_delete_policy 204 3100
151
152 sim_equal ricsim_g1_1 num_instances 0
153 sim_equal ricsim_g2_1 num_instances 0
154
155 # Check remote host access to simulator
156
157 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
158 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
159
160 # Check policy removal
161 use_agent_rest_http
162 api_get_policy 404 2000
163 api_get_policy 404 3000
164 api_get_policy 404 2100
165 api_get_policy 404 3100
166
167 # Remove the service
168 use_agent_dmaap_http
169 api_delete_services 204 "service1"
170
171 api_get_services 404 "service1"
172
173
174
175 check_policy_agent_logs
176
177 #### TEST COMPLETE ####
178
179 store_logs          END
180
181 print_result
182
183 auto_clean_containers