Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(DRIVERS-2657): break out lambda scripts #325

Merged
merged 18 commits into from
Jun 28, 2023
Merged

test(DRIVERS-2657): break out lambda scripts #325

merged 18 commits into from
Jun 28, 2023

Conversation

durran
Copy link
Member

@durran durran commented Jun 22, 2023

Breaks out the scripts that run the lambda tests into multiple scripts, with the atlas create/delete cluster scripts broken out so that they can be run in setup/teardown on evergreen task groups.

Node.js impl: mongodb/node-mongodb-native#3740
Spec changes: mongodb/specifications#1438
Original script: For context, the original script is https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/run-deployed-lambda-aws-tests.sh

Example evergreen config:

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

@durran durran changed the title Drivers 2657 test(DRIVERS-2657): break out lambda scripts Jun 22, 2023
@durran durran marked this pull request as ready for review June 23, 2023 12:01
Co-authored-by: Bailey Pearson <bailey.pearson@gmail.com>
@blink1073
Copy link
Member

Does the lambda stack deletion need to be part of teardown as well?

# DRIVERS_ATLAS_PRIVATE_API_KEY: The private Atlas key for the drivers org.
# DRIVERS_ATLAS_GROUP_ID: The id of the individual projects under the drivers org, per language.
# LAMBDA_STACK_NAME: The name of the stack on lambda "dbx-<language>-lambda"
# AWS_REGION: The region for the function - generally us-east-1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this script appears to be specifically written to run after the "setup-atlas-cluster", since we are breaking it out can we include the "MONGODB_URI" in the list of required environment variables?

I think it would be useful to note this, in the case an engineer wants to run the tests locally i.e.

PROJECT_DIRECTORY="mongo-go-driver"
DRIVERS_TOOLS="drivers-evergreen-tools"

# Change the directory to DRIVERS_TOOLS
cd $DRIVERS_TOOLS

TEST_LAMBDA_DIRECTORY="$PROJECT_DIRECTORY/internal/test/faas/awslambda" \
DRIVERS_ATLAS_PUBLIC_API_KEY="" \
DRIVERS_ATLAS_PRIVATE_API_KEY="" \
DRIVERS_ATLAS_GROUP_ID="" \
LAMBDA_STACK_NAME="dbx-go-lambda" \
MONGODB_URI="mongodb://localhost:27017" \
AWS_REGION="us-east-1" \
. .evergreen/aws_lambda/run-deployed-lambda-aws-tests.sh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added MONGODB_URI as a required env variable in the comments.


# The base Atlas API url. We use the API directly as the CLI does not yet
# support testing cluster outages.
ATLAS_BASE_URL="https://cloud.mongodb.com/api/atlas/v1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we decouple the version in the ATLAS_BASE_URL?

Suggested change
ATLAS_BASE_URL="https://cloud.mongodb.com/api/atlas/v1.0"
ATLAS_API_VERSION="v.10"
ATLAS_BASE_URL="https://cloud.mongodb.com/api/atlas/$ATLAS_API_VERSION"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


# The base Atlas API url. We use the API directly as the CLI does not yet
# support testing cluster outages.
ATLAS_BASE_URL="https://cloud.mongodb.com/api/atlas/v1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we decouple the version in the ATLAS_BASE_URL?

Suggested change
ATLAS_BASE_URL="https://cloud.mongodb.com/api/atlas/v1.0"
ATLAS_API_VERSION="v.10"
ATLAS_BASE_URL="https://cloud.mongodb.com/api/atlas/$ATLAS_API_VERSION"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@durran
Copy link
Member Author

durran commented Jun 26, 2023

Does the lambda stack deletion need to be part of teardown as well?

@blink1073 I didn't split out lambda cloud formation deploy/delete into their own setup/teardown as I wanted it to be apparent in the main task that it was a lambda flow with the assume role and running of the script, with the atlas related tasks being split out. I can split those out as well if you feel strongly about it.

@durran durran requested a review from alcaeus June 26, 2023 21:06
Co-authored-by: Andreas Braun <alcaeus@users.noreply.github.com>
@alcaeus alcaeus merged commit 797f71c into master Jun 28, 2023
12 checks passed
@alcaeus alcaeus deleted the DRIVERS-2657 branch June 28, 2023 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants