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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
20 TC_ONELINE_DESCR="Create and delete 50 policies in each 50 RICs, 25 STD version, 25 OSC version. Via agent REST"
22 . ../common/testcase_common.sh $@
23 . ../common/agent_api_functions.sh
24 . ../common/ricsimulator_api_functions.sh
28 #Local vars in test script
29 ##########################
30 # Path to callback receiver
31 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
34 # Number of instances per RIC
37 # Clean and start all containers
40 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
42 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
50 prepare_consul_config NOSDNC ".consul_config.json"
51 consul_config_app ".consul_config.json"
63 echo "Checking agent is alive"
67 echo "Print the interface for group 1 simulators, shall be OSC"
68 for ((i=1; i<=$NUM_RICS; i++))
70 sim_print ricsim_g1_$i interface
73 echo "Print the interface for group 2 simulators, shall be STD"
74 for ((i=1; i<=$NUM_RICS; i++))
76 sim_print ricsim_g2_$i interface
79 echo "Checking the number of policy instances in each group 1 simulator, shall be 0"
80 for ((i=1; i<=$NUM_RICS; i++))
82 sim_equal ricsim_g1_$i num_instances 0
85 echo "Checking the number of policy instances in each group 2 simulator, shall be 0"
86 for ((i=1; i<=$NUM_RICS; i++))
88 sim_equal ricsim_g1_$i num_instances 0
91 echo "Load policy type 1 in each group 1 simulator"
92 for ((i=1; i<=$NUM_RICS; i++))
94 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
97 echo "Checking the number of policy types in each group 1 simulator, shall be 1"
98 for ((i=1; i<=$NUM_RICS; i++))
100 sim_equal ricsim_g1_$i num_types 1
103 echo "Checking the number of policy types in each group 2 simulator, shall be 0"
104 for ((i=1; i<=$NUM_RICS; i++))
106 sim_equal ricsim_g2_$i num_types 0
109 echo "Check the number of rics, shall be the configured number: ""$(($NUM_RICS*2))"
110 api_equal json:rics "$(($NUM_RICS*2))" 120
112 api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator
114 sleep_wait 120 "Wait for the agent to refresh the types from all rics"
116 echo "Check the number of types in the agent for each group 1 rics, shall be 1"
117 for ((i=1; i<=$NUM_RICS; i++))
119 api_equal json:policy_types?ric=ricsim_g1_$i 1
122 echo "Check the number of types in the agent for each group 2 rics, shall be 1"
123 for ((i=1; i<=$NUM_RICS; i++))
125 api_equal json:policy_types?ric=ricsim_g2_$i 1
128 echo "Register the service"
129 api_put_service 201 "rapp1" 0 "$CR_PATH/1"
131 echo "Loading "$NUM_INST" policies in each group 1 ric"
132 for ((i=1; i<=$NUM_RICS; i++))
134 inst=$((1000000+$i*$NUM_INST))
135 api_put_policy 201 "rapp1" ricsim_g1_$i 1 $inst testdata/OSC/pi1_template.json $NUM_INST
138 echo "Loading "$NUM_INST" policies in each group 2 ric"
139 for ((i=1; i<=$NUM_RICS; i++))
141 inst=$((2000000+$i*$NUM_INST))
142 api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $inst testdata/STD/pi1_template.json $NUM_INST
145 echo "Check the number of types in the agent for each group 1 rics, shall be 1"
146 for ((i=1; i<=$NUM_RICS; i++))
148 api_equal json:policy_types?ric=ricsim_g1_$i 1
151 echo "Check the number of types in the agent for each group 2 rics, shall be 1"
152 for ((i=1; i<=$NUM_RICS; i++))
154 api_equal json:policy_types?ric=ricsim_g2_$i 1
157 echo "Checking the number of policy instances in each group 1 simulator, shall be "$NUM_INST
158 for ((i=1; i<=$NUM_RICS; i++))
160 sim_equal ricsim_g1_$i num_instances 50
163 echo "Checking the number of policy instances in each group 2 simulator, shall be "$NUM_INST
164 for ((i=1; i<=$NUM_RICS; i++))
166 sim_equal ricsim_g2_$i num_instances 50
169 echo "Deleting "$NUM_INST" policies in each group 1 ric"
170 for ((i=1; i<=$NUM_RICS; i++))
172 inst=$((1000000+$i*$NUM_INST))
173 api_delete_policy 201 $NUM_INST
176 echo "Deleting "$NUM_INST" policies in each group 2 ric"
177 for ((i=1; i<=$NUM_RICS; i++))
179 inst=$((2000000+$i*$NUM_INST))
180 api_delete_policy 201 $NUM_INST
183 echo "Checking the number of policy instances in each group 1 simulator, shall be 0"
184 for ((i=1; i<=$NUM_RICS; i++))
186 sim_equal ricsim_g1_$i num_instances 50
189 echo "Checking the number of policy instances in each group 1 simulator, shall be 0"
190 for ((i=1; i<=$NUM_RICS; i++))
192 sim_equal ricsim_g2_$i num_instances 50
196 check_policy_agent_logs
198 #### TEST COMPLETE ####