| #!/bin/bash |
| ################################################################################ |
| # Copyright (c) 2022 Nordix Foundation. # |
| # # |
| # Licensed under the Apache License, Version 2.0 (the \"License\"); # |
| # you may not use this file except in compliance with the License. # |
| # You may obtain a copy of the License at # |
| # # |
| # http://www.apache.org/licenses/LICENSE-2.0 # |
| # # |
| # Unless required by applicable law or agreed to in writing, software # |
| # distributed under the License is distributed on an \"AS IS\" BASIS, # |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # |
| # See the License for the specific language governing permissions and # |
| # limitations under the License. # |
| ################################################################################ |
| |
| SAMELINE="\033[0K\r" |
| BOLD="\033[1m" |
| EBOLD="\033[0m" |
| |
| alive_check() { |
| wstr="Waiting for $BOLD $1 $EBOLD http alive check on $3" |
| echo -ne $wstr $SAMELINE |
| res=-1 |
| cntr=$2 |
| T1=$SECONDS |
| while [ $cntr -gt 0 ]; do |
| res=$(curl -skw "%{http_code}" -m 5 $3) |
| retcode=$? |
| if [ $retcode -eq 0 ]; then |
| httpcode="${res:${#res}-3}" |
| if [ $httpcode -ge 200 ] && [ $httpcode -le 299 ]; then |
| echo -ne $wstr " - Alive OK after $(($SECONDS-$T1)) seconds $SAMELINE" |
| echo "" |
| return 0 |
| else |
| echo -ne $wstr " - http status $httpcode after $(($SECONDS-$T1)) seconds $SAMELINE" |
| fi |
| else |
| echo -ne $wstr " - return code $retcode after $(($SECONDS-$T1)) seconds $SAMELINE" |
| fi |
| sleep 1 |
| let cntr=cntr-1 |
| done |
| echo -ne $wstr " - Alive failed after $(($SECONDS-$T1)) seconds $SAMELINE" |
| echo "" |
| return 1 |
| } |
| |
| # args: <name> <time-out> <container-name> <target-state> |
| state_check() { |
| wstr="Waiting for $BOLD $1 $EBOLD state check $4 on $3" |
| echo -ne $wstr $SAMELINE |
| cntr=$2 |
| T1=$SECONDS |
| while [ $cntr -gt 0 ]; do |
| res=$(docker inspect --format "{{ .State.$4 }}" $3) |
| if [ "$res" == "true" ]; then |
| echo -ne $wstr " - State OK after $(($SECONDS-$T1)) seconds $SAMELINE" |
| echo "" |
| return 0 |
| else |
| echo -ne $wstr " - State $4 not reached after $(($SECONDS-$T1)) seconds $SAMELINE" |
| fi |
| sleep 1 |
| let cntr=cntr-1 |
| done |
| echo -ne $wstr " - State check failed after $(($SECONDS-$T1)) seconds $SAMELINE" |
| echo "" |
| return 1 |
| } |
| check_curl_result() { |
| res="$2" |
| if [ "$1" -eq 0 ]; then |
| httpcode="${res:${#res}-3}" |
| if [ $httpcode -ge 200 ] && [ $httpcode -le 299 ]; then |
| echo " Curl ok, http status: $httpcode" |
| return 0 |
| else |
| echo " Failed with curl http code: $httpcode and $res" |
| fi |
| else |
| echo " Failed with curl return code: $1 and $res" |
| fi |
| return 1 |
| } |
| |
| |
| echo "Starting identity(keycloak), persistence(elasticsearch) and dmaap(message-router)" |
| docker-compose -f group1/docker-compose1.yaml up -d |
| alive_check "dmaap(message-router)" 120 localhost:3904/topics |
| alive_check "identity(keycloak)" 120 https://localhost:8463 |
| echo "Configuring identity(keycloak)" |
| python3 group1/identity/config.py |
| |
| echo "Starting sdnr sdnc-web and ves-collector" |
| docker-compose -f group2/docker-compose2.yaml up -d |
| alive_check sdnr 300 localhost:8181/apidoc/explorer |
| |
| echo "Starting ntsim" |
| echo " sending dummy json to message router to clean pipe, first message always lost..." |
| curl localhost:3904/events/unauthenticated.VES_PNFREG_OUTPUT -X POST -H Content-Type:application/json -d {} |
| echo "sleep 30 to let message router settle down..." |
| sleep 30 |
| # pipeclean=1 |
| # while [ $pipeclean -eq 1 ]; do |
| # echo " posting message" |
| # res=$(curl localhost:3904/events/unauthenticated.VES_PNFREG_OUTPUT -X POST -H Content-Type:application/json -d {}) |
| # if [ $? -eq 0 ]; then |
| # res=$(curl "localhost:3904/events/unauthenticated.VES_PNFREG_OUTPUT/test/c1?timeout=15000&limit=100") |
| # if [ $? -eq 0 ]; then |
| # echo " result: "$res |
| # if [ "$res" != "[]" ]; then |
| # pipeclean=0 |
| # echo " pipe cleaned" |
| # fi |
| # fi |
| # fi |
| # if [ $pipeclean -eq 1 ]; then |
| # sleep 10 |
| # fi |
| # done |
| |
| |
| |
| |
| docker-compose -f group3/docker-compose3.yaml up -d |
| |
| # state_check netsim 120 ntsim-ng-o-du-1122 Running |
| # echo "Sleeping 10 sec to let ntsim fail first pnfregistration..." |
| # sleep 10 |
| # echo "Restarting ntsim - due to first ves event is lost in message router..." |
| # docker-compose -f group3/docker-compose3.yaml restart ntsim-ng-o-du-1122 |
| |
| |
| |
| state_check ntsim 120 ntsim-ng-o-du-1122 Running |
| |
| alive_check "ntsim" 300 '-u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=O-DU-1122' |
| echo "Sleeping 30 to let ntsim start up" |
| sleep 30 |
| echo "Creating pm event stream" |
| retcode=1 |
| while [ $retcode -ne 0 ]; do |
| 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) |
| check_curl_result $? "$res" |
| retcode=$? |
| sleep 1 |
| done |
| |
| echo "Creating pm event job" |
| retcode=1 |
| while [ $retcode -ne 0 ]; do |
| 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) |
| check_curl_result $? "$res" |
| retcode=$? |
| sleep 1 |
| done |
| |
| echo "Creating PM files: starting with index 100 - A100.xml.gz in ntsim dir /tmp " |
| docker cp group3/create-pm-files.sh ntsim-ng-o-du-1122:/tmp |
| docker cp group3/pm.xml ntsim-ng-o-du-1122:/tmp |
| docker exec -w /tmp ntsim-ng-o-du-1122 /tmp/create-pm-files.sh > /dev/null |
| |
| echo "Starting datafile collector" |
| docker-compose -f group4/docker-compose4.yaml up -d |
| alive_check "datafilecollector" 60 localhost:8100/status |
| |
| echo "Starting mariadb" |
| docker-compose -f group5/docker-compose5.yaml up -d mariadb |
| echo "Waiting for MariaDB to come up healthy..." |
| for i in {1..30}; do |
| mariadb_state=$(docker inspect --format='{{json .State.Health.Status}}' mariadb) |
| if [ $mariadb_state = '"healthy"' ] |
| then |
| echo " OK" |
| break |
| else |
| sleep 2 |
| fi |
| done |
| [ "$mariadb_state" != '"healthy"' ] && echo "Error: MariaDB container state not healthy" && exit 1 |
| |
| echo "Starting datarouter" |
| docker-compose -f group5/docker-compose5.yaml up -d datarouter-node datarouter-prov |
| alive_check "datarouter" 60 localhost:8480/internal/prov |
| |
| |
| echo "Starting pm-mapper" |
| docker-compose -f group5/docker-compose5.yaml up -d pmmapper |
| alive_check "pm-mapper" 60 localhost:8281/healthcheck |
| |
| echo "Configuring datarouter pm-mapper" |
| group5/config_dr.sh |
| |
| echo "Starting rapps" |
| echo " clean json dump dirs" |
| rm group6/jsondump/rapp1/*.json |
| rm group6/jsondump/rapp2/*.json |
| echo " starting..." |
| docker-compose -f group6/docker-compose6.yaml up -d |
| alive_check "rapp1" 120 localhost:9480 |
| alive_check "rapp2" 120 localhost:9481 |
| |
| echo "Starting ics, dmaap mediator and dmaap adapter" |
| docker-compose -f group7/docker-compose7.yaml up -d |
| alive_check "ics" 60 localhost:3927/status |
| alive_check "dmaap adapter" 60 localhost:9087/actuator/info |
| alive_check "dmaap mediator" 60 localhost:3928/health_check |
| |
| # Creating job with filter |
| 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"]}} }') |
| check_curl_result $? "$res" |
| 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": {}}') |
| check_curl_result $? "$res" |
| |
| 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": {}}') |
| check_curl_result $? "$res" |
| 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": {}}') |
| check_curl_result $? "$res" |
| |
| echo "pm events should be continously emitted by ntsim every 10 sec" |
| echo "start sending 100 fileready events..." |
| |
| echo "Check events received by ves collector" |
| echo "cmd: docker exec -it ves-collector tail -f /opt/app/VESCollector/logs/input.log" |
| echo "" |
| echo "Check datafile-collector log" |
| echo "cmd: docker logs -f datafile-collector" |
| echo "" |
| echo "Check pmmapper log" |
| echo "docker logs -f pmmapper" |
| echo "" |
| echo "Files recevied by rapp1 and rapp2 are dumped as json in localhost dir mounted to the rapp containers" |
| echo "pm file data: group6/jsondump/rapp<X>/data.json" |
| echo "pm event data: group6/jsondump/rapp<X>/event.json" |
| echo "cmd example: watch 'cat group6/jsondump/rapp1/event.json | jq' " |
| |
| read -p "Hit enter to start sending fileready events" |
| |
| nfiles=100 |
| while [ $nfiles -lt 1000 ]; do |
| echo -ne "ordering file-ready evt for file: A"$nfiles".xml.gz "$SAMELINE |
| fileurl="sftp://netconf:netconf!@ntsim-ng-o-du-1122/tmp/A"$nfiles".xml.gz" |
| res=$(curl -s -X POST -H "Content-Type: application/json" \ |
| -H "Accept: application/yang-data+json" \ |
| -u admin:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U \ |
| "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" \ |
| --data "{input:{file-location: "\"$fileurl\""}}") |
| echo -ne "ordering file-ready evt for file: A"$nfiles".xml.gz $res sleeping 30sec"$SAMELINE |
| sleep 30 |
| let nfiles=nfiles+1 |
| done |
| echo "" |
| |
| echo "All done" |