Skip to content

Commit

Permalink
try switch to name instead of quoted url
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Dec 10, 2024
1 parent 663c652 commit 89d1c28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

# Needs to be done in CI since docker stack does not support conditional waits
- name: Wait for minio
run: python3 main.py wait_for "http://localhost:9001/minio/health/live"
run: python3 main.py wait_for minio

- name: Run pytest
run: python3 main.py test
12 changes: 8 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ def test():
run_subprocess(f"docker exec -it {containerName} pytest")


def wait_for_response(url: str):
def wait_for_response(name: str):
"""
Wait for a response from the given url. This is needed to test code in CI/CD since
docker stack does not support conditional waits and the dockerfile logic
would be otherwise messy
"""
url = None
if name == "minio":
url = "http://localhost:9001/minio/health/live"

print(f"Waiting for response from {url}")
TIMEOUT_SEC = 60

Expand Down Expand Up @@ -188,9 +192,9 @@ def main():
subparsers.add_parser("test", help="Run pytest inside the user code container")
wait_for_parser = subparsers.add_parser(
"wait_for",
help="Wait for a 200 response from the given url. Helpful for CI/CD scripts",
help="Wait for a 200 response from the given service. Helpful for CI/CD scripts",
)
wait_for_parser.add_argument("url", help="The url to wait for")
wait_for_parser.add_argument("service", help="The service to wait for")

args = parser.parse_args()
if args.command == "down":
Expand All @@ -204,7 +208,7 @@ def main():
elif args.command == "test":
test()
elif args.command == "wait_for":
wait_for_response(args.url)
wait_for_response(args.service)
else:
parser.print_help()

Expand Down

0 comments on commit 89d1c28

Please sign in to comment.