Skip to content

Commit d0d044a

Browse files
authored
Update contributing test setup (#466)
add additional steps to test setup instructions
1 parent c3cd501 commit d0d044a

File tree

6 files changed

+74
-3
lines changed

6 files changed

+74
-3
lines changed

CONTRIBUTING.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ You can choose from three different environments to test your fixes/changes, bas
100100

101101
* To run a specific test function:
102102

103-
``pytest tests/test_moto::test_get_bucket_region_succeed``
103+
``pytest tests/test_moto.py::test_get_bucket_region_succeed``
104104

105105
* To run all mocked test functions (Using 8 parallel processes):
106106

@@ -121,6 +121,10 @@ You can choose from three different environments to test your fixes/changes, bas
121121

122122
``pip install -r requirements-dev.txt``
123123

124+
* [OPTIONAL] Set AWS_DEFAULT_REGION to define the region the Data Lake Test envrioment will deploy into. You may want to choose a region which you don't currently use:
125+
126+
``export AWS_DEFAULT_REGION=ap-northeast-1``
127+
124128
* Go to the ``cloudformation`` directory
125129

126130
``cd cloudformation``
@@ -145,10 +149,16 @@ You can choose from three different environments to test your fixes/changes, bas
145149

146150
``pytest -n 8 tests/test_athena*``
147151

152+
* [OPTIONAL] To remove the base test environment cloud formation stack post testing:
153+
154+
``./cloudformation/delete-base.sh``
155+
148156
### Full test environment
149157

150158
**DISCLAIMER**: Make sure you know what you are doing. These steps will charge some services on your AWS account and require a minimum security skill to keep your environment safe.
151159

160+
**DISCLAIMER**: This environment contains Aurora MySQL, Aurora PostgreSQL and Redshift (single-node) clusters which will incur cost while running.
161+
152162
* Pick up a Linux or MacOS.
153163
* Install Python 3.6, 3.7 and 3.8
154164
* Fork the AWS Data Wrangler repository and clone that into your development environment
@@ -160,16 +170,27 @@ You can choose from three different environments to test your fixes/changes, bas
160170

161171
``pip install -r requirements-dev.txt``
162172

173+
* [OPTIONAL] Set AWS_DEFAULT_REGION to define the region the Full Test envrioment will deploy into. You may want to choose a region which you don't currently use:
174+
175+
``export AWS_DEFAULT_REGION=ap-northeast-1``
176+
163177
* Go to the ``cloudformation`` directory
164178

165179
``cd cloudformation``
166180

167-
* Deploy the Cloudformation templates `base.yaml` and `databases.yaml`
181+
* Deploy the Cloudformation templates `base.yaml` and `databases.yaml`. This step could take about 15 minutes to deploy.
168182

169183
``./deploy-base.sh``
170184
``./deploy-databases.sh``
171185

172186
* Go to the `EC2 -> SecurityGroups` console, open the `aws-data-wrangler-*` security group and configure to accept your IP from any TCP port.
187+
- Alternatively run:
188+
189+
``./security-group-databases-add-local-ip.sh``
190+
191+
- Check local IP was applied:
192+
193+
``./security-group-databases-check.sh``
173194

174195
``P.S Make sure that your security group will not be open to the World! Configure your security group to only give access for your IP.``
175196

@@ -185,12 +206,22 @@ You can choose from three different environments to test your fixes/changes, bas
185206

186207
* To run a specific test function:
187208

188-
``pytest tests/test_athena_parquet.py::test_parquet_catalog``
209+
``pytest tests/test_db.py::test_sql``
210+
211+
* To run all database test functions (Using 8 parallel processes):
212+
213+
``pytest -n 8 tests/test_db.py``
189214

190215
* To run all data lake test functions for all python versions (Only if Amazon QuickSight is activated):
191216

192217
``./test.sh``
193218

219+
* [OPTIONAL] To remove the base test environment cloud formation stack post testing:
220+
221+
``./cloudformation/delete-base.sh``
222+
223+
``./cloudformation/delete-databases.sh``
224+
194225
## Recommended Visual Studio Code Recommended settings
195226

196227
```json

cloudformation/databases.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,8 @@ Outputs:
408408
- AuroraInstanceMysql
409409
- Endpoint.Address
410410
Description: Mysql Address
411+
DatabaseSecurityGroupId:
412+
Value:
413+
Fn::GetAtt:
414+
- DatabaseSecurityGroup
415+
- GroupId

cloudformation/delete-base.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Deploying
5+
aws cloudformation delete-stack \
6+
--stack-name aws-data-wrangler-base

cloudformation/delete-databases.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Deleting
5+
aws cloudformation delete-stack \
6+
--stack-name aws-data-wrangler-databases
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Get my current IP address
5+
LOCALIP=`host myip.opendns.com resolver1.opendns.com | grep myip | awk '{print $4}'`
6+
7+
# Get security group ID
8+
SGID=`aws cloudformation describe-stacks --stack-name aws-data-wrangler-databases --query "Stacks[0].Outputs[?OutputKey=='DatabaseSecurityGroupId'].OutputValue" --output text`
9+
10+
# Update Security Group with local ip
11+
aws ec2 authorize-security-group-ingress \
12+
--group-id ${SGID} \
13+
--protocol all \
14+
--port -1 \
15+
--cidr ${LOCALIP}/32
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Get security group ID
5+
SGID=`aws cloudformation describe-stacks --stack-name aws-data-wrangler-databases --query "Stacks[0].Outputs[?OutputKey=='DatabaseSecurityGroupId'].OutputValue" --output text`
6+
7+
# Check to see current setting
8+
aws ec2 describe-security-groups --group-id ${SGID}

0 commit comments

Comments
 (0)