Skip to content
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 Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tasks:

build-compile-check-all: bash etc/run-compile-check-test.sh

build-aws-ecs-test: go build ${BUILD_TAGS} ./internal/cmd/testaws/main.go
build-aws-ecs-test: go test -c ./internal/test/aws -o aws.testbin

cross-compile:
- GOOS=linux GOARCH=386 go build ./...
Expand Down
6 changes: 3 additions & 3 deletions etc/run-mongodb-aws-ecs-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
set -eu

if [ "${SKIP_ECS_AUTH_TEST:-}" = "true" ]; then
echo "This platform does not support the ECS auth test, skipping..."
exit 0
echo "This platform does not support the ECS auth test, skipping..."
exit 0
fi

task build-aws-ecs-test
Expand All @@ -13,7 +13,7 @@ ECS_SRC_DIR=$AUTH_AWS_DIR/src

# pack up project directory to ssh it to the container
mkdir -p $ECS_SRC_DIR/.evergreen
cp ${PROJECT_DIRECTORY}/main $ECS_SRC_DIR
cp ${PROJECT_DIRECTORY}/aws.testbin $ECS_SRC_DIR/main
cp ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-ecs-test.sh $ECS_SRC_DIR/.evergreen
tar -czf $ECS_SRC_DIR/src.tgz -C ${PROJECT_DIRECTORY} .

Expand Down
2 changes: 1 addition & 1 deletion etc/run-mongodb-aws-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ set -x

# For Go 1.16+, Go builds requires a go.mod file in the current working directory or a parent
# directory. Spawn a new subshell, "cd" to the project directory, then run "go run".
(cd ${PROJECT_DIRECTORY} && go run "./internal/cmd/testaws/main.go" | tee test.suite)
(cd ${PROJECT_DIRECTORY} && go test -timeout 30m -v ./internal/test/aws/... | tee -a test.suite)
26 changes: 12 additions & 14 deletions internal/cmd/testaws/main.go → internal/test/aws/aws_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) MongoDB, Inc. 2017-present.
// Copyright (C) MongoDB, Inc. 2025-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
Expand All @@ -9,32 +9,30 @@ package main
import (
"context"
"errors"
"fmt"
"os"
"testing"

"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/internal/require"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
)

func main() {
func TestAWS(t *testing.T) {
uri := os.Getenv("MONGODB_URI")
ctx := context.Background()

client, err := mongo.Connect(options.Client().ApplyURI(uri))
if err != nil {
panic(fmt.Sprintf("Connect error: %v", err))
}
require.NoError(t, err, "Connect error")

defer func() {
if err = client.Disconnect(ctx); err != nil {
panic(fmt.Sprintf("Disconnect error: %v", err))
}
err = client.Disconnect(context.Background())
require.NoError(t, err)
}()

db := client.Database("aws")
coll := db.Collection("test")
if err = coll.FindOne(ctx, bson.D{{"x", 1}}).Err(); err != nil && !errors.Is(err, mongo.ErrNoDocuments) {
panic(fmt.Sprintf("FindOne error: %v", err))
coll := client.Database("aws").Collection("test")

err = coll.FindOne(context.Background(), bson.D{{Key: "x", Value: 1}}).Err()
if err != nil && !errors.Is(err, mongo.ErrNoDocuments) {
t.Logf("FindOne error: %v", err)
}
}
Loading