Skip to content

Commit 80e2941

Browse files
blink1073qingyang-hu
authored andcommitted
GODRIVER-2958 Use AWS Secrets for Atlas tests (#1365)
* GODRIVER-2958 Use AWS Secrets for Atlas tests * fix handling of shell * fix cleanup * print finished * try wip branch * cleanup * cleanup * cleanup * cleanup * clean up secrets handling * GODRIVER-2958 Use AWS Secrets for Atlas tests * restore drivers-eg-tools checkout
1 parent d53e0bc commit 80e2941

File tree

6 files changed

+43
-30
lines changed

6 files changed

+43
-30
lines changed

.evergreen/config.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -437,37 +437,18 @@ functions:
437437
make -s evg-test-enterprise-auth
438438
439439
run-atlas-test:
440+
- command: ec2.assume_role
441+
params:
442+
role_arn: "${aws_test_secrets_role}"
440443
- command: shell.exec
441444
type: test
442445
params:
443446
shell: "bash"
444447
working_dir: src/go.mongodb.org/mongo-driver
448+
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
445449
script: |
446-
# DO NOT ECHO WITH XTRACE
447-
if [ "Windows_NT" = "$OS" ]; then
448-
export GOPATH=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
449-
export GOCACHE=$(cygpath -w "$(pwd)/.cache")
450-
else
451-
export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
452-
export GOCACHE="$(pwd)/.cache"
453-
fi;
454-
export GOPATH="$GOPATH"
455-
export GOROOT="${GO_DIST}"
456-
export GOCACHE="$GOCACHE"
457-
export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
458-
export ATLAS_FREE="${atlas_free_tier_uri}"
459-
export ATLAS_REPLSET="${atlas_replica_set_uri}"
460-
export ATLAS_SHARD="${atlas_sharded_uri}"
461-
export ATLAS_TLS11="${atlas_tls_v11_uri}"
462-
export ATLAS_TLS12="${atlas_tls_v12_uri}"
463-
export ATLAS_FREE_SRV="${atlas_free_tier_uri_srv}"
464-
export ATLAS_REPLSET_SRV="${atlas_replica_set_uri_srv}"
465-
export ATLAS_SHARD_SRV="${atlas_sharded_uri_srv}"
466-
export ATLAS_TLS11_SRV="${atlas_tls_v11_uri_srv}"
467-
export ATLAS_TLS12_SRV="${atlas_tls_v12_uri_srv}"
468-
export ATLAS_SERVERLESS="${atlas_serverless_uri}"
469-
export ATLAS_SERVERLESS_SRV="${atlas_serverless_uri_srv}"
470-
make -s evg-test-atlas
450+
${PREPARE_SHELL}
451+
bash etc/run-atlas-test.sh
471452
472453
run-ocsp-test:
473454
- command: shell.exec

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ internal/test/faas/awslambda/events/event.json
2121
# Ignore compiled binaries from the compilecheck
2222
internal/test/compilecheck/compilecheck
2323
internal/test/compilecheck/compilecheck.so
24+
25+
# Ignore api report files
26+
api-report.md
27+
api-report.txt
28+
29+
# Ignore secrets files
30+
secrets-expansion.yml
31+
secrets-export.sh

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
ATLAS_URIS = "$(ATLAS_FREE)" "$(ATLAS_REPLSET)" "$(ATLAS_SHARD)" "$(ATLAS_TLS11)" "$(ATLAS_TLS12)" "$(ATLAS_FREE_SRV)" "$(ATLAS_REPLSET_SRV)" "$(ATLAS_SHARD_SRV)" "$(ATLAS_TLS11_SRV)" "$(ATLAS_TLS12_SRV)" "$(ATLAS_SERVERLESS)" "$(ATLAS_SERVERLESS_SRV)"
21
TEST_TIMEOUT = 1800
32

43
### Utility targets. ###
@@ -124,10 +123,6 @@ build-aws-ecs-test:
124123
evg-test:
125124
go test -exec "env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s -p 1 ./... >> test.suite
126125

127-
.PHONY: evg-test-atlas
128-
evg-test-atlas:
129-
go run ./cmd/testatlas/main.go $(ATLAS_URIS)
130-
131126
.PHONY: evg-test-atlas-data-lake
132127
evg-test-atlas-data-lake:
133128
ATLAS_DATA_LAKE_INTEGRATION_TEST=true go test -v ./mongo/integration -run TestUnifiedSpecs/atlas-data-lake-testing >> spec_test.suite

cmd/testatlas/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ func main() {
2323
uris := flag.Args()
2424
ctx := context.Background()
2525

26+
fmt.Printf("Running atlas tests for %d uris\n", len(uris))
27+
2628
for idx, uri := range uris {
29+
fmt.Printf("Running test %d\n", idx)
30+
2731
// Set a low server selection timeout so we fail fast if there are errors.
2832
clientOpts := options.Client().
2933
ApplyURI(uri).
@@ -41,6 +45,8 @@ func main() {
4145
panic(fmt.Sprintf("error running test with tlsInsecure at index %d: %v", idx, err))
4246
}
4347
}
48+
49+
fmt.Println("Finished!")
4450
}
4551

4652
func runTest(ctx context.Context, clientOpts *options.ClientOptions) error {

etc/get_aws_secrets.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
# get-aws-secrets
3+
# Gets AWS secrets from the vault
4+
set -eu
5+
6+
if [ -z "$DRIVERS_TOOLS" ]; then
7+
echo "Please define DRIVERS_TOOLS variable"
8+
exit 1
9+
fi
10+
11+
bash $DRIVERS_TOOLS/.evergreen/auth_aws/setup_secrets.sh $@
12+
. ./secrets-export.sh

etc/run-atlas-test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
# run-atlas-test
3+
# Run atlas connectivity tests.
4+
set -eu
5+
set +x
6+
7+
# Get the atlas secrets.
8+
. etc/get_aws_secrets.sh drivers/atlas_connect
9+
10+
echo "Running cmd/testatlas/main.go"
11+
go run ./cmd/testatlas/main.go "$ATLAS_REPL" "$ATLAS_SHRD" "$ATLAS_FREE" "$ATLAS_TLS11" "$ATLAS_TLS12" "$ATLAS_SERVERLESS" "$ATLAS_SRV_REPL" "$ATLAS_SRV_SHRD" "$ATLAS_SRV_FREE" "$ATLAS_SRV_TLS11" "$ATLAS_SRV_TLS12" "$ATLAS_SRV_SERVERLESS"

0 commit comments

Comments
 (0)