Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Go tests wait for Prism to be responsive #128

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/go-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN go get -u github.com/twilio/twilio-go@main
RUN go get -u github.com/twilio/terraform-provider-twilio@main

# pipefail prevents errors in a pipeline from being masked.
CMD ["/bin/bash", "-c", "set -o pipefail && go test ./... -coverprofile /local/coverage.out -json | tee /local/test-report.out"]
CMD ["/local/wait-for-prism.sh", "/bin/bash", "-c", "set -o pipefail && go test ./... -coverprofile /local/coverage.out -json | tee /local/test-report.out"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have multiple services that will be dependent on the prism service being up and running, this script will need to exist in the context for each service. Instead can we replace this with a simple sleep:

CMD ["/bin/bash", "-c", "set -o pipefail && sleep 10 && go test ./... -coverprofile /local/coverage.out -json | tee /local/test-report.out"]

We've done something similar elsewhere which has not shown to have issues: https://github.com/sendgrid/sendgrid-oai/blob/64e32a322832ffea63afcd026e4e6557a04880ba/prism/docker-compose.yml#L8

19 changes: 19 additions & 0 deletions examples/go-client/wait-for-prism.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

while true
do
echo "Checking if Prism mock server is up... "
wget -O/dev/null --header="Authorization: Basic `echo -n abc:123 | base64`" http://prism_twilio:4010/v1/Credentials/AWS > /dev/null 2>&1
status=$?
echo "Prism Status: $status"
if [ $status -eq 0 ]; then
echo "Prism mock server is up now."
break
fi
sleep 0.1
done


>&2 echo "Prism is responding to API calls - executing command"
exec "$@"