3 # ============LICENSE_START===============================================
4 # Copyright (C) 2023 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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
21 echo "script-home: "$SD
38 echo "Usage: kafka-client-send-genfiles-file-ready.sh <node-count> <num-of-events> <node-name-base> <file-extension> sftp|ftpes|https <num-servers> [hist]"
42 if [ $# -lt 6 ] && [ $# -gt 7 ]; then
46 if [ $TYPE == "sftp" ]; then
47 echo "sftp servers not yet supported"
48 elif [ $TYPE == "ftpes" ]; then
49 echo "ftpes servers not yet supported"
50 elif [ $TYPE == "https" ]; then
56 if [ $FILE_EXT != "xml.gz" ]; then
57 echo "only xml.gz format supported"
62 if [ ! -z "$HIST" ]; then
63 if [ $HIST != "hist" ]; then
69 # Unix time of 20230220.1300
70 # If the value is changed, make sure to set the same time to the env var GENERATED_FILE_START_TIME in kube-plt.yaml for the https-server
73 # If the value is changed, make sure to set the same value to the env var GENERATED_FILE_TIMEZONE in kube-plt.yaml for the https-server
82 for (( i=0; i<$EVT_COUNT; i++)); do
84 if [ $CNTR -eq 0 ]; then
89 if [ "$HIST" == "" ]; then
90 echo "EVENT NO: $i for $NODE_COUNT NODES - 1 FILE PER EVENT"
92 echo "EVENT NO: $i for $NODE_COUNT NODES - $HIST_LEN FILES PER EVENT"
94 let STTIMEMS=$CURTIME*1000000
95 ST=$(date -d @$CURTIME +'%Y%m%d.%H%M')
96 let CURTIME=CURTIME+900
97 let CURTIMEMS=$CURTIME*1000000
98 ET=$(date -d @$CURTIME +'%H%M')
100 for (( j=0; j<$NODE_COUNT; j++)); do
102 if [ "$HIST" == "" ]; then
103 NO="$NODE_NAME_BASE-$j"
105 #FN="A20000626.2315+0200-2330+0200_$NO-$i.$FILE_EXT"
106 FN="A$ST$TIMEZONE-$ET${TIMEZONE}_$NO.$FILE_EXT"
107 let SRV_ID=$j%$SRV_COUNT
113 if [ $TYPE == "sftp" ]; then
114 SRV="ftp-sftp-$SRV_ID"
115 echo "FTP SERVER "$SRV
116 URL="sftp://onap:pano@$SRV:$SFTP_PORT/$FN"
117 elif [ $TYPE == "ftpes" ]; then
118 SRV="ftp-ftpes-$SRV_ID"
119 echo "FTP SERVER "$SRV
120 URL="ftpes://onap:pano@$SRV:$FTPES_PORT/$FN"
121 elif [ $TYPE == "https" ]; then
122 SRV="pm-https-server-$SRV_ID.pm-https-server.ran"
123 echo "HTTP SERVER "$SRV
124 URL="https://$SRV:$HTTPS_PORT/generatedfiles/$FN"
126 EVT='{"event":{"commonEventHeader":{"sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","sourceName":"'$NO'","lastEpochMicrosec":'$CURTIMEMS',"startEpochMicrosec":'$STTIMEMS',"timeZoneOffset":"UTC'$TIMEZONE'","changeIdentifier":"PM_MEAS_FILES"},"notificationFields":{"notificationFieldsVersion":"notificationFieldsVersion","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}]}}}'
127 echo $EVT >> .out.json
129 NO="$NODE_NAME_BASE-$j"
131 let SRV_ID=$j%$SRV_COUNT
136 for(( k=95; k>=0; k-- )); do
139 CURTIME=$(($BEGINTIME+$FID*900))
140 let STTIMEMS=$CURTIME*1000000
141 ST=$(date -d @$CURTIME +'%Y%m%d.%H%M')
142 let CURTIME=CURTIME+900
143 let CURTIMEMS=$CURTIME*1000000
144 ET=$(date -d @$CURTIME +'%H%M')
145 if [ $FID -lt 0 ]; then
146 FN="NONEXISTING_$NO.$FILE_EXT"
148 #FN="A20000626.2315+0200-2330+0200_$NO-$FID.$FILE_EXT"
149 FN="A$ST$TIMEZONE-$ET${TIMEZONE}_$NO.$FILE_EXT"
152 if [ $TYPE == "sftp" ]; then
153 SRV="ftp-sftp-$SRV_ID"
154 #echo "FTP SERVER "$SRV
155 URL="sftp://onap:pano@$SRV:$SFTP_PORT/$FN"
156 elif [ $TYPE == "ftpes" ]; then
157 SRV="ftp-ftpes-$SRV_ID"
158 #echo "FTP SERVER "$SRV
159 URL="ftpes://onap:pano@$SRV:$FTPES_PORT/$FN"
160 elif [ $TYPE == "https" ]; then
161 SRV="pm-https-server-$SRV_ID.pm-https-server.ran"
162 #echo "HTTP SERVER "$SRV
163 URL="https://$SRV:$HTTPS_PORT/files/$FN"
165 if [ "$EVT_FRAG" != "" ]; then
166 EVT_FRAG=$EVT_FRAG","
168 EVT_FRAG=$EVT_FRAG'{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}'
171 EVT='{"event":{"commonEventHeader":{"sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","sourceName":"'$NO'","lastEpochMicrosec":'$CURTIMEMS',"startEpochMicrosec":'$STTIMEMS',"timeZoneOffset":"UTC'$TIMEZONE'","changeIdentifier":"PM_MEAS_FILES"},"notificationFields":{"notificationFieldsVersion":"notificationFieldsVersion","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":['$EVT_FRAG']}}}'
172 echo $EVT >> .out.json
178 if [ $CNTR -ge $BATCHSIZE ]; then
179 echo "Pushing batch of $CNTR events"
180 cat .out.json | kafka-console-producer --topic file-ready --broker-list kafka-1-kafka-bootstrap.nonrtric:9092
187 if [ $CNTR -ne 0 ]; then
188 echo "Pushing batch of $CNTR events"
189 cat .out.json | kafka-console-producer --topic file-ready --broker-list kafka-1-kafka-bootstrap.nonrtric:9092
192 echo "Pushed $TCNTR events"