Skip to content

Commit fe0740f

Browse files
authored
Add endpoint variable for fixing CI (#147)
* Fix test workflow
1 parent 39c5524 commit fe0740f

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

.github/workflows/python-integration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ jobs:
3030
bucket: ${{ vars.S3_BUCKET }}
3131
region: ${{ vars.S3_REGION }}
3232
storage-class: ""
33+
endpoint-url: ${{ vars.S3_CUSTOM_ENDPOINT_URL }}
3334
- name: "S3 Express"
3435
bucket: ${{ vars.S3_EXPRESS_BUCKET }}
3536
region: ${{ vars.S3_EXPRESS_REGION }}
3637
storage-class: "EXPRESS_ONEZONE"
38+
endpoint-url: ""
3739
permissions:
3840
id-token: write
3941
contents: read
@@ -95,6 +97,7 @@ jobs:
9597
CI_REGION=${{ matrix.test-run.region }} \
9698
CI_BUCKET=${{ matrix.test-run.bucket }} \
9799
CI_STORAGE_CLASS=${{ matrix.test-run.storage-class }} \
100+
CI_CUSTOM_ENDPOINT_URL=${{ matrix.test-run.endpoint-url }} \
98101
pytest s3torchconnectorclient/python/tst/integration -n auto
99102
100103
- name: Save Cargo cache

run_cibuildwheel_on_ec2.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ BUCKET_NAME=$3
1010
PREFIX=$4
1111
EXPRESS_REGION_NAME=$5
1212
EXPRESS_BUCKET_NAME=$6
13+
S3_CUSTOM_ENDPOINT_URL=$7
1314

1415
FILE_NAME="tmp_cred.json"
1516
# Set metadata token TTL to 6 hours
@@ -28,5 +29,6 @@ export S3_BUCKET=${BUCKET_NAME}
2829
export S3_PREFIX=${PREFIX}
2930
export S3_EXPRESS_REGION=${EXPRESS_REGION_NAME}
3031
export S3_EXPRESS_BUCKET=${EXPRESS_BUCKET_NAME}
32+
export S3_CUSTOM_ENDPOINT_URL=${S3_CUSTOM_ENDPOINT_URL}
3133

3234
cibuildwheel --output-dir wheelhouse --platform linux s3torchconnectorclient

s3torchconnectorclient/pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ test-extras = "test"
4747
test-command = [
4848
"pytest {package}/python/tst/unit",
4949
"pytest {package}/../s3torchconnector/tst/unit",
50-
"CI_STORAGE_CLASS='' CI_REGION=${S3_REGION} CI_BUCKET=${S3_BUCKET} CI_PREFIX=${S3_PREFIX} pytest {package}/python/tst/integration",
51-
"CI_STORAGE_CLASS='' CI_REGION=${S3_REGION} CI_BUCKET=${S3_BUCKET} CI_PREFIX=${S3_PREFIX} pytest {package}/../s3torchconnector/tst/e2e",
52-
"CI_STORAGE_CLASS=EXPRESS_ONEZONE CI_REGION=${S3_EXPRESS_REGION} CI_BUCKET=${S3_EXPRESS_BUCKET} CI_PREFIX=${S3_PREFIX} pytest {package}/python/tst/integration",
53-
"CI_STORAGE_CLASS=EXPRESS_ONEZONE CI_REGION=${S3_EXPRESS_REGION} CI_BUCKET=${S3_EXPRESS_BUCKET} CI_PREFIX=${S3_PREFIX} pytest {package}/../s3torchconnector/tst/e2e",
50+
"CI_STORAGE_CLASS='' CI_REGION=${S3_REGION} CI_BUCKET=${S3_BUCKET} CI_PREFIX=${S3_PREFIX} CI_CUSTOM_ENDPOINT_URL=${S3_CUSTOM_ENDPOINT_URL} pytest {package}/python/tst/integration",
51+
"CI_STORAGE_CLASS='' CI_REGION=${S3_REGION} CI_BUCKET=${S3_BUCKET} CI_PREFIX=${S3_PREFIX} CI_CUSTOM_ENDPOINT_URL=${S3_CUSTOM_ENDPOINT_URL} pytest {package}/../s3torchconnector/tst/e2e",
52+
"CI_STORAGE_CLASS=EXPRESS_ONEZONE CI_REGION=${S3_EXPRESS_REGION} CI_BUCKET=${S3_EXPRESS_BUCKET} CI_PREFIX=${S3_PREFIX} CI_CUSTOM_ENDPOINT_URL='' pytest {package}/python/tst/integration",
53+
"CI_STORAGE_CLASS=EXPRESS_ONEZONE CI_REGION=${S3_EXPRESS_REGION} CI_BUCKET=${S3_EXPRESS_BUCKET} CI_PREFIX=${S3_PREFIX} CI_CUSTOM_ENDPOINT_URL='' pytest {package}/../s3torchconnector/tst/e2e",
5454
]
5555
environment-pass = [
5656
"AWS_ACCESS_KEY_ID",
@@ -60,7 +60,8 @@ environment-pass = [
6060
"S3_BUCKET",
6161
"S3_PREFIX",
6262
"S3_EXPRESS_BUCKET",
63-
"S3_EXPRESS_REGION"
63+
"S3_EXPRESS_REGION",
64+
"S3_CUSTOM_ENDPOINT_URL"
6465
]
6566
before-build = "cp README.md s3torchconnectorclient; cp LICENSE s3torchconnectorclient/; cp THIRD-PARTY-LICENSES s3torchconnectorclient/; cp NOTICE s3torchconnectorclient/"
6667
build = ["cp38*", "cp39*", "cp310*", "cp311*"]

s3torchconnectorclient/python/tst/integration/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,21 @@ class BucketPrefixFixture(object):
2626
bucket: str
2727
prefix: str
2828
storage_class: str = None
29+
endpoint_url: str = None
2930

3031
def __init__(
31-
self, region: str, bucket: str, prefix: str, storage_class: str = None
32+
self,
33+
region: str,
34+
bucket: str,
35+
prefix: str,
36+
storage_class: str = None,
37+
endpoint_url: str = None,
3238
):
3339
self.bucket = bucket
3440
self.prefix = prefix
3541
self.region = region
3642
self.storage_class = storage_class
43+
self.endpoint_url = endpoint_url
3744
self.contents = {}
3845
session = boto3.Session(region_name=region)
3946
self.s3 = session.client("s3")
@@ -61,12 +68,13 @@ def get_test_bucket_prefix(name: str) -> BucketPrefixFixture:
6168
prefix = getenv("CI_PREFIX")
6269
region = getenv("CI_REGION")
6370
storage_class = getenv("CI_STORAGE_CLASS", optional=True)
71+
endpoint_url = getenv("CI_CUSTOM_ENDPOINT_URL", optional=True)
6472
assert prefix == "" or prefix.endswith("/")
6573

6674
nonce = random.randrange(2**64)
6775
prefix = f"{prefix}{name}/{nonce}/"
6876

69-
return BucketPrefixFixture(region, bucket, prefix, storage_class)
77+
return BucketPrefixFixture(region, bucket, prefix, storage_class, endpoint_url)
7078

7179

7280
@pytest.fixture

s3torchconnectorclient/python/tst/integration/test_mountpoint_s3_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_get_object_with_endpoint(sample_directory):
4040
client = MountpointS3Client(
4141
sample_directory.region,
4242
TEST_USER_AGENT_PREFIX,
43-
endpoint="http://s3.amazonaws.com",
43+
endpoint=sample_directory.endpoint_url,
4444
)
4545
stream = client.get_object(
4646
sample_directory.bucket, f"{sample_directory.prefix}hello_world.txt"

0 commit comments

Comments
 (0)