Skip to content

GODRIVER-3046 [master] Fix FaaS Test Configuration #1559

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

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ tasks:
shell: bash
add_expansions_to_env: true
env:
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/internal/test/faas/awslambda
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/internal/cmd/faas/awslambda
LAMBDA_STACK_NAME: dbx-go-lambda
AWS_REGION: us-east-1
script: |
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ venv
test.suite

# AWS SAM-generated files
internal/test/faas/awslambda/.aws-sam
internal/test/faas/awslambda/events/event.json
internal/cmd/faas/awslambda/.aws-sam
internal/cmd/faas/awslambda/events/event.json

# Ignore compiled binaries from the compilecheck
internal/test/compilecheck/compilecheck
internal/test/compilecheck/compilecheck.so
internal/cmd/compilecheck/compilecheck
internal/cmd/compilecheck/compilecheck.so

# Ignore api report files
api-report.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"go.mongodb.org/mongo-driver/event"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/event"
"go.mongodb.org/mongo-driver/mongo/options"
)

Expand All @@ -41,12 +41,12 @@ type eventListener struct {
func (listener *eventListener) commandMonitor() *event.CommandMonitor {
succeeded := func(_ context.Context, e *event.CommandSucceededEvent) {
listener.commandCount++
listener.commandDuration += e.DurationNanos
listener.commandDuration += e.Duration.Nanoseconds()
}

failed := func(_ context.Context, e *event.CommandFailedEvent) {
listener.commandCount++
listener.commandDuration += e.DurationNanos
listener.commandDuration += e.Duration.Nanoseconds()
}

return &event.CommandMonitor{
Expand All @@ -61,7 +61,7 @@ func (listener *eventListener) commandMonitor() *event.CommandMonitor {
func (listener *eventListener) serverMonitor() *event.ServerMonitor {
succeeded := func(e *event.ServerHeartbeatSucceededEvent) {
listener.heartbeatCount++
listener.heartbeatDuration += e.DurationNanos
listener.heartbeatDuration += e.Duration.Nanoseconds()

if e.Awaited {
listener.heartbeatAwaitedCount++
Expand All @@ -70,7 +70,7 @@ func (listener *eventListener) serverMonitor() *event.ServerMonitor {

failed := func(e *event.ServerHeartbeatFailedEvent) {
listener.heartbeatCount++
listener.heartbeatDuration += e.DurationNanos
listener.heartbeatDuration += e.Duration.Nanoseconds()

if e.Awaited {
listener.heartbeatAwaitedCount++
Expand Down Expand Up @@ -130,16 +130,11 @@ func handler(ctx context.Context, request events.APIGatewayProxyRequest) (events

// Create a MongoClient that points to MONGODB_URI and listens to the
// ComandMonitor, ServerMonitor, and PoolMonitor events.
client, err := mongo.NewClient(clientOptions)
client, err := mongo.Connect(clientOptions)
if err != nil {
return gateway500(), fmt.Errorf("failed to create client: %w", err)
}

// Attempt to connect to the client with a timeout.
if err = client.Connect(ctx); err != nil {
return gateway500(), fmt.Errorf("failed to connect: %w", err)
}

defer client.Disconnect(ctx)

collection := client.Database("faas").Collection("lambda")
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/faas/awslambda/mongodb/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
require (
github.com/golang/snappy v0.0.1 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/faas/awslambda/mongodb/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/faas/awslambda/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ Globals:
Resources:
MongoDBFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: go1.x
Properties:
CodeUri: mongodb/
Handler: main
Runtime: go1.x
Architectures:
- x86_64
Handler: bootstrap
Runtime: provided.al2
Architectures: [arm64]
Events:
MongoDB:
Type: Api
Expand Down Expand Up @@ -54,5 +55,4 @@ Outputs:
Value: !GetAtt MongoDBFunction.Arn
MongoDBFunctionIamRole:
Description: "Implicit IAM Role created for MongoDB function"
Value: !GetAtt MongoDBFunctionRole.Arn

Value: !GetAtt MongoDBFunctionRole.Arn