Skip to content

Conversation

@RafaelCenzano
Copy link
Contributor

@RafaelCenzano RafaelCenzano commented Jan 9, 2026

GODRIVER-3517

Summary

  • Move oidc test out of internal/cmd and into internal/test
  • Convert to using go test package instead of custom testing code
  • Ensure the updated go test can still compile as a binary to be used in remote execution testing

Background & Motivation

The current code in master uses custom code to validate results and doesn't output in a standard format making it hard to view and read in CI/CD. By switching to using the go testing package things will be standardized and the same results can achieved as the original test with less code.

Patches

From master branch: https://spruce.mongodb.com/task/mongo_go_driver_testoidc_variant_oidc_auth_test_patch_d6ad23466699cd643cac9f2bfc4039dc8b90e4fd_69604bcc0446b80007af76b1_26_01_09_00_29_52/logs?execution=0
From the new changes: https://spruce.mongodb.com/task/mongo_go_driver_testoidc_variant_oidc_auth_test_patch_2d42254f49b16346c9a642093bd5283f35f0e6ac_696048178201660007bf7900_26_01_09_00_13_59/logs?execution=0

@RafaelCenzano RafaelCenzano added review-priority-normal Medium Priority PR for Review: within 1 business day go Pull requests that update Go code ci/cd labels Jan 9, 2026
This move is since the new test won't be primarily run by a go build
then run, instead it will use the go testing framework
Follow design patterns from other prose tests
Update functions to use testing framework
Update test main to allow for compiling to use the test the way it
currently is used

remove uneeded var rename
Keep the diff change as small as required for reviews
@RafaelCenzano RafaelCenzano force-pushed the test/oidc-prose-test-as-go-test-godriver3517 branch from 94daf67 to 81f357e Compare January 9, 2026 17:03
@mongodb-drivers-pr-bot
Copy link
Contributor

mongodb-drivers-pr-bot bot commented Jan 9, 2026

🧪 Performance Results

Commit SHA: 667c71d

The following benchmark tests for version 697280a49e5ee4000720b7f4 had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkBSONDeepDocumentEncoding ns_per_op 9.9022 16192.0000 Avg: 14733.0926
Med: 14793.5000
Stdev: 507.1038
0.8034 2.8769
BenchmarkBSONDeepDocumentEncoding total_mem_allocs -9.5747 220560.0000 Avg: 243913.9074
Med: 242030.5000
Stdev: 8689.8682
0.7899 -2.6875
BenchmarkBSONDeepDocumentEncoding total_bytes_allocated -9.3976 157396664.0000 Avg: 173722379.7037
Med: 172408792.0000
Stdev: 6078929.0690
0.7898 -2.6856
BenchmarkBSONDeepDocumentEncoding ops_per_second_med -8.5746 66631.1301 Avg: 72880.2889
Med: 71994.2587
Stdev: 2789.0918
0.7496 -2.2406
BenchmarkSingleRunCommand total_time_seconds 7.0648 1.1956 Avg: 1.1167
Med: 1.1180
Stdev: 0.0341
0.7590 2.3144
BenchmarkBSONDeepDocumentEncoding ops_per_second_max -6.7893 71169.3118 Avg: 76353.1449
Med: 75511.6530
Stdev: 2637.9692
0.7144 -1.9651
BenchmarkMultiFindMany ops_per_second_max 3.8018 4385964.9123 Avg: 4225324.8598
Med: 4237288.1356
Stdev: 50818.5706
0.8277 3.1611
BenchmarkBSONFlatDocumentDecoding ops_per_second_max 3.4964 22398.9249 Avg: 21642.2201
Med: 21623.4918
Stdev: 325.8975
0.7626 2.3219
BenchmarkMultiFindMany ops_per_second_med 2.5704 3816793.8931 Avg: 3721146.4405
Med: 3717523.4936
Stdev: 30356.6988
0.8369 3.1508
BenchmarkBSONFlatDocumentDecoding total_time_seconds 2.0973 1.2245 Avg: 1.1994
Med: 1.1991
Stdev: 0.0064
0.8674 3.9415
BenchmarkBSONDeepDocumentEncoding allocated_bytes_per_op 0.2273 2148.0000 Avg: 2143.1296
Med: 2143.0000
Stdev: 1.5302
0.8246 3.1829

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@mongodb-drivers-pr-bot
Copy link
Contributor

