This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-examples.git
commit e17fb5fde62c0322120eafb014af087ede44e7c6 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Tue Aug 9 10:48:43 2022 +0200 (chores) camel-resume-api-examples: add support for verifying the results --- .../resume-api-fileset/src/main/docker/Dockerfile | 1 + .../resume-api-fileset/src/main/scripts/run.sh | 39 ++++++++++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/examples/resume-api/resume-api-fileset/src/main/docker/Dockerfile b/examples/resume-api/resume-api-fileset/src/main/docker/Dockerfile index f054938a..bd4353b9 100644 --- a/examples/resume-api/resume-api-fileset/src/main/docker/Dockerfile +++ b/examples/resume-api/resume-api-fileset/src/main/docker/Dockerfile @@ -21,6 +21,7 @@ COPY src/main/scripts/run.sh /deployments/run.sh ENV JAVA_HOME /etc/alternatives/jre ENV DATA_DIR /data/source +ENV OUTPUT_DIR /data/output RUN chmod +x /deployments/*.sh WORKDIR /deployments/ diff --git a/examples/resume-api/resume-api-fileset/src/main/scripts/run.sh b/examples/resume-api/resume-api-fileset/src/main/scripts/run.sh index fff449c1..972ad6bc 100644 --- a/examples/resume-api/resume-api-fileset/src/main/scripts/run.sh +++ b/examples/resume-api/resume-api-fileset/src/main/scripts/run.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -14,13 +15,31 @@ # See the License for the specific language governing permissions and # limitations under the License. # + +function checkResults() { + expectedItems=$((ITERATIONS * BATCH_SIZE)) + processedRecords=$(cat ${OUTPUT_DIR}/summary.txt | wc -l) + repeated=$(cat ${OUTPUT_DIR}/summary.txt | sort | uniq --count --repeated | wc -l) + + echo "###**************************************************************************###" + echo "Results: repeated items: ${repeated}" + echo "Results: processed items: ${processedRecords} (expected ${expectedItems})" + echo "###**************************************************************************###" + echo "Resume simulation completed" + echo "###**************************************************************************###" + +} + +trap checkResults exit SIGINT SIGABRT SIGHUP + echo "The test will process the following directory tree:" mkdir -p ${DATA_DIR} ITERATIONS=${1:-5} -BATCH_SIZE=${2:-50} +BATCH_SIZE=${2:-100} FILE_COUNT=${3:-100} +MAX_IDLE=5 for i in $(seq 0 ${ITERATIONS}) ; do mkdir -p ${DATA_DIR}/${i} @@ -35,22 +54,28 @@ for i in $(seq 0 ${ITERATIONS}) ; do done echo "Only the following files should processed in this execution:" - tree ${DATA_DIR}/${i} | pv -q -L 1014 + find ${DATA_DIR}/${i} -type f | pv -q -L 1014 java -Dinput.dir=${DATA_DIR} \ - -Doutput.dir=/tmp/out \ + -Doutput.dir=${OUTPUT_DIR} \ -Dresume.type=kafka \ -Dresume.type.kafka.topic=dir-offsets \ -Dbootstrap.address=kafka:9092 \ -jar /deployments/example.jar \ - -dm ${BATCH_SIZE} + -di ${MAX_IDLE} echo "********************************************************************************" echo "Finished the iteration ${i}" echo "********************************************************************************" sleep 2s + + if [[ -f ${OUTPUT_DIR}/summary.txt ]] ; then + processedRecords=$(cat ${OUTPUT_DIR}/summary.txt | wc -l) + echo "Processed ${processedRecords} so far" + fi + + done -echo "###**************************************************************************###" -echo "Resume simulation completed" -echo "###**************************************************************************###" + + exit 0
