Skip to content

Commit

Permalink
test(DRIVERS-2657): update faas testing spec (#1438)
Browse files Browse the repository at this point in the history
* test(DRIVERS-2657): update faas testing spec

* chore: update per suggestions

* fix: table formatting

* fix: moved atlas scripts
  • Loading branch information
durran authored Jun 28, 2023
1 parent 6b267dd commit 8debfae
Showing 1 changed file with 50 additions and 38 deletions.
88 changes: 50 additions & 38 deletions source/faas-automated-testing/faas-automated-testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Running in CI requires Evergreen to be setup to assume the appropriate role in A
and then execute the script in drivers-evergreen-tools with the required environment
variables. An explanation of the required environment is as follows:

+-------------------------------+----------+--------------------------+
+-------------------------------+-------------------------------------+
| Name | Description |
+===============================+=====================================+
| LAMBDA_AWS_ROLE_ARN | The role ARN to assume |
Expand Down Expand Up @@ -286,63 +286,75 @@ Supported Evergreen variants that have the AWS SAM CLI installed:
- rhel82-arm64


This is an example function in the Evergreen config that accomplishes this, using
subprocess.exec to execute a script that calls the drivers-evergreen-tools
function inside of it:
This is an example task group in the Evergreen config that accomplishes this, using
subprocess.exec to execute scripts that call the drivers-evergreen-tools
functions inside of it for setup, teardown, and execution:

.. code:: yaml
run deployed aws lambda tests:
- command: ec2.assume_role
params:
role_arn: ${LAMBDA_AWS_ROLE_ARN}
- command: subprocess.exec
params:
working_dir: src
binary: bash
args:
- .evergreen/run-deployed-lambda-aws-tests.sh
env:
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
DRIVERS_ATLAS_PUBLIC_API_KEY: ${DRIVERS_ATLAS_PUBLIC_API_KEY}
DRIVERS_ATLAS_PRIVATE_API_KEY: ${DRIVERS_ATLAS_PRIVATE_API_KEY}
DRIVERS_ATLAS_LAMBDA_USER: ${DRIVERS_ATLAS_LAMBDA_USER}
DRIVERS_ATLAS_LAMBDA_PASSWORD: ${DRIVERS_ATLAS_LAMBDA_PASSWORD}
DRIVERS_ATLAS_GROUP_ID: ${DRIVERS_ATLAS_GROUP_ID}
LAMBDA_STACK_NAME: dbx-node-lambda
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN}
tasks:
- name: "test-aws-lambda-deployed"
commands:
- func: "install dependencies"
- command: ec2.assume_role
params:
role_arn: ${LAMBDA_AWS_ROLE_ARN}
duration_seconds: 3600
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/aws_lambda/run-deployed-lambda-aws-tests.sh
env:
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
AWS_REGION: us-east-1
task_groups:
- name: test_aws_lambda_task_group
setup_group:
- func: fetch source
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
params:
file: src/atlas-expansion.yml
teardown_group:
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-aws-lambda-deployed
Drivers MUST run the function on a single variant in Evergreen, in order to not
potentially hit the Atlas API rate limit. The variant itself MUST be either a
RHEL8 or Ubuntu 20 variant in order to have the SAM CLI installed.

The script itself:

.. code:: none
#!/bin/bash
set -o errexit # Exit the script with error if any of the commands fail
. ${DRIVERS_TOOLS}/.evergreen/run-deployed-lambda-aws-tests.sh
Description of the behaviour of run-deployed-lambda-aws-tests.sh:

- Creates a new Atlas cluster in a specific driver project
- Polls for the cluster SRV record when cluster creation is complete
- Builds the Lambda function locally
- Deploys the Lambda function to AWS.
- Queries for the Lambda function ARN.
- Invokes the Lambda function cold and frozen.
- Initiates a primary failover of the cluster in Atlas.
- Calls the frozen lambda function again.
- Deletes the Lambda function.
- Deletes the Atlas cluster.


Changelog
=========

:2023-06-22: Updated evergreen configuration to use task groups.
:2023-04-14: Added list of supported variants, added additional template config.

0 comments on commit 8debfae

Please sign in to comment.