blob: 9600f4ad70a26e7dfeee1557cbe41304c8765513 [file] [log] [blame]
BjornMagnussonXA80a92002020-03-19 14:31:06 +01001#!/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
20TC_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
31CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
32# Number of RICs per interface type (OSC and STD)
33NUM_RICS=4
34# Number of policy instances per RIC
35NUM_INSTANCES=10000
36
37clean_containers
38
39start_ric_simulators ricsim_g1 4 OSC_2.1.0
40
41start_ric_simulators ricsim_g2 4 STD_1.1.3
42
43start_mr
44
45start_cr
46
47start_consul_cbs
48
49prepare_consul_config NOSDNC ".consul_config.json"
50consul_config_app ".consul_config.json"
51
52start_control_panel
53
54start_policy_agent
55
BjornMagnussonXA72667f12020-04-24 09:20:18 +020056use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010057
58api_get_status 200
59
60echo "Print the interface for group 1 simulators, shall be OSC"
61for ((i=1; i<=$NUM_RICS; i++))
62do
63 sim_print ricsim_g1_$i interface
64done
65
66echo "Print the interface for group 2 simulators, shall be STD"
67for ((i=1; i<=$NUM_RICS; i++))
68do
69 sim_print ricsim_g2_$i interface
70done
71
72echo "Load policy type in group 1 simulators"
73for ((i=1; i<=$NUM_RICS; i++))
74do
75 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
76done
77
78echo "Check the number of instances in group 1 simulators, shall be 0"
79for ((i=1; i<=$NUM_RICS; i++))
80do
81 sim_equal ricsim_g1_$i num_instances 0
82done
83
84echo "Check the number of instances in group 2 simulators, shall be 0"
85for ((i=1; i<=$NUM_RICS; i++))
86do
87 sim_equal ricsim_g2_$i num_instances 0
88done
89
90echo "Wait for the agent to refresh types from the simulator"
91api_equal json:policy_types 2 120
92
93echo "Check the number of types in the agent for each ric is 1"
94for ((i=1; i<=$NUM_RICS; i++))
95do
96 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
97done
98
99echo "Register a service"
100api_put_service 201 "rapp1" 0 "$CR_PATH/1"
101
102TEST_DURATION=$((24*3600))
103TEST_START=$SECONDS
104
105while [ $(($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
163done
164
165
166check_policy_agent_logs
167
168#### TEST COMPLETE ####
169
170store_logs END
171
172print_result