Skip to content

Commit

Permalink
update verify script
Browse files Browse the repository at this point in the history
  • Loading branch information
dipjyotimetia committed Sep 17, 2023
1 parent c3f6666 commit 672d858
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions verify.bash
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
# 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

0 comments on commit 672d858

Please sign in to comment.