X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=sample-services%2Fics-producer-consumer%2Fstart.sh;fp=sample-services%2Fics-producer-consumer%2Fstart.sh;h=94da48e97683026410b302b35d1493e4fef1ca09;hb=a6696f0efafd7341924258c937cdcafddff97772;hp=33d1ecf1fa38c8aa17f07991460b4387794e0e9a;hpb=84525a0316cc1626fe4d6328283d4578f735ae9b;p=nonrtric.git diff --git a/sample-services/ics-producer-consumer/start.sh b/sample-services/ics-producer-consumer/start.sh index 33d1ecf1..94da48e9 100755 --- a/sample-services/ics-producer-consumer/start.sh +++ b/sample-services/ics-producer-consumer/start.sh @@ -62,119 +62,121 @@ docker run -d \ -e KAFKA_SERVERS=kafka-zkless:9092 \ $PREFIX/o-ran-sc/nonrtric-sample-icsconsumer:$VERSION -# # Wait for the Kafka container to be running -# wait_for_container "kafka-zkless" "Kafka Server started" -# wait_for_container "kafka-producer" "Started Application" -# wait_for_container "kafka-consumer" "Started Application" - -# # Once Kafka container is running, start the producers and consumers -# echo "Kafka container is up and running. Starting producer and consumer..." -# space - -# echo "Start 1 Producer on mytopic" -# curl -X GET http://localhost:8080/startProducer/mytopic -# space - -# echo "Start 1 Consumer on mytopic" -# curl -X GET http://localhost:8081/startConsumer/mytopic -# space - -# sleep 10 - -# echo "Sending type1 to ICS" -# curl -X 'PUT' \ -# 'http://localhost:8083/data-producer/v1/info-types/type1' \ -# -H 'accept: application/json' \ -# -H 'Content-Type: application/json' \ -# -d '{ -# "info_job_data_schema": { -# "$schema":"http://json-schema.org/draft-07/schema#", -# "title":"STD_Type1_1.0.0", -# "description":"Type 1", -# "type":"object" -# } -# }' - -# echo "Getting types from ICS" -# curl -X 'GET' 'http://localhost:8083/data-producer/v1/info-types/type1' -# space - -# echo "Sending Producer infos to ICS" -# curl -X 'PUT' \ -# 'http://localhost:8083/data-producer/v1/info-producers/1' \ -# -H 'accept: application/json' \ -# -H 'Content-Type: application/json' \ -# -d '{ -# "info_producer_supervision_callback_url": "http://kafka-producer:8080/producer/supervision", -# "supported_info_types": [ -# "type1" -# ], -# "info_job_callback_url": "http://kafka-producer:8080/producer/job" -# }' - -# echo "Getting Producers Infos from ICS" -# curl -H 'Content-Type: application/json' 'http://localhost:8083/data-producer/v1/info-producers/1' -# space - -# echo "Sending Consumer Job infos to ICS" -# curl -X 'PUT' \ -# 'http://localhost:8083/data-consumer/v1/info-jobs/1' \ -# -H 'accept: application/json' \ -# -H 'Content-Type: application/json' \ -# -d '{ -# "info_type_id": "type1", -# "job_owner": "demo", -# "job_definition": { -# "deliveryInfo": { -# "topic": "mytopic", -# "bootStrapServers": "http://kafka-zkless:9092", -# "numberOfMessages": 0 -# } -# }, -# "job_result_uri": "http://kafka-producer:8080/producer/job", -# "status_notification_uri": "http://kafka-producer:8080/producer/supervision" -# }' - -# echo "Getting Consumer Job Infos from ICS" -# curl -H 'Content-Type: application/json' 'http://localhost:8083/data-consumer/v1/info-jobs/1' -# space - -# echo "Sending Consumer Subscription Job infos to ICS" -# curl -X 'PUT' \ -# 'http://localhost:8083/data-consumer/v1/info-type-subscription/1' \ -# -H 'accept: application/json' \ -# -H 'Content-Type: application/json' \ -# -d '{ -# "status_result_uri": "http://kafka-consumer:8081/info-type-status", -# "owner": "owner" -# }' -# echo "Getting Consumer Subscription Job infos from ICS" -# curl -X 'GET' 'http://localhost:8083/data-consumer/v1/info-type-subscription/1' -H 'accept: application/json' -# space - -# sleep 5 -# echo "ICS Producer Docker logs " -# docker logs informationcoordinatorservice | grep -E 'o.o.i.c.r1producer.ProducerCallbacks|o.o.i.repository.InfoTypeSubscriptions' -# space -# echo "Demo Producer Docker logs " -# docker logs kafka-producer | grep c.d.p.p.SimpleProducer -# space -# echo "Demo Consumer Docker logs " -# docker logs kafka-consumer | grep c.d.c.c.SimpleConsumer -# space - -# echo "Done." - -# containers=("kafka-producer" "kafka-consumer") - -# for container in "${containers[@]}"; do -# if docker logs "$container" | grep -q ERROR; then -# echo "Errors found in logs of $container" -# echo "FAIL" -# exit 1 -# else -# echo "No errors found in logs of $container" -# fi -# done +# Wait for the Kafka container to be running +wait_for_container "kafka-zkless" "Kafka Server started" +wait_for_container "kafka-producer" "Started Application" +wait_for_container "kafka-consumer" "Started Application" + +# Once Kafka container is running, start the producers and consumers +echo "Kafka container is up and running. Starting producer and consumer..." +space + +#Using the autostart flag in the application.yaml +echo "Start 1 Producer on mytopic" +#curl -X GET http://localhost:8080/startProducer/mytopic +space + +echo "Start 1 Consumer on mytopic" +#curl -X GET http://localhost:8081/startConsumer/mytopic +space + +sleep 10 + +echo "Sending type1 to ICS" +curl -X 'PUT' \ + 'http://localhost:8083/data-producer/v1/info-types/type1' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "info_job_data_schema": { + "$schema":"http://json-schema.org/draft-07/schema#", + "title":"STD_Type1_1.0.0", + "description":"Type 1", + "type":"object" + } +}' + +echo "Getting types from ICS" +curl -X 'GET' 'http://localhost:8083/data-producer/v1/info-types/type1' +space + +echo "Sending Producer infos to ICS" +curl -X 'PUT' \ + 'http://localhost:8083/data-producer/v1/info-producers/1' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "info_producer_supervision_callback_url": "http://kafka-producer:8080/producer/supervision", + "supported_info_types": [ + "type1" + ], + "info_job_callback_url": "http://kafka-producer:8080/producer/job" +}' + +echo "Getting Producers Infos from ICS" +curl -H 'Content-Type: application/json' 'http://localhost:8083/data-producer/v1/info-producers/1' +space + +echo "Sending Consumer Job infos to ICS" +curl -X 'PUT' \ + 'http://localhost:8083/data-consumer/v1/info-jobs/1' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "info_type_id": "type1", + "job_owner": "demo", + "job_definition": { + "deliveryInfo": { + "topic": "mytopic", + "bootStrapServers": "http://kafka-zkless:9092", + "numberOfMessages": 0 + } + }, + "job_result_uri": "http://kafka-producer:8080/producer/job", + "status_notification_uri": "http://kafka-producer:8080/producer/supervision" +}' + +echo "Getting Consumer Job Infos from ICS" +curl -H 'Content-Type: application/json' 'http://localhost:8083/data-consumer/v1/info-jobs/1' +space + +echo "Sending Consumer Subscription Job infos to ICS" +curl -X 'PUT' \ + 'http://localhost:8083/data-consumer/v1/info-type-subscription/1' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "status_result_uri": "http://kafka-consumer:8081/info-type-status", + "owner": "owner" +}' +echo "Getting Consumer Subscription Job infos from ICS" +curl -X 'GET' 'http://localhost:8083/data-consumer/v1/info-type-subscription/1' -H 'accept: application/json' +space + +sleep 5 +echo "ICS Producer Docker logs " +docker logs informationcoordinatorservice | grep -E 'o.o.i.c.r1producer.ProducerCallbacks|o.o.i.repository.InfoTypeSubscriptions' +space +echo "Demo Producer Docker logs " +docker logs kafka-producer | grep c.d.p.p.SimpleProducer +space +echo "Demo Consumer Docker logs " +docker logs kafka-consumer | grep c.d.c.c.SimpleConsumer +space + +echo "Done." + +containers=("kafka-producer" "kafka-consumer") + +for container in "${containers[@]}"; do + if docker logs "$container" | grep -q ERROR; then + echo "Errors found in logs of $container" + docker logs "$container" | grep ERROR + echo "FAIL" + exit 1 + else + echo "No errors found in logs of $container" + fi +done echo "SUCCESS" exit 0