Skip to content

Commit d50b214

Browse files
committed
Add DynamoDB to tests and CloudFormation
1 parent 34efdc6 commit d50b214

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

testing/template.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,22 @@ Resources:
376376
}
377377
Name: "aws-data-wrangler-mysql"
378378

379+
DynamoDBTable:
380+
Type: AWS::DynamoDB::Table
381+
Properties:
382+
AttributeDefinitions:
383+
- AttributeName: "attr_hash"
384+
AttributeType: "S"
385+
- AttributeName: "attr_range"
386+
AttributeType: "S"
387+
KeySchema:
388+
- AttributeName: "attr_hash"
389+
KeyType: "HASH"
390+
- AttributeName: "attr_range"
391+
KeyType: "RANGE"
392+
BillingMode: "PAY_PER_REQUEST"
393+
TableName: "aws-data-wrangler-test"
394+
379395
Outputs:
380396
BucketName:
381397
Value: !Ref Bucket
@@ -415,4 +431,7 @@ Outputs:
415431
Description: Postgres Address
416432
MysqlAddress:
417433
Value: !GetAtt AuroraInstanceMysql.Endpoint.Address
418-
Description: Mysql Address
434+
Description: Mysql Address
435+
DynamoDbTableARN:
436+
Value: !GetAtt DynamoDBTable.Arn
437+
Description: DynamoDB table name
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import logging
2+
3+
import boto3
4+
import pytest
5+
6+
# import awswrangler as wr
7+
8+
logging.basicConfig(level=logging.INFO, format="[%(asctime)s][%(levelname)s][%(name)s][%(funcName)s] %(message)s")
9+
logging.getLogger("awswrangler").setLevel(logging.DEBUG)
10+
11+
12+
@pytest.fixture(scope="module")
13+
def cloudformation_outputs():
14+
response = boto3.client("cloudformation").describe_stacks(StackName="aws-data-wrangler-test")
15+
outputs = {}
16+
for output in response.get("Stacks")[0].get("Outputs"):
17+
outputs[output.get("OutputKey")] = output.get("OutputValue")
18+
yield outputs
19+
20+
21+
@pytest.fixture(scope="module")
22+
def ddb_table_arn(session, cloudformation_outputs):
23+
if "DynamoDbTableARN" in cloudformation_outputs:
24+
arn = cloudformation_outputs["DynamoDbTableARN"]
25+
else:
26+
raise Exception("You must deploy the test infrastructure using Cloudformation!")
27+
yield arn

0 commit comments

Comments
 (0)