blob: bd4dfb62964e026bfc6eb465ff520d11a3287660 [file] [log] [blame]
Lusheng Ji37534a52020-08-02 21:25:26 -04001#!/bin/bash
2################################################################################
3# Copyright (c) 2020 AT&T Intellectual Property. #
4# #
5# Licensed under the Apache License, Version 2.0 (the "License"); #
6# you may not use this file except in compliance with the License. #
7# You may obtain a copy of the License at #
8# #
9# http://www.apache.org/licenses/LICENSE-2.0 #
10# #
11# Unless required by applicable law or agreed to in writing, software #
12# distributed under the License is distributed on an "AS IS" BASIS, #
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14# See the License for the specific language governing permissions and #
15# limitations under the License. #
16################################################################################
17
18#set -x
19
20acknowledge() {
21 echo "$1"
22 read -n 1 -p "Press any key to continue" mainmenuinput
23 echo
24}
25
26
27echo "This script demonstrates the phase one of the Bronze release Traffic Steering use case."
28DIRNAME="/tmp/tsflow-$(date +%Y%m%d%H%M)"
29mkdir $DIRNAME
30cd $DIRNAME
31
32echo "===> Generating xApp on-boarding file"
33echo '{
34 "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/qp.git;a=blob_plain;f=xapp-descriptor/config.json;hb=HEAD"
35}' > onboard.qp.url
36echo '{
37 "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/qp-driver.git;a=blob_plain;f=xapp-descriptor/config.json;hb=HEAD"
38}' > onboard.qpd.url
39echo '{
40 "config-file.json_url": "https://gerrit.o-ran-sc.org/r/gitweb?p=ric-app/ts.git;a=blob_plain;f=xapp-descriptor/config.json;hb=HEAD"
41}' > onboard.ts.url
42
43
44echo "===> On-boarding xApps"
45curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
46 --header 'Content-Type: application/json' --data-binary "@./onboard.ts.url"
47curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
48 --header 'Content-Type: application/json' --data-binary "@./onboard.qp.url"
49curl --location --request POST "http://$(hostname):32080/onboard/api/v1/onboard/download" \
50 --header 'Content-Type: application/json' --data-binary "@./onboard.qpd.url"
51
52echo "======> Listing on boarded xApps"
53curl --location --request GET "http://$(hostname):32080/onboard/api/v1/charts"
54
55
56echo "====> Deploy xApps"
57curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
58 --header 'Content-Type: application/json' --data-raw '{"xappName": "qp"}'
59# response: {"instances":null,"name":"qp","status":"deployed","version":"1.0"}
60
61curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
62 --header 'Content-Type: application/json' --data-raw '{"xappName": "qpdriver"}'
63# response: {"instances":null,"name":"qpdriver","status":"deployed","version":"1.0"}
64
65curl --location --request POST "http://$(hostname):32080/appmgr/ric/v1/xapps" \
66 --header 'Content-Type: application/json' --data-raw '{"xappName": "trafficxapp"}'
67# response: {"instances":null,"name":"trafficxapp","status":"deployed","version":"1.0"}
68
69echo "======> Status of xApps"
70kubectl get pods -n ricxapp
71
72POD_QP=""
73POD_QPD=""
74POD_TS=""
75while [ -z $POD_QP ] || [ -z $POD_QPD ] || [ -z $POD_TS ]; do
76 echo "Not all new xApp pods are in running state."
77 sleep 5
78 POD_QP=$(kubectl get pods -n ricxapp | grep Running | grep "\-qp\-" | cut -f1 -d ' ')
79 POD_QPD=$(kubectl get pods -n ricxapp | grep Running | grep "\-qpdriver\-" | cut -f1 -d ' ')
80 POD_TS=$(kubectl get pods -n ricxapp | grep Running | grep "\-trafficxapp\-" | cut -f1 -d ' ')
81done
82
83
84POD_A1=$(kubectl get pods -n ricplt | grep Running | grep "\-a1mediator\-" | cut -f1 -d ' ')
85echo "To view the logs of the A1 midiator, run the following "
86echo "command in a separate terminal window:"
87echo " kubectl logs -f -n ricplt $POD_A1"
88
89echo "To view the logs of the traffic steering xapp, run the following "
90echo "command in a separate terminal window:"
91echo " kubectl logs -f -n ricplt $POD_TS"
92
93acknowledge ""
94
95
96# populate DB
97echo "===> Inject DBaas with testing data for Traffic Steering test"
98if [ ! -e ts ]; then
99 git clone http://gerrit.o-ran-sc.org/r/ric-xapp/ts
100fi
101pushd "$(pwd)"
102cd ts/test/populatedb
103./populate_db.sh
104popd
105
106
107echo "====> Pushing policy type to A1"
108POLICY_TYPE_ID="20008"
109cat << EOF > ts-policy-type-${POLICY_TYPE_ID}.json
110{
111 "name": "tsapolicy",
112 "description": "tsa parameters",
113 "policy_type_id": ${POLICY_TYPE_ID},
114 "create_schema": {
115 "\$schema": "http://json-schema.org/draft-07/schema#",
116 "title": "TS Policy",
117 "description": "TS policy type",
118 "type": "object",
119 "properties": {
120 "threshold": {
121 "type": "integer",
122 "default": 0
123 }
124 },
125 "additionalProperties": false
126 }
127}
128EOF
129
130acknowledge "The next command will create a new policy type. Watch the logs of A1 Mediator"
131
132curl -v -X PUT "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}" \
133 -H "accept: application/json" -H "Content-Type: application/json" \
134 -d @./ts-policy-type-${POLICY_TYPE_ID}.json
135# expect to see a 201
136
137echo "======> Listing policy types"
138curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
139 http://$(hostname):32080/a1mediator/a1-p/policytypes
140
141acknowledge "The next command will create a new policy instance. Watch the logs of A1 Mediator and TS xApp"
142
143POLICY_ID="tsapolicy145"
144echo "===> Deploy policy ID of ${POLICY_ID}" of policy type ${POLICY_TYPE_ID}"
145curl -X PUT --header "Content-Type: application/json" \
146 --data "{\"threshold\" : 5}" \
147 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
148
149# get policy instances
150echo "======> Listing policy instances"
151curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
152 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
153
154echo "Watch how TS processes the data retrieved from RNIB in TS logs"
155acknowledge "After done we will start the removal process"
156
157
158echo "===> Deleting policy instance"
159acknowledge "The next command will delete a policy instance. Watch the logs of A1 Mediator andd TS xApp"
160curl -X DELETE --header "Content-Type: application/json" --header "accept: application/json" \
161 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies/${POLICY_ID}
162
163echo "======> Listing policy instances"
164curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
165 http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}/policies
166
167echo "===> Deleting policy type $POLICY_TYPE_ID"
168acknowledge "The next command will delete a policy type. Watch the logs of TS xApp"
169curl -X DELETE -H "accept: application/json" -H "Content-Type: application/json" \
170 "http://$(hostname):32080/a1mediator/a1-p/policytypes/${POLICY_TYPE_ID}"
171
172echo "======> Listing policy types"
173curl -X GET --header "Content-Type: application/json" --header "accept: application/json" \
174 http://$(hostname):32080/a1mediator/a1-p/policytypes
175
176
177echo "===> Unddeploy the xApps"
178acknowledge "The next command will delete the TS, QP, and DPQ xApps."
179curl -H "Content-Type: application/json" -X DELETE \
180 http://$(hostname):32080/appmgr/ric/v1/xapps/trafficxapp
181curl -H "Content-Type: application/json" -X DELETE \
182 http://$(hostname):32080/appmgr/ric/v1/xapps/qp
183curl -H "Content-Type: application/json" -X DELETE \
184 http://$(hostname):32080/appmgr/ric/v1/xapps/qpdriver
185
186echo "======> Listing xApps"
187kubectl get pods -n ricxapp
188