Skip to content

Commit 096d89f

Browse files
authored
fix ci build for localstack 2.0 (#4)
1 parent bcadb2a commit 096d89f

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

.github/workflows/integration-test.yml

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ jobs:
3030
- name: Start LocalStack
3131
env:
3232
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
33-
DNS_ADDRESS: 0
34-
EDGE_PORT: 4566
3533
run: |
3634
pip install localstack awscli-local[ver1]
3735
docker pull localstack/localstack

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Pillow==9.2.0
44
mypy_boto3_ssm
55
mypy_boto3_sns
66
mypy_boto3_s3
7+
mypy_boto3_lambda
78
black
89
pytest
910
awscli

tests/test_integration.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import uuid
55

66
import boto3
7+
import pytest
78
import requests
89

910
if typing.TYPE_CHECKING:
1011
from mypy_boto3_s3 import S3Client
1112
from mypy_boto3_ssm import SSMClient
13+
from mypy_boto3_lambda import LambdaClient
1214

1315
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"
1416
os.environ["AWS_ACCESS_KEY_ID"] = "test"
@@ -20,6 +22,17 @@
2022
ssm: "SSMClient" = boto3.client(
2123
"ssm", endpoint_url="http://localhost.localstack.cloud:4566"
2224
)
25+
awslambda: "LambdaClient" = boto3.client(
26+
"lambda", endpoint_url="http://localhost.localstack.cloud:4566"
27+
)
28+
29+
30+
@pytest.fixture(autouse=True)
31+
def _wait_for_lambdas():
32+
# makes sure that the lambdas are available before running integration tests
33+
awslambda.get_waiter("function_active").wait(FunctionName="presign")
34+
awslambda.get_waiter("function_active").wait(FunctionName="resize")
35+
awslambda.get_waiter("function_active").wait(FunctionName="list")
2336

2437

2538
def test_s3_resize_integration():
@@ -34,14 +47,8 @@ def test_s3_resize_integration():
3447

3548
s3.upload_file(file, Bucket=source_bucket, Key=key)
3649

37-
# try for 15 seconds to wait for the resized image
38-
for i in range(15):
39-
try:
40-
s3.head_object(Bucket=target_bucket, Key=key)
41-
break
42-
except:
43-
pass
44-
time.sleep(1)
50+
# wait for the resized image to appear
51+
s3.get_waiter("object_exists").wait(Bucket=target_bucket, Key=key)
4552

4653
s3.head_object(Bucket=target_bucket, Key=key)
4754
s3.download_file(

0 commit comments

Comments
 (0)