Skip to content

Commit 7fd4e30

Browse files
authored
GODRIVER-3046 [master] Fix FaaS Test Configuration (#1559)
1 parent 85ff8d2 commit 7fd4e30

File tree

6 files changed

+17
-25
lines changed

6 files changed

+17
-25
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ tasks:
20102010
shell: bash
20112011
add_expansions_to_env: true
20122012
env:
2013-
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/internal/test/faas/awslambda
2013+
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/internal/cmd/faas/awslambda
20142014
LAMBDA_STACK_NAME: dbx-go-lambda
20152015
AWS_REGION: us-east-1
20162016
script: |

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ venv
2121
test.suite
2222

2323
# AWS SAM-generated files
24-
internal/test/faas/awslambda/.aws-sam
25-
internal/test/faas/awslambda/events/event.json
24+
internal/cmd/faas/awslambda/.aws-sam
25+
internal/cmd/faas/awslambda/events/event.json
2626

2727
# Ignore compiled binaries from the compilecheck
28-
internal/test/compilecheck/compilecheck
29-
internal/test/compilecheck/compilecheck.so
28+
internal/cmd/compilecheck/compilecheck
29+
internal/cmd/compilecheck/compilecheck.so
3030

3131
# Ignore api report files
3232
api-report.md

internal/cmd/faas/awslambda/mongodb/main.go renamed to internal/cmd/faas/awslambda/mongodb/bootstrap.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
"github.com/aws/aws-lambda-go/events"
1818
"github.com/aws/aws-lambda-go/lambda"
19-
"go.mongodb.org/mongo-driver/event"
2019
"go.mongodb.org/mongo-driver/mongo"
20+
"go.mongodb.org/mongo-driver/event"
2121
"go.mongodb.org/mongo-driver/mongo/options"
2222
)
2323

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

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

5252
return &event.CommandMonitor{
@@ -61,7 +61,7 @@ func (listener *eventListener) commandMonitor() *event.CommandMonitor {
6161
func (listener *eventListener) serverMonitor() *event.ServerMonitor {
6262
succeeded := func(e *event.ServerHeartbeatSucceededEvent) {
6363
listener.heartbeatCount++
64-
listener.heartbeatDuration += e.DurationNanos
64+
listener.heartbeatDuration += e.Duration.Nanoseconds()
6565

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

7171
failed := func(e *event.ServerHeartbeatFailedEvent) {
7272
listener.heartbeatCount++
73-
listener.heartbeatDuration += e.DurationNanos
73+
listener.heartbeatDuration += e.Duration.Nanoseconds()
7474

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

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

138-
// Attempt to connect to the client with a timeout.
139-
if err = client.Connect(ctx); err != nil {
140-
return gateway500(), fmt.Errorf("failed to connect: %w", err)
141-
}
142-
143138
defer client.Disconnect(ctx)
144139

145140
collection := client.Database("faas").Collection("lambda")

internal/cmd/faas/awslambda/mongodb/go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require (
1515
require (
1616
github.com/golang/snappy v0.0.1 // indirect
1717
github.com/klauspost/compress v1.13.6 // indirect
18-
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
1918
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
2019
github.com/xdg-go/scram v1.1.2 // indirect
2120
github.com/xdg-go/stringprep v1.0.4 // indirect

internal/cmd/faas/awslambda/mongodb/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
66
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
77
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
88
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
9-
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
10-
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
119
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1210
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
1311
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=

internal/cmd/faas/awslambda/template.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ Globals:
1515
Resources:
1616
MongoDBFunction:
1717
Type: AWS::Serverless::Function
18+
Metadata:
19+
BuildMethod: go1.x
1820
Properties:
1921
CodeUri: mongodb/
20-
Handler: main
21-
Runtime: go1.x
22-
Architectures:
23-
- x86_64
22+
Handler: bootstrap
23+
Runtime: provided.al2
24+
Architectures: [arm64]
2425
Events:
2526
MongoDB:
2627
Type: Api
@@ -54,5 +55,4 @@ Outputs:
5455
Value: !GetAtt MongoDBFunction.Arn
5556
MongoDBFunctionIamRole:
5657
Description: "Implicit IAM Role created for MongoDB function"
57-
Value: !GetAtt MongoDBFunctionRole.Arn
58-
58+
Value: !GetAtt MongoDBFunctionRole.Arn

0 commit comments

Comments
 (0)