BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 1 | #!/bin/bash |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 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 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 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" |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 21 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 22 | #App names to include in the test, space separated list |
| 23 | INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 24 | |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame^] | 25 | #SUPPORTED TEST ENV FILE |
| 26 | SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-MASTER" |
| 27 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 28 | . ../common/testcase_common.sh $@ |
| 29 | . ../common/agent_api_functions.sh |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 30 | . ../common/ricsimulator_api_functions.sh |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 31 | |
| 32 | #### TEST BEGIN #### |
| 33 | |
BjornMagnussonXA | ad04778 | 2020-06-08 15:54:11 +0200 | [diff] [blame] | 34 | generate_uuid |
| 35 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 36 | use_simulator_http |
| 37 | use_mr_http |
| 38 | use_agent_rest_http |
| 39 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 40 | |
| 41 | clean_containers |
| 42 | |
| 43 | start_ric_simulators ricsim_g1 3 OSC_2.1.0 |
| 44 | |
| 45 | start_ric_simulators ricsim_g2 5 STD_1.1.3 |
| 46 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 47 | if [ "$PMS_VERSION" == "V2" ]; then |
| 48 | start_ric_simulators ricsim_g3 1 STD_2.0.0 |
| 49 | fi |
| 50 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 51 | start_mr |
| 52 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 53 | start_consul_cbs |
| 54 | |
| 55 | prepare_consul_config NOSDNC ".consul_config.json" |
| 56 | consul_config_app ".consul_config.json" |
| 57 | |
| 58 | start_control_panel |
| 59 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 60 | start_policy_agent |
| 61 | |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 62 | set_agent_debug |
| 63 | |
| 64 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 65 | |
| 66 | api_get_status 200 |
| 67 | |
| 68 | sim_print ricsim_g1_1 interface |
| 69 | |
| 70 | sim_print ricsim_g2_1 interface |
| 71 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 72 | if [ "$PMS_VERSION" == "V2" ]; then |
| 73 | sim_print ricsim_g3_1 interface |
| 74 | fi |
| 75 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 76 | sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json |
| 77 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 78 | if [ "$PMS_VERSION" == "V2" ]; then |
| 79 | api_equal json:policy-types 2 60 |
| 80 | else |
| 81 | api_equal json:policy_types 2 60 |
| 82 | fi |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 83 | |
| 84 | # Create policies |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 85 | |
| 86 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame^] | 87 | notificationurl=$CR_PATH"/test" |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 88 | else |
| 89 | notificationurl="" |
| 90 | fi |
| 91 | |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 92 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 93 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 94 | api_put_service 201 "service1" 3600 "$CR_PATH/1" |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 95 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 96 | api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 97 | |
| 98 | sim_equal ricsim_g1_1 num_instances 1 |
| 99 | |
| 100 | |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 101 | use_agent_dmaap_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 102 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 103 | api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 104 | |
| 105 | sim_equal ricsim_g1_1 num_instances 2 |
| 106 | |
| 107 | |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 108 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 109 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 110 | api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 111 | |
| 112 | sim_equal ricsim_g2_1 num_instances 1 |
| 113 | |
| 114 | |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 115 | use_agent_dmaap_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 116 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 117 | api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 118 | |
| 119 | sim_equal ricsim_g2_1 num_instances 2 |
| 120 | |
| 121 | |
| 122 | #Update policies |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 123 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 124 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 125 | api_put_service 200 "service1" 3600 "$CR_PATH/1" |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 126 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 127 | api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 128 | |
| 129 | sim_equal ricsim_g1_1 num_instances 2 |
| 130 | |
| 131 | |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 132 | use_agent_dmaap_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 133 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 134 | api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 135 | |
| 136 | sim_equal ricsim_g1_1 num_instances 2 |
| 137 | |
| 138 | |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 139 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 140 | |
| 141 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 142 | api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 143 | |
| 144 | sim_equal ricsim_g2_1 num_instances 2 |
| 145 | |
| 146 | |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 147 | use_agent_dmaap_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 148 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 149 | api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 150 | |
| 151 | sim_equal ricsim_g2_1 num_instances 2 |
| 152 | |
| 153 | # Check policies |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 154 | if [ "$PMS_VERSION" == "V2" ]; then |
| 155 | api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl |
| 156 | api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl |
| 157 | api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl |
| 158 | api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl |
| 159 | else |
| 160 | api_get_policy 200 2000 testdata/OSC/pi1_template.json |
| 161 | api_get_policy 200 3000 testdata/OSC/pi1_template.json |
| 162 | api_get_policy 200 2100 testdata/STD/pi1_template.json |
| 163 | api_get_policy 200 3100 testdata/STD/pi1_template.json |
| 164 | fi |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 165 | |
| 166 | # Remove policies |
| 167 | |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 168 | use_agent_dmaap_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 169 | api_delete_policy 204 2000 |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 170 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 171 | api_delete_policy 204 3000 |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 172 | use_agent_dmaap_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 173 | api_delete_policy 204 2100 |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 174 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 175 | api_delete_policy 204 3100 |
| 176 | |
| 177 | sim_equal ricsim_g1_1 num_instances 0 |
| 178 | sim_equal ricsim_g2_1 num_instances 0 |
| 179 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 180 | if [ "$PMS_VERSION" == "V2" ]; then |
| 181 | sim_equal ricsim_g3_1 num_instances 0 |
| 182 | fi |
| 183 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 184 | # Check remote host access to simulator |
| 185 | |
ecaiyanlinux | c8ccab1 | 2020-06-09 13:29:53 +0200 | [diff] [blame] | 186 | sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" |
| 187 | sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 188 | if [ "$PMS_VERSION" == "V2" ]; then |
| 189 | sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" |
| 190 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 191 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 192 | # Check policy removal |
BjornMagnussonXA | 72667f1 | 2020-04-24 09:20:18 +0200 | [diff] [blame] | 193 | use_agent_rest_http |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 194 | api_get_policy 404 2000 |
| 195 | api_get_policy 404 3000 |
| 196 | api_get_policy 404 2100 |
| 197 | api_get_policy 404 3100 |
| 198 | |
| 199 | # Remove the service |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 200 | use_agent_dmaap_http |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 201 | api_delete_services 204 "service1" |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 202 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 203 | api_get_services 404 "service1" |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 204 | |
BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 205 | check_policy_agent_logs |
| 206 | |
| 207 | #### TEST COMPLETE #### |
| 208 | |
| 209 | store_logs END |
| 210 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 211 | print_result |
| 212 | |
| 213 | auto_clean_containers |