BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 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 | |
| 21 | TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller" |
| 22 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 23 | #App names to include in the test, space separated list |
| 24 | INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 25 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 26 | . ../common/testcase_common.sh $@ |
| 27 | . ../common/agent_api_functions.sh |
| 28 | . ../common/ricsimulator_api_functions.sh |
| 29 | |
| 30 | #### TEST BEGIN #### |
| 31 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 32 | |
BjornMagnussonXA | ad04778 | 2020-06-08 15:54:11 +0200 | [diff] [blame] | 33 | generate_uuid |
| 34 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 35 | # Tested variants of REST/DMAAP/SDNC config |
| 36 | TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC" |
| 37 | #Test agent and simulator protocol versions (others are http only) |
| 38 | TESTED_PROTOCOLS="HTTP HTTPS" |
| 39 | for __httpx in $TESTED_PROTOCOLS ; do |
| 40 | for interface in $TESTED_VARIANTS ; do |
| 41 | |
| 42 | echo "#####################################################################" |
| 43 | echo "#####################################################################" |
| 44 | echo "### Testing agent: $interface using $__httpx" |
| 45 | echo "#####################################################################" |
| 46 | echo "#####################################################################" |
| 47 | |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 48 | |
| 49 | if [ $__httpx == "HTTPS" ]; then |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 50 | CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks" |
| 51 | use_cr_https |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 52 | use_simulator_https |
| 53 | use_mr_https |
| 54 | if [[ $interface = *"SDNC"* ]]; then |
| 55 | use_sdnc_https |
| 56 | fi |
| 57 | if [[ $interface = *"DMAAP"* ]]; then |
| 58 | use_agent_dmaap_https |
| 59 | else |
| 60 | use_agent_rest_https |
| 61 | fi |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 62 | else |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 63 | CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" |
| 64 | use_cr_http |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 65 | use_simulator_http |
| 66 | use_mr_http |
| 67 | if [[ $interface = *"SDNC"* ]]; then |
| 68 | use_sdnc_http |
| 69 | fi |
| 70 | if [[ $interface = *"DMAAP"* ]]; then |
| 71 | use_agent_dmaap_http |
| 72 | else |
| 73 | use_agent_rest_http |
| 74 | fi |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 75 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 76 | |
| 77 | # Clean container and start all needed containers # |
| 78 | clean_containers |
| 79 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 80 | start_ric_simulators ricsim_g1 1 OSC_2.1.0 |
| 81 | start_ric_simulators ricsim_g2 1 STD_1.1.3 |
| 82 | |
| 83 | start_mr |
| 84 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 85 | start_cr |
| 86 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 87 | start_consul_cbs |
| 88 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 89 | if [[ $interface = *"SDNC"* ]]; then |
| 90 | start_sdnc |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 91 | prepare_consul_config SDNC ".consul_config.json" |
| 92 | else |
| 93 | prepare_consul_config NOSDNC ".consul_config.json" |
| 94 | fi |
| 95 | |
| 96 | consul_config_app ".consul_config.json" |
| 97 | |
| 98 | start_control_panel |
| 99 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 100 | start_policy_agent |
| 101 | |
| 102 | set_agent_debug |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 103 | set_agent_trace |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 104 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 105 | cr_equal received_callbacks 0 |
| 106 | mr_equal requests_submitted 0 |
| 107 | |
| 108 | sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json |
| 109 | |
| 110 | api_equal json:rics 2 60 |
| 111 | |
| 112 | api_equal json:policy_schemas 2 120 |
| 113 | |
| 114 | api_equal json:policy_types 2 |
| 115 | |
| 116 | api_equal json:policies 0 |
| 117 | |
| 118 | api_equal json:policy_ids 0 |
| 119 | |
| 120 | echo "############################################" |
| 121 | echo "############## Health check ################" |
| 122 | echo "############################################" |
| 123 | |
| 124 | api_get_status 200 |
| 125 | |
| 126 | echo "############################################" |
| 127 | echo "##### Service registry and supervision #####" |
| 128 | echo "############################################" |
| 129 | |
| 130 | api_put_service 201 "serv1" 1000 "$CR_PATH/1" |
| 131 | |
| 132 | api_get_service_ids 200 "serv1" |
| 133 | |
| 134 | api_put_services_keepalive 200 "serv1" |
| 135 | |
| 136 | echo "############################################" |
| 137 | echo "############## RIC Repository ##############" |
| 138 | echo "############################################" |
| 139 | |
| 140 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" |
| 141 | |
| 142 | echo "############################################" |
| 143 | echo "########### A1 Policy Management ###########" |
| 144 | echo "############################################" |
| 145 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 146 | api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json |
| 147 | api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 148 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 149 | api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json |
| 150 | api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 151 | |
| 152 | api_delete_policy 204 5000 |
| 153 | |
| 154 | api_delete_policy 204 5100 |
| 155 | |
| 156 | api_equal json:policies 0 |
| 157 | |
| 158 | api_equal json:policy_ids 0 |
| 159 | |
| 160 | cr_equal received_callbacks 0 |
| 161 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 162 | if [[ $interface = *"DMAAP"* ]]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 163 | VAL=11 # Number of Agent API calls over DMAAP |
| 164 | mr_equal requests_fetched $VAL |
| 165 | mr_equal responses_submitted $VAL |
| 166 | mr_equal responses_fetched $VAL |
| 167 | mr_equal current_requests 0 |
| 168 | mr_equal current_responses 0 |
| 169 | else |
| 170 | mr_equal requests_submitted 0 |
| 171 | fi |
| 172 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 173 | if [[ $interface = *"SDNC"* ]]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 174 | sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" |
| 175 | sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" |
| 176 | else |
| 177 | sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" |
| 178 | sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" |
| 179 | fi |
| 180 | |
| 181 | check_policy_agent_logs |
| 182 | check_control_panel_logs |
| 183 | |
| 184 | store_logs "${__httpx}__${interface}" |
| 185 | |
| 186 | done |
| 187 | |
| 188 | done |
| 189 | |
| 190 | #### TEST COMPLETE #### |
| 191 | |
| 192 | |
| 193 | print_result |
| 194 | |
| 195 | auto_clean_containers |