API Change Report

No changes found!

When converting this test to a go test it is now picked up by many
variants on evergreen that run go test ./...
This is an issue because the test requires env vars
This change skips it except for the cases where it is called with
required env vars
@RafaelCenzano RafaelCenzano marked this pull request as ready for review January 9, 2026 23:25
@RafaelCenzano RafaelCenzano requested a review from a team as a code owner January 9, 2026 23:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR converts OIDC prose tests from a custom main package with manual test execution to standard Go testing framework. The changes move the test from internal/cmd to internal/test and refactor all test functions to use standard testing.T patterns while maintaining the ability to compile as a binary for remote execution.

  • Changed package from main to oidcauth and added proper TestMain for environment-based test skipping
  • Converted all test functions from func name() error to func TestName(t *testing.T) with proper test naming conventions
  • Updated test infrastructure (shell scripts and Taskfile) to use go test commands instead of go run

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/test/oidcauth/oidcauth_test.go Main test file converted from custom main package to standard Go test package with ~50 test functions refactored to use testing.T, proper cleanup patterns, and environment-based conditional execution
etc/run-oidc-remote-test.sh Updated to compile tests with go test -c instead of go build, and added -test.v flag for verbose output
Taskfile.yml Updated OIDC test commands from go run to go test -v with proper test path patterns
Comments suppressed due to low confidence (1)

internal/test/oidcauth/oidcauth_test.go:1545

  • The error message "expected 1 finds succeed" is grammatically incorrect. It should be "expected 1 find to succeed" or "expected 1 find succeeded".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if err != nil {
return fmt.Errorf("machine_1_1: failed connecting client: %v", err)
t.Fatalf("failed connecting client: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] We should update all tests to use the internal require package instead of if blocks.

Use the internal require package to check test values
Reduces lines of code and makes the intention of the checks more clear
@matthewdale
Copy link
Collaborator

matthewdale commented Jan 14, 2026

I've reconfigured the Evergreen test variants to run the "OIDC" tests, which are not run by default on PRs. We will have to do that for each new commit in this PR.

@RafaelCenzano
Copy link
Contributor Author

matthewdale
matthewdale previously approved these changes Jan 14, 2026
Accidentally inversed the check when converting to the require package
Comment on lines 1558 to 1562
require.True(
t,
opts.Auth == nil || opts.Auth.AuthMechanism != "MONGODB-OIDC",
"expected URI to contain MONGODB-OIDC auth information",
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] The logic here is inverted from the original assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks good catch I missed this one, just pushed the change

matthewdale
matthewdale previously approved these changes Jan 15, 2026
@RafaelCenzano
Copy link
Contributor Author

@prestonvasquez changes are up to date on comments now. Ran the OIDC tests in the patch they pass but I'm noticing an issue. Because the Azure, GCP, and K8s tests run on another platform the test output and the benefits of the go tests like listing the tests is not available. Is there a fix for this? And is there a case where those tests fail but evergreen won't know or would it know it fails but it would be unable to list which test failed? https://spruce.mongodb.com/version/697144ad2fc1e400073afe6c/tasks?page=0&sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC&variant=%5Etestoidc-variant%24

@prestonvasquez
Copy link
Member

prestonvasquez commented Jan 22, 2026

@prestonvasquez changes are up to date on comments now. Ran the OIDC tests in the patch they pass but I'm noticing an issue. Because the Azure, GCP, and K8s tests run on another platform the test output and the benefits of the go tests like listing the tests is not available. Is there a fix for this? And is there a case where those tests fail but evergreen won't know or would it know it fails but it would be unable to list which test failed? https://spruce.mongodb.com/version/697144ad2fc1e400073afe6c/tasks?page=0&sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC&variant=%5Etestoidc-variant%24

@RafaelCenzano Need to redirect (e.g. bash ${DRIVERS_TOOLS}/.evergreen/auth_oidc/azure/run-driver-test.sh ) to test.suite and capture all the output in /etc/run-oidc-test.sh: $@ instead of $1. Can tell looking at the .tgz:

[WORKDIR]/drivers-evergreen-tools/.evergreen/auth_oidc/azure [WORKDIR]/mongo-driver
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... begin
retry_with_backoff: running 'ssh -n -o ConnectTimeout=10 -o StrictHostKeyChecking=no azureuser@[REDACTED_VM_IP] -i [REDACTED_KEYFILE_PATH] echo 'hi' > /dev/null' - attempt n. 1 ...
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... end
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... begin
retry_with_backoff: running 'ssh -n -o ConnectTimeout=10 -o StrictHostKeyChecking=no azureuser@[REDACTED_VM_IP] -i [REDACTED_KEYFILE_PATH] echo 'hi' > /dev/null' - attempt n. 1 ...
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... end
Copying file /tmp/mongo-go-driver.tar.gz to Virtual Machine ~/ ... begin
Copying file /tmp/mongo-go-driver.tar.gz to Virtual Machine ~/ ... end
Copying files ... end
Untarring file ... begin
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... begin
retry_with_backoff: running 'ssh -n -o ConnectTimeout=10 -o StrictHostKeyChecking=no azureuser@[REDACTED_VM_IP] -i [REDACTED_KEYFILE_PATH] echo 'hi' > /dev/null' - attempt n. 1 ...
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... end
Running 'tar xf mongo-go-driver.tar.gz' on Azure Virtual Machine ... begin
Running 'tar xf mongo-go-driver.tar.gz' on Azure Virtual Machine ... end
Untarring file ... end
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... begin
retry_with_backoff: running 'ssh -n -o ConnectTimeout=10 -o StrictHostKeyChecking=no azureuser@[REDACTED_VM_IP] -i [REDACTED_KEYFILE_PATH] echo 'hi' > /dev/null' - attempt n. 1 ...
Adding current IP ([REDACTED_LOCAL_IP]) to Azure Virtual Machine ... end
Running 'PROJECT_DIRECTORY='.' OIDC_ENV=azure OIDC=oidc ./etc/run-oidc-test.sh ./test -test.v' on Azure Virtual Machine ... begin
Running MONGODB-OIDC authentication tests
PASS
Running 'PROJECT_DIRECTORY='.' OIDC_ENV=azure OIDC=oidc ./etc/run-oidc-test.sh ./test -test.v' on Azure Virtual Machine ... end

# Ensure that we source the environment file created for us, set up any other variables we need,
# and then run our test suite on the vm.
export AZUREOIDC_TEST_CMD="PROJECT_DIRECTORY='.' OIDC_ENV=azure OIDC=oidc ./etc/run-oidc-test.sh ./test"
export AZUREOIDC_TEST_CMD="PROJECT_DIRECTORY='.' OIDC_ENV=azure OIDC=oidc ./etc/run-oidc-test.sh ./test -test.v"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] See #2283 (comment)

@RafaelCenzano
Copy link
Contributor Author

Most recent OIDC run for the most recent changes. https://spruce.mongodb.com/version/697280a49e5ee4000720b7f4/tasks?page=0&sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC&variant=%5Etestoidc-variant%24

@RafaelCenzano RafaelCenzano merged commit 952202f into mongodb:master Jan 23, 2026
33 of 35 checks passed
@RafaelCenzano RafaelCenzano deleted the test/oidc-prose-test-as-go-test-godriver3517 branch January 23, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd go Pull requests that update Go code review-priority-normal Medium Priority PR for Review: within 1 business day

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants