Skip to content

Commit

Permalink
CSHARP-5479: Fix AWS lambda tests (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
adelinowona authored Feb 4, 2025
1 parent e3f3943 commit ed795aa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
16 changes: 8 additions & 8 deletions evergreen/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,9 @@ tasks:
params:
role_arn: ${LAMBDA_AWS_ROLE_ARN}
duration_seconds: 3600
- func: install-dotnet
vars:
DOTNET_SDK_VERSION: 8.0
- command: shell.exec
params:
working_dir: mongo-csharp-driver
Expand All @@ -1529,6 +1532,7 @@ tasks:
${PREPARE_SHELL}
evergreen/run-deployed-lambda-aws-tests.sh
env:
LAMBDA_STACK_NAME: dbx-csharp-lambda
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/tests/FaasTests/LambdaTests
AWS_REGION: us-east-1

Expand Down Expand Up @@ -2067,8 +2071,6 @@ task_groups:
- "AWS_ACCESS_KEY_ID"
- "AWS_SECRET_ACCESS_KEY"
- "AWS_SESSION_TOKEN"
env:
VAULT_NAME: "azurekms"
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup-secrets.sh
- command: subprocess.exec
Expand Down Expand Up @@ -2115,8 +2117,6 @@ task_groups:
- "AWS_ACCESS_KEY_ID"
- "AWS_SECRET_ACCESS_KEY"
- "AWS_SESSION_TOKEN"
env:
VAULT_NAME: "gcpkms"
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/setup-secrets.sh
- command: subprocess.exec
Expand Down Expand Up @@ -2161,10 +2161,9 @@ task_groups:
- "AWS_ACCESS_KEY_ID"
- "AWS_SECRET_ACCESS_KEY"
- "AWS_SESSION_TOKEN"
env:
VAULT_NAME: "atlas"
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-secrets.sh
- "atlas"
- command: subprocess.exec
params:
binary: bash
Expand Down Expand Up @@ -2196,17 +2195,18 @@ task_groups:
- command: subprocess.exec
params:
binary: bash
add_expansions_to_env: true
env:
LAMBDA_STACK_NAME: dbx-csharp-lambda
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
params:
file: atlas-expansion.yml
redact_file_expansions: true
teardown_group:
- command: subprocess.exec
params:
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
tasks:
Expand Down
18 changes: 5 additions & 13 deletions evergreen/run-deployed-lambda-aws-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

LOCALTOOLPATH=$TEST_LAMBDA_DIRECTORY/localtool
# SAM CLI installs the "Amazon.Lambda.Tools" tool in this location so we need to add it to our PATH
export PATH="$PATH:$HOME/.dotnet/tools"

echo "Installing aws lambda tool to a custom location"
dotnet tool install "Amazon.Lambda.Tools" --tool-path $LOCALTOOLPATH
# setting this as SAM CLI seems to check DOTNET_ROOT directly instead of the PATH
export DOTNET_ROOT=$DOTNET_SDK_PATH

# makes the "sam build" command use the local version of the lambda tool
export PATH="$PATH:$LOCALTOOLPATH"

. ${DRIVERS_TOOLS}/.evergreen/aws_lambda/run-deployed-lambda-aws-tests.sh

# uninstall global version installed by the "sam build" command
dotnet tool uninstall -g "Amazon.Lambda.Tools"

# uninstall our local version
dotnet tool uninstall "Amazon.Lambda.Tools" --tool-path $LOCALTOOLPATH
. ${DRIVERS_TOOLS}/.evergreen/aws_lambda/run-deployed-lambda-aws-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<IsPackable>false</IsPackable>
Expand Down
16 changes: 1 addition & 15 deletions tests/FaasTests/LambdaTests/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Resources:
Properties:
CodeUri: MongoDB.Driver.LambdaTest/
Handler: MongoDB.Driver.LambdaTest::MongoDB.Driver.LambdaTest.LambdaFunction::LambdaFunctionHandlerAsync
Runtime: dotnet6
Runtime: dotnet8
Architectures:
- x86_64
Environment:
Expand All @@ -33,20 +33,6 @@ Resources:
Properties:
Path: /mongodb
Method: get

ApplicationResourceGroup:
Type: AWS::ResourceGroups::Group
Properties:
Name:
Fn::Sub: ApplicationInsights-SAM-${AWS::StackName}
ResourceQuery:
Type: CLOUDFORMATION_STACK_1_0
ApplicationInsightsMonitoring:
Type: AWS::ApplicationInsights::Application
Properties:
ResourceGroupName:
Ref: ApplicationResourceGroup
AutoConfigurationEnabled: 'true'
Outputs:
LambdaTestApi:
Description: API Gateway endpoint URL for Prod stage for C# Driver Lambda Test function
Expand Down

0 comments on commit ed795aa

Please sign in to comment.