From 672d85885e0aa9945e680fa47298045b052ca0d3 Mon Sep 17 00:00:00 2001 From: Dipjyoti Metia Date: Sun, 17 Sep 2023 13:59:30 +1000 Subject: [PATCH] update verify script --- verify.bash | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/verify.bash b/verify.bash index dc7a00d..6c85efe 100644 --- a/verify.bash +++ b/verify.bash @@ -1,9 +1,12 @@ #!/usr/bin/env bash +# Exit on any error set -e +# Build the Docker container and tag it as "verify-emulator" docker build . -t verify-emulator +# Run the Docker container with the required environment variables and detach it docker run --rm --env PUBSUB_PROJECT=test-project \ --env PUBSUB_TOPIC=test-topic1,test-topic2,test-topic3 \ --env PUBSUB_SUBSCRIPTION=test-sub1,test-sub2,test-sub3 \ @@ -12,20 +15,26 @@ docker run --rm --env PUBSUB_PROJECT=test-project \ --name verify \ verify-emulator +# Sleep for 10 seconds to allow the container to start sleep 10 +# Capture the container logs to a file docker logs verify &> verifylogs +# Display the container logs cat verifylogs +# Stop the Docker container docker stop verify > /dev/null -echo verifying log output - -grep "Server started, listening on 8085" verifylogs -grep "Topic created: projects/test-project/topics/test-topic1" verifylogs -grep "Created subscription: projects/test-project/subscriptions/test-sub1" verifylogs -grep "Published message with ID: 1" verifylogs -grep "Received message: Hello, Pub/Sub emulator!" verifylogs - -echo logs contain expected output \ No newline at end of file +# Verify log output +echo "Verifying log output..." +if grep -q "Server started, listening on 8085" verifylogs && + grep -q "Topic created: projects/test-project/topics/test-topic1" verifylogs && + grep -q "Created subscription: projects/test-project/subscriptions/test-sub1" verifylogs && + grep -q "Published message with ID: 1" verifylogs && + grep -q "Received message: Hello, Pub/Sub emulator!" verifylogs; then + echo "Logs contain expected output." +else + echo "Logs do not contain expected output." +fi