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

Conversation

natebrennand
Copy link

Fixes #127

This PR introduces a bash script that will repeatedly try to access the Prism container on a sample API.
Once a working response is received, the script stops looping and begins executing the passed in command (in this case, go tests).

Checklist

Most of these items do not seem to apply to this change AFAICT.

  • I acknowledge that all my contributions will be made under the project's license
  • Run make test-docker
  • Verify affected language:
    • Generate twilio-go from our OpenAPI specification using the build_twilio_go.py using python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go and inspect the diff
    • Run make test in twilio-go
    • Create a pull request in twilio-go
    • Provide a link below to the pull request
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

@@ -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

@beebzz
Copy link
Contributor

beebzz commented May 23, 2022

Closing until PR feedback is addressed.

@beebzz beebzz closed this May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition in make test-docker
3 participants