BjornMagnussonXA | 80a9200 | 2020-03-19 14:31:06 +0100 | [diff] [blame] | 1 | #!/usr/bin/env 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="Repeatedly create and delete 10000 policies in each RICs for 24h. Via agent REST" |
| 21 | |
| 22 | . ../common/testcase_common.sh $@ |
| 23 | . ../common/agent_api_functions.sh |
| 24 | . ../common/ricsimulator_api_functions.sh |
| 25 | |
| 26 | #### TEST BEGIN #### |
| 27 | |
| 28 | #Local vars in test script |
| 29 | ########################## |
| 30 | # Path to callback receiver |
| 31 | CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" |
| 32 | # Number of RICs per interface type (OSC and STD) |
| 33 | NUM_RICS=4 |
| 34 | # Number of policy instances per RIC |
| 35 | NUM_INSTANCES=10000 |
| 36 | |
| 37 | clean_containers |
| 38 | |
| 39 | start_ric_simulators ricsim_g1 4 OSC_2.1.0 |
| 40 | |
| 41 | start_ric_simulators ricsim_g2 4 STD_1.1.3 |
| 42 | |
| 43 | start_mr |
| 44 | |
| 45 | start_cr |
| 46 | |
| 47 | start_consul_cbs |
| 48 | |
| 49 | prepare_consul_config NOSDNC ".consul_config.json" |
| 50 | consul_config_app ".consul_config.json" |
| 51 | |
| 52 | start_control_panel |
| 53 | |
| 54 | start_policy_agent |
| 55 | |
| 56 | use_agent_rest |
| 57 | |
| 58 | api_get_status 200 |
| 59 | |
| 60 | echo "Print the interface for group 1 simulators, shall be OSC" |
| 61 | for ((i=1; i<=$NUM_RICS; i++)) |
| 62 | do |
| 63 | sim_print ricsim_g1_$i interface |
| 64 | done |
| 65 | |
| 66 | echo "Print the interface for group 2 simulators, shall be STD" |
| 67 | for ((i=1; i<=$NUM_RICS; i++)) |
| 68 | do |
| 69 | sim_print ricsim_g2_$i interface |
| 70 | done |
| 71 | |
| 72 | echo "Load policy type in group 1 simulators" |
| 73 | for ((i=1; i<=$NUM_RICS; i++)) |
| 74 | do |
| 75 | sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json |
| 76 | done |
| 77 | |
| 78 | echo "Check the number of instances in group 1 simulators, shall be 0" |
| 79 | for ((i=1; i<=$NUM_RICS; i++)) |
| 80 | do |
| 81 | sim_equal ricsim_g1_$i num_instances 0 |
| 82 | done |
| 83 | |
| 84 | echo "Check the number of instances in group 2 simulators, shall be 0" |
| 85 | for ((i=1; i<=$NUM_RICS; i++)) |
| 86 | do |
| 87 | sim_equal ricsim_g2_$i num_instances 0 |
| 88 | done |
| 89 | |
| 90 | echo "Wait for the agent to refresh types from the simulator" |
| 91 | api_equal json:policy_types 2 120 |
| 92 | |
| 93 | echo "Check the number of types in the agent for each ric is 1" |
| 94 | for ((i=1; i<=$NUM_RICS; i++)) |
| 95 | do |
| 96 | api_equal json:policy_types?ric=ricsim_g1_$i 1 120 |
| 97 | done |
| 98 | |
| 99 | echo "Register a service" |
| 100 | api_put_service 201 "rapp1" 0 "$CR_PATH/1" |
| 101 | |
| 102 | TEST_DURATION=$((24*3600)) |
| 103 | TEST_START=$SECONDS |
| 104 | |
| 105 | while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do |
| 106 | |
| 107 | echo "" |
| 108 | echo "#########################################################################################################" |
| 109 | echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds (24h)."$EBOLD |
| 110 | echo "#########################################################################################################" |
| 111 | echo "" |
| 112 | |
| 113 | |
| 114 | echo "Create 10000 instances in each OSC RIC" |
| 115 | INSTANCE_ID=200000 |
| 116 | INSTANCES=0 |
| 117 | for ((i=1; i<=$NUM_RICS; i++)) |
| 118 | do |
| 119 | api_put_policy 201 "rapp1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES |
| 120 | sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES |
| 121 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 122 | INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) |
| 123 | done |
| 124 | |
| 125 | api_equal json:policy_ids $INSTANCES |
| 126 | |
| 127 | echo "Create 10000 instances in each OSC RIC" |
| 128 | for ((i=1; i<=$NUM_RICS; i++)) |
| 129 | do |
| 130 | api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES |
| 131 | sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES |
| 132 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 133 | INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) |
| 134 | done |
| 135 | |
| 136 | api_equal json:policy_ids $INSTANCES |
| 137 | |
| 138 | |
| 139 | echo "Delete all instances in each OSC RIC" |
| 140 | |
| 141 | INSTANCE_ID=200000 |
| 142 | for ((i=1; i<=$NUM_RICS; i++)) |
| 143 | do |
| 144 | api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES |
| 145 | INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) |
| 146 | sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES |
| 147 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 148 | done |
| 149 | |
| 150 | api_equal json:policy_ids $INSTANCES |
| 151 | |
| 152 | echo "Delete all instances in each STD RIC" |
| 153 | INSTANCE_ID=200000 |
| 154 | for ((i=1; i<=$NUM_RICS; i++)) |
| 155 | do |
| 156 | api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES |
| 157 | INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) |
| 158 | sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES |
| 159 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 160 | done |
| 161 | |
| 162 | api_equal json:policy_ids 0 |
| 163 | done |
| 164 | |
| 165 | |
| 166 | check_policy_agent_logs |
| 167 | |
| 168 | #### TEST COMPLETE #### |
| 169 | |
| 170 | store_logs END |
| 171 | |
| 172 | print_result |