Skip to content

Commit 0f326a9

Browse files
committed
chore: local readme
1 parent 2440dde commit 0f326a9

File tree

2 files changed

+12
-92
lines changed

2 files changed

+12
-92
lines changed

.evergreen/run-deployed-lambda-aws-tests.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
#!/bin/bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

4-
# export DRIVERS_ATLAS_PUBLIC_API_KEY=${DRIVERS_ATLAS_PUBLIC_API_KEY}
5-
# export DRIVERS_ATLAS_PRIVATE_API_KEY=${DRIVERS_ATLAS_PRIVATE_API_KEY}
6-
# export DRIVERS_ATLAS_LAMBDA_USER=${DRIVERS_ATLAS_LAMBDA_USER}
7-
# export DRIVERS_ATLAS_LAMBDA_PASSWORD=${DRIVERS_ATLAS_LAMBDA_PASSWORD}
8-
# export DRIVERS_ATLAS_GROUP_ID=${DRIVERS_ATLAS_GROUP_ID}
9-
# export TEST_LAMBDA_DIRECTORY=${TEST_LAMBDA_DIRECTORY}
10-
# export LAMBDA_STACK_NAME=${LAMBDA_STACK_NAME}
11-
# export AWS_REGION=${AWS_REGION}
12-
13-
# TODO(BUILD-16797): Install sam on EVG
4+
# TODO(BUILD-16902): Install SAM on Evergreen boxes.
145
curl -L https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip -o aws-sam-cli-linux-x86_64.zip
156
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
167
sudo ./sam-installation/install

test/lambda/README.md

Lines changed: 11 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,17 @@
1-
Prerequisites:
2-
- AWS SAM CLI
3-
- Docker daemon running
4-
5-
Environment:
6-
- `LAMBDA_AWS_ROLE_ARN`
7-
- `LAMBDA_STACK_NAME`
8-
- `DRIVERS_ATLAS_GROUP_ID`
9-
- `MONGODB_URI`
10-
- `AWS_ACCESS_KEY_ID`
11-
- `AWS_SECRET_ACCESS_KEY`
12-
- `AWS_REGION`
13-
14-
Function Setup:
15-
16-
1. `sam init` and follow instructions for your language, creating a hello world example.
17-
18-
2. Modify the generated function and template.yaml, renaming as needed, and add the
19-
following functionality:
20-
- Must create and cache a `MongoClient` during the init phase of the function.
21-
- For dynamic languages this is at module load time.
22-
- For static languages this can be done in the function constructor.
23-
- The MongoClient must get the uri from the `MONGODB_URI` environment variable.
24-
- The following events must be listened to on the client, and should be added and removed
25-
within the handler function itself.
26-
- command started
27-
- command succeeded
28-
- command failed
29-
- server heartbeat started
30-
- server heartbeat succeeded
31-
- server heartbeat failed
32-
- connection created
33-
- connection closed
34-
- The function itself must insert one document and delete that document
35-
- The function must return JSON with the average duration times of each suceeded
36-
event, the number of connections created and closed, and heartbeat count:
37-
```json
38-
{
39-
"averageCommandSuceeded": 40,
40-
"averageHeartbeatSuceeded": 20,
41-
"openConnections": 1,
42-
"heartbeatCount": 10
43-
}
44-
```
45-
- Update template.yaml to provide a default MONGODB_URI in the Globals section:
46-
```yaml
47-
Globals:
48-
Function:
49-
Timeout: 10
50-
Environment:
51-
Variables:
52-
MONGODB_URI: 'mongodb://127.0.0.1:27017'
53-
```
54-
55-
3. Create env.json with the format:
56-
```json
57-
{
58-
"Parameters": {
59-
"MONGODB_URI": "<uri to test>"
60-
}
61-
}
62-
```
63-
64-
4. `sam build` from the project directory to build the function.
1+
AWS Lambda Testing
2+
------------------
653

66-
5. `sam local invoke --env-vars ./env.json` to create the container and run the function locally.
4+
Running locally
5+
===============
676

68-
Function Testing:
69-
70-
1. Create an Atlas M10 sharded cluster.
71-
72-
2. Get URI to connect to cluster.
73-
74-
3. Set MONGODB_URI in the function environment.
75-
76-
4. `sam build`
77-
78-
5. Assume role DRIVERS-2384
79-
80-
6. `sam deploy ==stack-name ${LAMBDA_STACK_NAME}` --capabilities CAPABILITY_IAM --resolve-s3`
7+
Prerequisites:
818

82-
7. Get the function arn
9+
- AWS SAM CLI
10+
- Docker daemon running
8311

84-
7. `aws lambda invoke --function-name <function arn> standard.json`
12+
Steps
13+
=====
8514

86-
8. Sleep 30 seconds.
15+
- `sam build` from the `test/lambda`.
8716

88-
7. `aws lambda invoke --function-name <function arn> standard.json`
17+
- `sam local invoke --parameter-overrides "MongoDbUri=mongodb://127.0.0.1:27017"`

0 commit comments

Comments
 (0)