blob: 771ee55535b6ceb05b10ae7efc484781afbe35b2 [file] [log] [blame]
BjornMagnussonXA70e878f2020-05-11 14:11:30 +02001#!/bin/bash
BjornMagnussonXA80a92002020-03-19 14:31:06 +01002
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
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020020TC_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"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010021
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020022#App names to exclude checking pulling images for, space separated list
23EXCLUDED_IMAGES="SDNC SDNC_ONAP"
24
BjornMagnussonXA80a92002020-03-19 14:31:06 +010025. ../common/testcase_common.sh $@
26. ../common/agent_api_functions.sh
BjornMagnussonXA72667f12020-04-24 09:20:18 +020027. ../common/ricsimulator_api_functions.sh
BjornMagnussonXA80a92002020-03-19 14:31:06 +010028
29#### TEST BEGIN ####
30
31#Local vars in test script
32##########################
33# Path to callback receiver
34CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
35
36clean_containers
37
38start_ric_simulators ricsim_g1 3 OSC_2.1.0
39
40start_ric_simulators ricsim_g2 5 STD_1.1.3
41
42start_mr
43
44start_cr
45
46start_consul_cbs
47
48prepare_consul_config NOSDNC ".consul_config.json"
49consul_config_app ".consul_config.json"
50
51start_control_panel
52
BjornMagnussonXA80a92002020-03-19 14:31:06 +010053start_policy_agent
54
BjornMagnussonXA72667f12020-04-24 09:20:18 +020055set_agent_debug
56
57use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010058
59api_get_status 200
60
61sim_print ricsim_g1_1 interface
62
63sim_print ricsim_g2_1 interface
64
65sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
66
67api_equal json:policy_types 2 60
68
69
70# Create policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +020071use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010072
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020073api_put_service 201 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010074
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020075api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010076
77sim_equal ricsim_g1_1 num_instances 1
78
79
80use_agent_dmaap
81
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020082api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010083
84sim_equal ricsim_g1_1 num_instances 2
85
86
BjornMagnussonXA72667f12020-04-24 09:20:18 +020087use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010088
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020089api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010090
91sim_equal ricsim_g2_1 num_instances 1
92
93
94use_agent_dmaap
95
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020096api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010097
98sim_equal ricsim_g2_1 num_instances 2
99
100
101#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200102use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100103
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200104api_put_service 200 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100105
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200106api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100107
108sim_equal ricsim_g1_1 num_instances 2
109
110
111use_agent_dmaap
112
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200113api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100114
115sim_equal ricsim_g1_1 num_instances 2
116
117
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200118use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100119
120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200121api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100122
123sim_equal ricsim_g2_1 num_instances 2
124
125
126use_agent_dmaap
127
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200128api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100129
130sim_equal ricsim_g2_1 num_instances 2
131
132# Check policies
133api_get_policy 200 2000 testdata/OSC/pi1_template.json
134api_get_policy 200 3000 testdata/OSC/pi1_template.json
135api_get_policy 200 2100 testdata/STD/pi1_template.json
136api_get_policy 200 3100 testdata/STD/pi1_template.json
137
138# Remove policies
139
140use_agent_dmaap
141api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200142use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100143api_delete_policy 204 3000
144use_agent_dmaap
145api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200146use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100147api_delete_policy 204 3100
148
149sim_equal ricsim_g1_1 num_instances 0
150sim_equal ricsim_g2_1 num_instances 0
151
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200152# Check remote host access to simulator
153
154sim_contains_ste ricsim_g1_1 hosts "policy-agent"
155sim_contains_ste ricsim_g2_1 hosts "policy-agent"
156
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100157# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200158use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100159api_get_policy 404 2000
160api_get_policy 404 3000
161api_get_policy 404 2100
162api_get_policy 404 3100
163
164# Remove the service
165use_agent_dmaap
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200166api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100167
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200168api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100169
170
171
172check_policy_agent_logs
173
174#### TEST COMPLETE ####
175
176store_logs END
177
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200178print_result
179
180auto_clean_containers