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