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

patch(pytest_plugins/microceph): Add retry if microceph not ready #175

Merged
merged 4 commits into from
May 14, 2024
Merged
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
24 changes: 18 additions & 6 deletions python/pytest_plugins/microceph/pytest_microceph/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import logging
import os
import subprocess
import time

import boto3
import botocore.exceptions
import pytest


Expand Down Expand Up @@ -43,12 +45,22 @@ def microceph():
key_id = key["access_key"]
secret_key = key["secret_key"]
logger.info("Creating microceph bucket")
boto3.client(
"s3",
endpoint_url="http://localhost",
aws_access_key_id=key_id,
aws_secret_access_key=secret_key,
).create_bucket(Bucket=_BUCKET)
for attempt in range(3):
try:
boto3.client(
"s3",
endpoint_url="http://localhost",
aws_access_key_id=key_id,
aws_secret_access_key=secret_key,
).create_bucket(Bucket=_BUCKET)
except botocore.exceptions.EndpointConnectionError:
if attempt == 2:
raise
# microceph is not ready yet
logger.info("Unable to connect to microceph via S3. Retrying")
time.sleep(1)
else:
break
logger.info("Set up microceph")
return ConnectionInformation(key_id, secret_key, _BUCKET)

Expand Down