blob: eaa6de29bc784c84f6166a52665ccf13812ab019 [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
BjornMagnussonXAad047782020-06-08 15:54:11 +020031generate_uuid
32
BjornMagnussonXA80a92002020-03-19 14:31:06 +010033#Local vars in test script
34##########################
35# Path to callback receiver
36CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
37
38clean_containers
39
40start_ric_simulators ricsim_g1 3 OSC_2.1.0
41
42start_ric_simulators ricsim_g2 5 STD_1.1.3
43
44start_mr
45
46start_cr
47
48start_consul_cbs
49
50prepare_consul_config NOSDNC ".consul_config.json"
51consul_config_app ".consul_config.json"
52
53start_control_panel
54
BjornMagnussonXA80a92002020-03-19 14:31:06 +010055start_policy_agent
56
BjornMagnussonXA72667f12020-04-24 09:20:18 +020057set_agent_debug
58
59use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010060
61api_get_status 200
62
63sim_print ricsim_g1_1 interface
64
65sim_print ricsim_g2_1 interface
66
67sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
68
69api_equal json:policy_types 2 60
70
71
72# Create policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +020073use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010074
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020075api_put_service 201 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010076
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020077api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010078
79sim_equal ricsim_g1_1 num_instances 1
80
81
82use_agent_dmaap
83
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020084api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010085
86sim_equal ricsim_g1_1 num_instances 2
87
88
BjornMagnussonXA72667f12020-04-24 09:20:18 +020089use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010090
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020091api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010092
93sim_equal ricsim_g2_1 num_instances 1
94
95
96use_agent_dmaap
97
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020098api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010099
100sim_equal ricsim_g2_1 num_instances 2
101
102
103#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200104use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100105
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200106api_put_service 200 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100107
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200108api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100109
110sim_equal ricsim_g1_1 num_instances 2
111
112
113use_agent_dmaap
114
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200115api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100116
117sim_equal ricsim_g1_1 num_instances 2
118
119
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200120use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100121
122
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200123api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100124
125sim_equal ricsim_g2_1 num_instances 2
126
127
128use_agent_dmaap
129
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200130api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100131
132sim_equal ricsim_g2_1 num_instances 2
133
134# Check policies
135api_get_policy 200 2000 testdata/OSC/pi1_template.json
136api_get_policy 200 3000 testdata/OSC/pi1_template.json
137api_get_policy 200 2100 testdata/STD/pi1_template.json
138api_get_policy 200 3100 testdata/STD/pi1_template.json
139
140# Remove policies
141
142use_agent_dmaap
143api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200144use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100145api_delete_policy 204 3000
146use_agent_dmaap
147api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200148use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100149api_delete_policy 204 3100
150
151sim_equal ricsim_g1_1 num_instances 0
152sim_equal ricsim_g2_1 num_instances 0
153
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200154# Check remote host access to simulator
155
156sim_contains_ste ricsim_g1_1 hosts "policy-agent"
157sim_contains_ste ricsim_g2_1 hosts "policy-agent"
158
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100159# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200160use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100161api_get_policy 404 2000
162api_get_policy 404 3000
163api_get_policy 404 2100
164api_get_policy 404 3100
165
166# Remove the service
167use_agent_dmaap
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200168api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100169
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200170api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100171
172
173
174check_policy_agent_logs
175
176#### TEST COMPLETE ####
177
178store_logs END
179
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200180print_result
181
182auto_clean_containers