From 2c3651546c24ccd14b9a8db6fa3b6be5ccf2c68e Mon Sep 17 00:00:00 2001 From: lapentafd Date: Mon, 14 Oct 2024 09:19:20 +0100 Subject: [PATCH] Re-Enable verify test for sample rapp Issue-ID: NONRTRIC-1009 Change-Id: I681647e17e24e4cbf468690359d6426b092ac035 Signed-off-by: lapentafd --- sample-services/ics-producer-consumer/start.sh | 8 + .../ics-simple-producer-consumer/tests/.env | 3 +- .../tests/docker-compose.yaml | 4 +- .../tests/start_ics_producer_consumer_test.sh | 310 +++++++++++---------- 4 files changed, 168 insertions(+), 157 deletions(-) mode change 100644 => 100755 sample-services/ics-simple-producer-consumer/tests/start_ics_producer_consumer_test.sh diff --git a/sample-services/ics-producer-consumer/start.sh b/sample-services/ics-producer-consumer/start.sh index 7ddc9080..0a4ce857 100755 --- a/sample-services/ics-producer-consumer/start.sh +++ b/sample-services/ics-producer-consumer/start.sh @@ -195,4 +195,12 @@ for container in "${containers[@]}"; do fi done echo "SUCCESS" +docker stop kafka-zkless +docker stop informationcoordinatorservice +docker stop kafka-producer +docker stop kafka-consumer +docker rm kafka-zkless +docker rm informationcoordinatorservice +docker rm kafka-producer +docker rm kafka-consumer exit 0 diff --git a/sample-services/ics-simple-producer-consumer/tests/.env b/sample-services/ics-simple-producer-consumer/tests/.env index ba642fbb..fae88a82 100644 --- a/sample-services/ics-simple-producer-consumer/tests/.env +++ b/sample-services/ics-simple-producer-consumer/tests/.env @@ -1,2 +1,3 @@ REGISTRY=nexus3.o-ran-sc.org:10001/ -STAGING=nexus3.o-ran-sc.org:10004/ \ No newline at end of file +STAGING=nexus3.o-ran-sc.org:10004/ +LOCAL= \ No newline at end of file diff --git a/sample-services/ics-simple-producer-consumer/tests/docker-compose.yaml b/sample-services/ics-simple-producer-consumer/tests/docker-compose.yaml index 89a38704..1ae9537b 100644 --- a/sample-services/ics-simple-producer-consumer/tests/docker-compose.yaml +++ b/sample-services/ics-simple-producer-consumer/tests/docker-compose.yaml @@ -6,7 +6,7 @@ services: - "8083:8083" kafka-producer: - image: ${REGISTRY}o-ran-sc/nonrtric-sample-simple-icsproducer:0.0.1 + image: ${STAGING}o-ran-sc/nonrtric-sample-simple-icsproducer:0.0.1 container_name: kafka-producer environment: - SPRING_KAFKA_SERVER=broker:9092 @@ -16,7 +16,7 @@ services: - broker kafka-consumer: - image: ${REGISTRY}o-ran-sc/nonrtric-sample-simple-icsconsumer:0.0.1 + image: ${STAGING}o-ran-sc/nonrtric-sample-simple-icsconsumer:0.0.1 container_name: kafka-consumer environment: - SPRING_KAFKA_SERVER=broker:9092 diff --git a/sample-services/ics-simple-producer-consumer/tests/start_ics_producer_consumer_test.sh b/sample-services/ics-simple-producer-consumer/tests/start_ics_producer_consumer_test.sh old mode 100644 new mode 100755 index d19c11b1..253303d3 --- a/sample-services/ics-simple-producer-consumer/tests/start_ics_producer_consumer_test.sh +++ b/sample-services/ics-simple-producer-consumer/tests/start_ics_producer_consumer_test.sh @@ -15,158 +15,160 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============LICENSE_END================================================= + #!/bin/bash -echo "commented" -# source ./utils/utils.sh - -# docker compose up -d - -# # Wait for the Kafka container to be running -# wait_for_container "broker" "Kafka Server started" -# wait_for_container "kafka-producer" "Started KafkaProducerApplication" -# wait_for_container "kafka-consumer" "Started KafkaConsumerApplication" - -# # Once Kafka container is running, start the producers and consumers -# echo "Kafka container is up and running. Starting producer and consumer..." -# space - -# curl -v -i -X POST -H 'Content-Type: application/json' -d '{"configuredLevel": "TRACE"}' http://localhost:8083/actuator/loggers/org.oransc.ics - -# 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", -# "topic": "mytopic", -# "bootStrapServers": "broker:9092" -# } -# }' - -# 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/health-check", -# "supported_info_types": [ -# "type1" -# ], -# "info_job_callback_url": "http://kafka-producer:8080/info-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 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:9090/info-type-status", -# "owner": "demo" -# }' -# 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 - -# #start Consumer -# echo "Sending type1 to ICS to use the callback, This will start a CONSUMER" -# 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", -# "topic": "mytopic", -# "bootStrapServers": "broker:9092" -# } -# }' - -# sleep 3 - -# #ICS starts a producer (healthcheck to status) -# echo "Sending Consumer Job infos to ICS, This will start a PRODUCER" -# 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": "broker:9092", -# "numberOfMessages": 100 -# } -# }, -# "job_result_uri": "http://kafka-producer:8080/info-job", -# "status_notification_uri": "http://kafka-consumer:9090/info-type-status" -# }' - -# echo "Getting Consumer Job Infos from ICS" -# curl -H 'Content-Type: application/json' 'http://localhost:8083/data-consumer/v1/info-jobs/1' -# space - -# for i in {1..10}; do -# echo -# curl -X GET "http://localhost:8080/publish/$i" -# sleep 1 -# done - -# space -# echo "Deleting Producer Job infos to ICS" -# curl -X 'DELETE' \ -# 'http://localhost:8083/data-producer/v1/info-producers/1' - -# echo "Deleting Consumer Job infos to ICS" -# curl -X 'DELETE' \ -# 'http://localhost:8083/data-consumer/v1/info-jobs/1' - -# echo "Deleting type1 to ICS to use the callback and stop consuming" -# curl -X 'DELETE' \ -# 'http://localhost:8083/data-producer/v1/info-types/type1' - - -# 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.k.controller.KafkaController -# space -# echo "Demo Consumer Docker logs " -# docker logs kafka-consumer | grep c.d.kafkaconsumer.service.KafkaConsumer -# 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" -# docker compose down -# exit 0 +source ./utils/utils.sh + +docker build -t nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-sample-simple-icsproducer:0.0.1 ../kafka-producer/ +docker build -t nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-sample-simple-icsconsumer:0.0.1 ../kafka-consumer/ + +docker compose up -d + +# Wait for the Kafka container to be running +wait_for_container "broker" "Kafka Server started" +wait_for_container "kafka-producer" "Started KafkaProducerApplication" +wait_for_container "kafka-consumer" "Started KafkaConsumerApplication" + +# Once Kafka container is running, start the producers and consumers +echo "Kafka container is up and running. Starting producer and consumer..." +space + +curl -v -i -X POST -H 'Content-Type: application/json' -d '{"configuredLevel": "TRACE"}' http://localhost:8083/actuator/loggers/org.oransc.ics + +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", + "topic": "mytopic", + "bootStrapServers": "broker:9092" + } +}' + +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/health-check", + "supported_info_types": [ + "type1" + ], + "info_job_callback_url": "http://kafka-producer:8080/info-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 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:9090/info-type-status", + "owner": "demo" +}' +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 + +#start Consumer +echo "Sending type1 to ICS to use the callback, This will start a CONSUMER" +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", + "topic": "mytopic", + "bootStrapServers": "broker:9092" + } +}' + +sleep 3 + +#ICS starts a producer (healthcheck to status) +echo "Sending Consumer Job infos to ICS, This will start a PRODUCER" +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": "broker:9092", + "numberOfMessages": 100 + } + }, + "job_result_uri": "http://kafka-producer:8080/info-job", + "status_notification_uri": "http://kafka-consumer:9090/info-type-status" +}' + +echo "Getting Consumer Job Infos from ICS" +curl -H 'Content-Type: application/json' 'http://localhost:8083/data-consumer/v1/info-jobs/1' +space + +for i in {1..10}; do + echo + curl -X GET "http://localhost:8080/publish/$i" + sleep 1 +done + +space +echo "Deleting Producer Job infos to ICS" +curl -X 'DELETE' \ + 'http://localhost:8083/data-producer/v1/info-producers/1' + +echo "Deleting Consumer Job infos to ICS" +curl -X 'DELETE' \ + 'http://localhost:8083/data-consumer/v1/info-jobs/1' + +echo "Deleting type1 to ICS to use the callback and stop consuming" +curl -X 'DELETE' \ + 'http://localhost:8083/data-producer/v1/info-types/type1' + +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.k.controller.KafkaController +space +echo "Demo Consumer Docker logs " +docker logs kafka-consumer | grep c.d.kafkaconsumer.service.KafkaConsumer +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" +docker compose down +exit 0 -- 2.16.6