BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ################################################################################ |
| 3 | # Copyright (c) 2022 Nordix Foundation. # |
| 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 | SAMELINE="\033[0K\r" |
| 19 | BOLD="\033[1m" |
| 20 | EBOLD="\033[0m" |
| 21 | |
| 22 | alive_check() { |
| 23 | wstr="Waiting for $BOLD $1 $EBOLD http alive check on $3" |
| 24 | echo -ne $wstr $SAMELINE |
| 25 | res=-1 |
| 26 | cntr=$2 |
| 27 | T1=$SECONDS |
| 28 | while [ $cntr -gt 0 ]; do |
| 29 | res=$(curl -skw "%{http_code}" -m 5 $3) |
| 30 | retcode=$? |
| 31 | if [ $retcode -eq 0 ]; then |
| 32 | httpcode="${res:${#res}-3}" |
| 33 | if [ $httpcode -ge 200 ] && [ $httpcode -le 299 ]; then |
| 34 | echo -ne $wstr " - Alive OK after $(($SECONDS-$T1)) seconds $SAMELINE" |
| 35 | echo "" |
| 36 | return 0 |
| 37 | else |
| 38 | echo -ne $wstr " - http status $httpcode after $(($SECONDS-$T1)) seconds $SAMELINE" |
| 39 | fi |
| 40 | else |
| 41 | echo -ne $wstr " - return code $retcode after $(($SECONDS-$T1)) seconds $SAMELINE" |
| 42 | fi |
| 43 | sleep 1 |
| 44 | let cntr=cntr-1 |
| 45 | done |
| 46 | echo -ne $wstr " - Alive failed after $(($SECONDS-$T1)) seconds $SAMELINE" |
| 47 | echo "" |
| 48 | return 1 |
| 49 | } |
| 50 | |
| 51 | # args: <name> <time-out> <container-name> <target-state> |
| 52 | state_check() { |
| 53 | wstr="Waiting for $BOLD $1 $EBOLD state check $4 on $3" |
| 54 | echo -ne $wstr $SAMELINE |
| 55 | cntr=$2 |
| 56 | T1=$SECONDS |
| 57 | while [ $cntr -gt 0 ]; do |
| 58 | res=$(docker inspect --format "{{ .State.$4 }}" $3) |
| 59 | if [ "$res" == "true" ]; then |
| 60 | echo -ne $wstr " - State OK after $(($SECONDS-$T1)) seconds $SAMELINE" |
| 61 | echo "" |
| 62 | return 0 |
| 63 | else |
| 64 | echo -ne $wstr " - State $4 not reached after $(($SECONDS-$T1)) seconds $SAMELINE" |
| 65 | fi |
| 66 | sleep 1 |
| 67 | let cntr=cntr-1 |
| 68 | done |
| 69 | echo -ne $wstr " - State check failed after $(($SECONDS-$T1)) seconds $SAMELINE" |
| 70 | echo "" |
| 71 | return 1 |
| 72 | } |
| 73 | check_curl_result() { |
| 74 | res="$2" |
| 75 | if [ "$1" -eq 0 ]; then |
| 76 | httpcode="${res:${#res}-3}" |
| 77 | if [ $httpcode -ge 200 ] && [ $httpcode -le 299 ]; then |
| 78 | echo " Curl ok, http status: $httpcode" |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 79 | return 0 |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 80 | else |
| 81 | echo " Failed with curl http code: $httpcode and $res" |
| 82 | fi |
| 83 | else |
| 84 | echo " Failed with curl return code: $1 and $res" |
| 85 | fi |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 86 | return 1 |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | |
| 90 | echo "Starting identity(keycloak), persistence(elasticsearch) and dmaap(message-router)" |
| 91 | docker-compose -f group1/docker-compose1.yaml up -d |
| 92 | alive_check "dmaap(message-router)" 120 localhost:3904/topics |
| 93 | alive_check "identity(keycloak)" 120 https://localhost:8463 |
| 94 | echo "Configuring identity(keycloak)" |
| 95 | python3 group1/identity/config.py |
| 96 | |
| 97 | echo "Starting sdnr sdnc-web and ves-collector" |
| 98 | docker-compose -f group2/docker-compose2.yaml up -d |
| 99 | alive_check sdnr 300 localhost:8181/apidoc/explorer |
| 100 | |
| 101 | echo "Starting ntsim" |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 102 | echo " sending dummy json to message router to clean pipe, first message always lost..." |
| 103 | curl localhost:3904/events/unauthenticated.VES_PNFREG_OUTPUT -X POST -H Content-Type:application/json -d {} |
| 104 | echo "sleep 30 to let message router settle down..." |
| 105 | sleep 30 |
| 106 | # pipeclean=1 |
| 107 | # while [ $pipeclean -eq 1 ]; do |
| 108 | # echo " posting message" |
| 109 | # res=$(curl localhost:3904/events/unauthenticated.VES_PNFREG_OUTPUT -X POST -H Content-Type:application/json -d {}) |
| 110 | # if [ $? -eq 0 ]; then |
| 111 | # res=$(curl "localhost:3904/events/unauthenticated.VES_PNFREG_OUTPUT/test/c1?timeout=15000&limit=100") |
| 112 | # if [ $? -eq 0 ]; then |
| 113 | # echo " result: "$res |
| 114 | # if [ "$res" != "[]" ]; then |
| 115 | # pipeclean=0 |
| 116 | # echo " pipe cleaned" |
| 117 | # fi |
| 118 | # fi |
| 119 | # fi |
| 120 | # if [ $pipeclean -eq 1 ]; then |
| 121 | # sleep 10 |
| 122 | # fi |
| 123 | # done |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 124 | |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 125 | |
| 126 | |
| 127 | |
| 128 | docker-compose -f group3/docker-compose3.yaml up -d |
| 129 | |
| 130 | # state_check netsim 120 ntsim-ng-o-du-1122 Running |
| 131 | # echo "Sleeping 10 sec to let ntsim fail first pnfregistration..." |
| 132 | # sleep 10 |
| 133 | # echo "Restarting ntsim - due to first ves event is lost in message router..." |
| 134 | # docker-compose -f group3/docker-compose3.yaml restart ntsim-ng-o-du-1122 |
| 135 | |
| 136 | |
| 137 | |
| 138 | state_check ntsim 120 ntsim-ng-o-du-1122 Running |
| 139 | |
| 140 | alive_check "ntsim" 300 '-u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=O-DU-1122' |
| 141 | echo "Sleeping 30 to let ntsim start up" |
| 142 | sleep 30 |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 143 | echo "Creating pm event stream" |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 144 | retcode=1 |
| 145 | while [ $retcode -ne 0 ]; do |
| 146 | res=$(curl -X PUT -sw %{http_code} -H "Content-Type: application/yang-data+json" -H "Accept: application/yang-data+json" -d @group3/stream-payload.json -u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=O-DU-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/subscription-streams=stream-1) |
| 147 | check_curl_result $? "$res" |
| 148 | retcode=$? |
| 149 | sleep 1 |
| 150 | done |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 151 | |
| 152 | echo "Creating pm event job" |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 153 | retcode=1 |
| 154 | while [ $retcode -ne 0 ]; do |
| 155 | res=$(curl -X PUT -sw %{http_code} -H "Content-Type: application/yang-data+json" -H "Accept: application/yang-data+json" -d @group3/job-payload.json -u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=O-DU-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/performance-measurement-jobs=pm-1) |
| 156 | check_curl_result $? "$res" |
| 157 | retcode=$? |
| 158 | sleep 1 |
| 159 | done |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 160 | |
| 161 | echo "Creating PM files: starting with index 100 - A100.xml.gz in ntsim dir /tmp " |
| 162 | docker cp group3/create-pm-files.sh ntsim-ng-o-du-1122:/tmp |
| 163 | docker cp group3/pm.xml ntsim-ng-o-du-1122:/tmp |
| 164 | docker exec -w /tmp ntsim-ng-o-du-1122 /tmp/create-pm-files.sh > /dev/null |
| 165 | |
| 166 | echo "Starting datafile collector" |
| 167 | docker-compose -f group4/docker-compose4.yaml up -d |
| 168 | alive_check "datafilecollector" 60 localhost:8100/status |
| 169 | |
| 170 | echo "Starting mariadb" |
| 171 | docker-compose -f group5/docker-compose5.yaml up -d mariadb |
| 172 | echo "Waiting for MariaDB to come up healthy..." |
| 173 | for i in {1..30}; do |
| 174 | mariadb_state=$(docker inspect --format='{{json .State.Health.Status}}' mariadb) |
| 175 | if [ $mariadb_state = '"healthy"' ] |
| 176 | then |
| 177 | echo " OK" |
| 178 | break |
| 179 | else |
| 180 | sleep 2 |
| 181 | fi |
| 182 | done |
| 183 | [ "$mariadb_state" != '"healthy"' ] && echo "Error: MariaDB container state not healthy" && exit 1 |
| 184 | |
| 185 | echo "Starting datarouter" |
| 186 | docker-compose -f group5/docker-compose5.yaml up -d datarouter-node datarouter-prov |
| 187 | alive_check "datarouter" 60 localhost:8480/internal/prov |
| 188 | |
| 189 | |
| 190 | echo "Starting pm-mapper" |
| 191 | docker-compose -f group5/docker-compose5.yaml up -d pmmapper |
| 192 | alive_check "pm-mapper" 60 localhost:8281/healthcheck |
| 193 | |
| 194 | echo "Configuring datarouter pm-mapper" |
| 195 | group5/config_dr.sh |
| 196 | |
| 197 | echo "Starting rapps" |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 198 | echo " clean json dump dirs" |
| 199 | rm group6/jsondump/rapp1/*.json |
| 200 | rm group6/jsondump/rapp2/*.json |
| 201 | echo " starting..." |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 202 | docker-compose -f group6/docker-compose6.yaml up -d |
| 203 | alive_check "rapp1" 120 localhost:9480 |
| 204 | alive_check "rapp2" 120 localhost:9481 |
| 205 | |
| 206 | echo "Starting ics, dmaap mediator and dmaap adapter" |
| 207 | docker-compose -f group7/docker-compose7.yaml up -d |
| 208 | alive_check "ics" 60 localhost:3927/status |
| 209 | alive_check "dmaap adapter" 60 localhost:9087/actuator/info |
| 210 | alive_check "dmaap mediator" 60 localhost:3928/health_check |
| 211 | |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 212 | # Creating job with filter |
| 213 | res=$(curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "http://localhost:3927/data-consumer/v1/info-jobs/job-adp-1?typeCheck=true" --data-binary '{"info_type_id": "PM_File_Data_Adp", "job_result_uri": "http://rapp1:8080/callbacks/data", "job_owner": "rapp1","status_notification_uri": "http://rapp1:8080/callbacks/status","job_definition": {"filterType":"pmdata","filter":{"measObjInstIds":["EUtranCellFDD=2"]}} }') |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 214 | check_curl_result $? "$res" |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 215 | res=$(curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "http://localhost:3927/data-consumer/v1/info-jobs/job-adp-2?typeCheck=true" --data-binary '{"info_type_id": "PM_Event_Data_Adp", "job_result_uri": "http://rapp1:8080/callbacks/event","job_owner": "rapp1","status_notification_uri": "http://rapp1:8080/callbacks/status","job_definition": {}}') |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 216 | check_curl_result $? "$res" |
| 217 | |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 218 | res=$(curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "http://localhost:3927/data-consumer/v1/info-jobs/job-med-1?typeCheck=true" --data-binary '{"info_type_id": "PM_File_Data_Med", "job_result_uri": "http://rapp2:8080/callbacks/data", "job_owner": "rapp2","status_notification_uri": "http://rapp2:8080/callbacks/status","job_definition": {}}') |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 219 | check_curl_result $? "$res" |
BjornMagnussonXA | 3f34dc8 | 2022-05-05 21:24:46 +0200 | [diff] [blame] | 220 | res=$(curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "http://localhost:3927/data-consumer/v1/info-jobs/job-med-2?typeCheck=true" --data-binary '{"info_type_id": "PM_Event_Data_Med", "job_result_uri": "http://rapp2:8080/callbacks/event","job_owner": "rapp2","status_notification_uri": "http://rapp2:8080/callbacks/status","job_definition": {}}') |
BjornMagnussonXA | 56683ca | 2022-04-04 17:17:22 +0200 | [diff] [blame] | 221 | check_curl_result $? "$res" |
| 222 | |
| 223 | echo "pm events should be continously emitted by ntsim every 10 sec" |
| 224 | echo "start sending 100 fileready events..." |
| 225 | |
| 226 | echo "Check events received by ves collector" |
| 227 | echo "cmd: docker exec -it ves-collector tail -f /opt/app/VESCollector/logs/input.log" |
| 228 | echo "" |
| 229 | echo "Check datafile-collector log" |
| 230 | echo "cmd: docker logs -f datafile-collector" |
| 231 | echo "" |
| 232 | echo "Check pmmapper log" |
| 233 | echo "docker logs -f pmmapper" |
| 234 | echo "" |
| 235 | echo "Files recevied by rapp1 and rapp2 are dumped as json in localhost dir mounted to the rapp containers" |
| 236 | echo "pm file data: group6/jsondump/rapp<X>/data.json" |
| 237 | echo "pm event data: group6/jsondump/rapp<X>/event.json" |
| 238 | echo "cmd example: watch 'cat group6/jsondump/rapp1/event.json | jq' " |
| 239 | |
| 240 | read -p "Hit enter to start sending fileready events" |
| 241 | |
| 242 | nfiles=100 |
| 243 | while [ $nfiles -lt 1000 ]; do |
| 244 | echo -ne "ordering file-ready evt for file: A"$nfiles".xml.gz "$SAMELINE |
| 245 | fileurl="sftp://netconf:netconf!@ntsim-ng-o-du-1122/tmp/A"$nfiles".xml.gz" |
| 246 | res=$(curl -s -X POST -H "Content-Type: application/json" \ |
| 247 | -H "Accept: application/yang-data+json" \ |
| 248 | -u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U \ |
| 249 | "http://localhost:8181/rests/operations/network-topology:network-topology/topology=topology-netconf/node=O-DU-1122/yang-ext:mount/nts-network-function:invoke-ves-pm-file-ready" \ |
| 250 | --data "{input:{file-location: "\"$fileurl\""}}") |
| 251 | echo -ne "ordering file-ready evt for file: A"$nfiles".xml.gz $res sleeping 30sec"$SAMELINE |
| 252 | sleep 30 |
| 253 | let nfiles=nfiles+1 |
| 254 | done |
| 255 | echo "" |
| 256 | |
| 257 | echo "All done" |