blob: 42b8f587b40abe7e83d853edce0352542287719b [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
BjornMagnussonXAf38e1e82020-10-11 23:05:02 +020022#App names to include in the test, space separated list
23INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020024
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"
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020037
BjornMagnussonXA496156d2020-08-10 14:16:24 +020038use_cr_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020039use_simulator_http
40use_mr_http
41use_agent_rest_http
42
BjornMagnussonXA80a92002020-03-19 14:31:06 +010043
44clean_containers
45
46start_ric_simulators ricsim_g1 3 OSC_2.1.0
47
48start_ric_simulators ricsim_g2 5 STD_1.1.3
49
50start_mr
51
52start_cr
53
54start_consul_cbs
55
56prepare_consul_config NOSDNC ".consul_config.json"
57consul_config_app ".consul_config.json"
58
59start_control_panel
60
BjornMagnussonXA80a92002020-03-19 14:31:06 +010061start_policy_agent
62
BjornMagnussonXA72667f12020-04-24 09:20:18 +020063set_agent_debug
64
65use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010066
67api_get_status 200
68
69sim_print ricsim_g1_1 interface
70
71sim_print ricsim_g2_1 interface
72
73sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
74
75api_equal json:policy_types 2 60
76
77
78# Create policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +020079use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010080
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020081api_put_service 201 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010082
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020083api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010084
85sim_equal ricsim_g1_1 num_instances 1
86
87
BjornMagnussonXA496156d2020-08-10 14:16:24 +020088use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010089
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020090api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010091
92sim_equal ricsim_g1_1 num_instances 2
93
94
BjornMagnussonXA72667f12020-04-24 09:20:18 +020095use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010096
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020097api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010098
99sim_equal ricsim_g2_1 num_instances 1
100
101
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200102use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100103
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200104api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100105
106sim_equal ricsim_g2_1 num_instances 2
107
108
109#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200110use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100111
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200112api_put_service 200 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100113
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200114api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100115
116sim_equal ricsim_g1_1 num_instances 2
117
118
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200119use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200121api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100122
123sim_equal ricsim_g1_1 num_instances 2
124
125
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200126use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100127
128
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200129api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100130
131sim_equal ricsim_g2_1 num_instances 2
132
133
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200134use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100135
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200136api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100137
138sim_equal ricsim_g2_1 num_instances 2
139
140# Check policies
141api_get_policy 200 2000 testdata/OSC/pi1_template.json
142api_get_policy 200 3000 testdata/OSC/pi1_template.json
143api_get_policy 200 2100 testdata/STD/pi1_template.json
144api_get_policy 200 3100 testdata/STD/pi1_template.json
145
146# Remove policies
147
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200148use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100149api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200150use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100151api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200152use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100153api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200154use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100155api_delete_policy 204 3100
156
157sim_equal ricsim_g1_1 num_instances 0
158sim_equal ricsim_g2_1 num_instances 0
159
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200160# Check remote host access to simulator
161
ecaiyanlinuxc8ccab12020-06-09 13:29:53 +0200162sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
163sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200164
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100165# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200166use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100167api_get_policy 404 2000
168api_get_policy 404 3000
169api_get_policy 404 2100
170api_get_policy 404 3100
171
172# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200173use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200174api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100175
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200176api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100177
178
179
180check_policy_agent_logs
181
182#### TEST COMPLETE ####
183
184store_logs END
185
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200186print_result
187
188auto_clean_containers