blob: 2e627fc899720912ed67c185b48d6b1570d09172 [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"
BjornMagnussonXA496156d2020-08-10 14:16:24 +020037use_cr_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010038
39clean_containers
40
41start_ric_simulators ricsim_g1 3 OSC_2.1.0
42
43start_ric_simulators ricsim_g2 5 STD_1.1.3
44
45start_mr
46
47start_cr
48
49start_consul_cbs
50
51prepare_consul_config NOSDNC ".consul_config.json"
52consul_config_app ".consul_config.json"
53
54start_control_panel
55
BjornMagnussonXA80a92002020-03-19 14:31:06 +010056start_policy_agent
57
BjornMagnussonXA72667f12020-04-24 09:20:18 +020058set_agent_debug
59
60use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010061
62api_get_status 200
63
64sim_print ricsim_g1_1 interface
65
66sim_print ricsim_g2_1 interface
67
68sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
69
70api_equal json:policy_types 2 60
71
72
73# Create policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +020074use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010075
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020076api_put_service 201 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010077
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020078api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010079
80sim_equal ricsim_g1_1 num_instances 1
81
82
BjornMagnussonXA496156d2020-08-10 14:16:24 +020083use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010084
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020085api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010086
87sim_equal ricsim_g1_1 num_instances 2
88
89
BjornMagnussonXA72667f12020-04-24 09:20:18 +020090use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010091
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020092api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010093
94sim_equal ricsim_g2_1 num_instances 1
95
96
BjornMagnussonXA496156d2020-08-10 14:16:24 +020097use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010098
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020099api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100100
101sim_equal ricsim_g2_1 num_instances 2
102
103
104#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200105use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100106
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200107api_put_service 200 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100108
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200109api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100110
111sim_equal ricsim_g1_1 num_instances 2
112
113
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200114use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100115
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200116api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100117
118sim_equal ricsim_g1_1 num_instances 2
119
120
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200121use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100122
123
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200124api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100125
126sim_equal ricsim_g2_1 num_instances 2
127
128
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200129use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100130
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200131api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100132
133sim_equal ricsim_g2_1 num_instances 2
134
135# Check policies
136api_get_policy 200 2000 testdata/OSC/pi1_template.json
137api_get_policy 200 3000 testdata/OSC/pi1_template.json
138api_get_policy 200 2100 testdata/STD/pi1_template.json
139api_get_policy 200 3100 testdata/STD/pi1_template.json
140
141# Remove policies
142
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200143use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100144api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200145use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100146api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200147use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100148api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200149use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100150api_delete_policy 204 3100
151
152sim_equal ricsim_g1_1 num_instances 0
153sim_equal ricsim_g2_1 num_instances 0
154
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200155# Check remote host access to simulator
156
ecaiyanlinuxc8ccab12020-06-09 13:29:53 +0200157sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
158sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200159
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100160# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200161use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100162api_get_policy 404 2000
163api_get_policy 404 3000
164api_get_policy 404 2100
165api_get_policy 404 3100
166
167# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200168use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200169api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100170
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200171api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100172
173
174
175check_policy_agent_logs
176
177#### TEST COMPLETE ####
178
179store_logs END
180
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200181print_result
182
183auto_clean_containers