2 # ============LICENSE_START=======================================================
3 # dcaegen2-collectors-veshv
4 # ================================================================================
5 # Copyright (C) 2018 NOKIA
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
23 echo "Send request to xnf-simulator"
24 echo "Usage: $0 [-h|--help] [-v|--verbose] [<xnf listen port> [<messages amount> [<messages type> [<xnf endpoint>]]]]"
26 echo "Default values:"
27 echo " - xnf listen port : 6062"
28 echo " - messages amount : 1"
29 echo " - messages type : VALID"
30 echo " - xnf endpoint : simulator/async"
31 echo "Example invocations:"
32 echo "./xnf-simulation.sh -v 6062 1000 VALID"
36 optspec=":vh-:" # catch v, h and -
37 while getopts "$optspec" arg; do
48 echo "Unknown option --${OPTARG}" >&2
60 echo "Unknown option -${OPTARG}" >&2
68 MESSAGES_AMOUNT=${2:-1}
69 MESSAGES_TYPE=${3:-VALID}
70 XNF_ENDPOINT=simulator/async
72 if [ -n "${VERBOSE+x}" ]; then
73 echo "Requesting xnf-simulator on port ${XNF_PORT} to send ${MESSAGES_AMOUNT} messages of type ${MESSAGES_TYPE}"
76 currentTimeMicros=$((`date +%s%N`/1000))
77 REQUEST_ID=$(curl --request POST -s --header 'Content-Type: application/json' localhost:${XNF_PORT}/${XNF_ENDPOINT} -d "
80 \"commonEventHeader\": {
81 \"version\": \"sample-version\",
82 \"domain\": \"perf3gpp\",
85 \"eventId\": \"sample-event-id\",
86 \"eventName\": \"sample-event-name\",
87 \"eventType\": \"sample-event-type\",
88 \"startEpochMicrosec\": 120034455,
89 \"lastEpochMicrosec\": $currentTimeMicros,
90 \"nfNamingCode\": \"sample-nf-naming-code\",
91 \"nfcNamingCode\": \"sample-nfc-naming-code\",
92 \"reportingEntityId\": \"sample-reporting-entity-id\",
93 \"reportingEntityName\": \"sample-reporting-entity-name\",
94 \"sourceId\": \"sample-source-id\",
95 \"sourceName\": \"sample-source-name\",
96 \"vesEventListenerVersion\": \"7.2.0\"
98 \"messageType\": \"${MESSAGES_TYPE}\",
99 \"messagesAmount\": ${MESSAGES_AMOUNT}
103 if [ -n "${VERBOSE+x}" ]; then
104 echo -e "Request id: ${REQUEST_ID}\n"
106 echo "To check request status execute:"
107 echo "curl --request GET localhost:${XNF_PORT}/simulator/${REQUEST_ID}"
108 echo "To further debug you can try something similiar to:"
109 echo "docker ps -a | grep ${XNF_PORT} | awk '{ print \$1 }' | xargs docker logs"