X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Ftest%2FKAFKA_DISPATCHER_TEST%2Fbasic_test.sh;fp=near-rt-ric-simulator%2Ftest%2FKAFKA_DISPATCHER_TEST%2Fbasic_test.sh;h=62c2fa5b59e78589bff660325ddf27d86d2a2717;hb=514637b303ec7dc6390007be1a046189f7a9d169;hp=0000000000000000000000000000000000000000;hpb=f6a48104c0a89a91dc36bb175c8ca301bfc9950d;p=sim%2Fa1-interface.git diff --git a/near-rt-ric-simulator/test/KAFKA_DISPATCHER_TEST/basic_test.sh b/near-rt-ric-simulator/test/KAFKA_DISPATCHER_TEST/basic_test.sh new file mode 100755 index 0000000..62c2fa5 --- /dev/null +++ b/near-rt-ric-simulator/test/KAFKA_DISPATCHER_TEST/basic_test.sh @@ -0,0 +1,166 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2022 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# + +# Script for basic test of the Kafka message dispatcher. +# Run the build_and_start with the same arg, except arg 'nonsecure|secure', as this script + +print_usage() { + echo "Usage: ./basic_test.sh nonsecure|secure " + exit 1 +} + +if [ $# -ne 1 ]; then + print_usage +fi +if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then + print_usage +fi + +if [ $1 == "nonsecure" ]; then + #Default http port for the simulator + PORT=7075 + # Set http protocol + HTTPX="http" +else + #Default https port for the simulator + PORT=7175 + # Set https protocol + HTTPX="https" +fi + +. ../common/test_common.sh +. ../common/elapse_time_curl.sh + +echo "=== Kafka message dispatcher hello world ===" +RESULT="OK" +do_curl GET / 200 + +echo "=== Reset force delay ===" +RESULT="Force delay has been resetted for all dispatcher responses" +do_curl POST /dispatcheradmin/forcedelay 200 + +echo "=== API: Get policy type to topic mapping of type: ANR ===" +res=$(cat jsonfiles/ANR_to_topic_map.json) +RESULT="json:$res" +do_curl GET /policytypetotopicmapping/ANR 200 + +echo "=== Put policy: shall publish and consume for put policy operation ===" +req_id=$(get_random_number) +RESULT="" +do_curl PUT /policytypes/ANR/kafkadispatcher/alpha 200 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres +wait $proc_id + +echo "=== Get policy status: shall publish and consume for get policy status operation ===" +req_id=$(get_random_number) +RESULT="" +do_curl GET /policytypes/ANR/kafkadispatcher/alpha/status 200 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres +wait $proc_id + +echo "=== Put policy: shall publish and consume for put policy operation for alpha ===" +req_id=$(get_random_number) +RESULT="" +do_curl PUT /policytypes/STD_1/kafkadispatcher/alpha 200 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres2 +wait $proc_id + +echo "=== Delete policy: shall publish and consume for delete policy operation for alpha ===" +req_id=$(get_random_number) +RESULT="" +do_curl DELETE /policytypes/STD_1/kafkadispatcher/alpha 200 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres2 +wait $proc_id + +echo "=== Set force delay 5 sec ===" +RESULT="Force delay: 5 sec set for all dispatcher responses until it is resetted" +do_curl POST '/dispatcheradmin/forcedelay?delay=5' 200 + +echo "=== Hello world: shall wait at least sec and then respond while hello world ===" +RESULT="OK" +do_elapsetime_curl GET / 200 jsonfiles/alpha_policy.json 5 + +echo "=== Reset force delay ===" +RESULT="Force delay has been resetted for all dispatcher responses" +do_curl POST /dispatcheradmin/forcedelay 200 + +echo "=== Put policy: shall publish and consume for put policy operation for beta ===" +req_id=$(get_random_number) +RESULT="" +do_curl PUT /policytypes/STD_1/kafkadispatcher/beta 200 jsonfiles/beta_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres2 +wait $proc_id + +echo "=== Get policy status: shall publish and consume for get policy status operation ===" +req_id=$(get_random_number) +RESULT="" +do_curl GET /policytypes/ANR/kafkadispatcher/alpha/status 200 jsonfiles/beta_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres +wait $proc_id + +echo "=== Put policy: shall publish and consume for put policy operation for alpha ===" +req_id=$(get_random_number) +RESULT="" +do_curl PUT /policytypes/STD_2/kafkadispatcher/alpha 200 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres3 +wait $proc_id + +echo "=== Set force response code: 500 ===" +RESULT="Force response code: 500 set for all dispatcher response until it is resetted" +do_curl POST '/dispatcheradmin/forceresponse?code=500' 200 + +echo "=== Put policy: shall not publish and consume for put policy operation for alpha ===" +req_id=$(get_random_number) +res=$(cat jsonfiles/forced_response.json) +RESULT="json:$res" +do_curl PUT /policytypes/ANR/kafkadispatcher/alpha 500 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres +wait $proc_id + +echo "=== Reset force response code ===" +RESULT="Force response code has been resetted for dispatcher responses" +do_curl POST /dispatcheradmin/forceresponse 200 + +echo "=== Get policy status: shall publish and consume for get policy status operation ===" +req_id=$(get_random_number) +RESULT="" +do_curl GET /policytypes/ANR/kafkadispatcher/alpha/status 200 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres +wait $proc_id + +echo "=== Delete policy: shall publish and consume for delete policy operation for alpha ===" +req_id=$(get_random_number) +RESULT="" +do_curl DELETE /policytypes/STD_1/kafkadispatcher/alpha 200 jsonfiles/alpha_policy.json $req_id & +proc_id=$! +publish_response_event $req_id kafkatopicres2 +wait $proc_id + +echo "********************" +echo "*** All tests ok ***" +echo "********************"