-
Notifications
You must be signed in to change notification settings - Fork 905
GODRIVER-1931 Run tests against LBs in Evergreen #648
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
GODRIVER-1931 Run tests against LBs in Evergreen #648
Conversation
983cc68
to
aa89353
Compare
dataLake bool | ||
requireAPIVersion bool | ||
serverParameters bson.Raw | ||
singleMongosLoadBalancerURI string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only changes were the addition of singleMongosLoadBalancerURI
and multiMongosLoadBalancerURI
. The diff looks larger due to auto-alignment by gofmt.
// ConnString gets the globally configured connection string. | ||
func getConnString() (connstring.ConnString, error) { | ||
// getClusterConnString gets the globally configured connection string. | ||
func getClusterConnString() (connstring.ConnString, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name changed for clarity.
@@ -186,6 +188,20 @@ func Setup(setupOpts ...*SetupOptions) error { | |||
} | |||
} | |||
|
|||
if testContext.topoKind == LoadBalanced { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is due to a spec/setup requirement - when mongo-orchestration starts up a cluster, it provides a URI that includes authentication information (if needed) but does not include TLS information (e.g. CA file path). We normally work around this by manually modifying the cluster URI, which is done in getClusterConnString()
, which internally calls addTLSConfig()
. For LB testing, we have to make the same modification for the URIs of the LBs themselves as well, so we do all of that here and then store the processed URI in testContext
.
@@ -126,26 +122,19 @@ func newClientEntity(ctx context.Context, em *EntityMap, entityOptions *entityOp | |||
return entity, nil | |||
} | |||
|
|||
func getURIForClient(opts *entityOptions) (string, error) { | |||
func getURIForClient(opts *entityOptions) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function originally returned an error because it would dynamically fetch the LB URI from an environment variable, which could be empty. The error is no longer needed because the env var checking is done in mtest#Setup
so we can fetch the required URI via the mtest
functions here.
@@ -344,8 +333,14 @@ func setClientOptionsFromURIOptions(clientOpts *options.ClientOptions, uriOpts b | |||
|
|||
for key, value := range uriOpts { | |||
switch key { | |||
case "appname": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All additions here are due to missing client options that were not required by previous tests.
@@ -748,6 +748,38 @@ func executeInsertOne(ctx context.Context, operation *operation) (*operationResu | |||
return newDocumentResult(raw, err), nil | |||
} | |||
|
|||
func executeListIndexes(ctx context.Context, operation *operation) (*operationResult, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously missed because no other test required it.
@@ -89,7 +89,7 @@ func executeListCollections(ctx context.Context, operation *operation) (*operati | |||
defer cursor.Close(ctx) | |||
|
|||
var docs []bson.Raw | |||
if err := cursor.All(ctx, &cursor); err != nil { | |||
if err := cursor.All(ctx, &docs); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug but there was no unified test that executed listCollections
.
@@ -518,6 +518,33 @@ functions: | |||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH \ | |||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH | |||
|
|||
run-load-balancer-tests: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script here is mostly a copy/paste of the run-tests function.
|
||
export GOFLAGS=-mod=vendor | ||
set +o xtrace | ||
AUTH="${AUTH}" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notable change in env var settings between this invocation and run-tests: there are no CSFLE env vars set here (e.g. AWS_ACCESS_KEY_ID) because the CSFLE tests are not run against LBs.
4395ef7
to
986dd67
Compare
.evergreen/config.yml
Outdated
fi | ||
fi | ||
|
||
# Verify that the required LB URI env vars are set to ensure that the test runner can correctly connect to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check for empty LB URIs both here and in mongo/integration/mtest/setup.go
. This might be redundant, but it accounts for both running in CI and locally. If we only checked in setup.go
, we could have an issue where SINGLE_MONGOS_LB_URI
is unset, so MONGODB_URI
would also be unset. In this case, the setup
function defaults to localhost:27017
and based on topology discovery, thinks it's connecting to a mongos rather than an LB cluster, so important tests that only run against LBs would be incorrectly skipped. Having the check in both places prevents that from happening.
Note that this may not be required once an upstream service fully supports running behind an LB because the service should error if it's configured in LB mode but the driver connects without loadBalanced=true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the extra check to avoid accidentally skipping these tests is a good precaution.
Note that this may not be required once an upstream service fully supports running behind an LB because the service should error if it's configured in LB mode but the driver connects without loadBalanced=true.
Right, since drivers send loadBalanced: true
as part of the hello
command, the server could reject non load balanced connections if it knows it is running behind a load balancer.
@@ -866,6 +922,7 @@ post: | |||
files: | |||
- "src/go.mongodb.org/mongo-driver/*.suite" | |||
- func: upload-mo-artifacts | |||
- func: stop-load-balancer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added as a post
task to ensure that the LB is shut down even if the tests fail.
@@ -355,6 +350,8 @@ func setClientOptionsFromURIOptions(clientOpts *options.ClientOptions, uriOpts b | |||
case "w": | |||
wc.W = value | |||
wcSet = true | |||
case "waitQueueTimeoutMS": | |||
return newSkipTestError("the waitQueueTimeoutMS client option is not supported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of dynamically detecting that the test needs to be skipped as mentioned in the PR description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why do we not support WaitQueueTimeoutMS
in Go ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CMAP spec states that supporting waitQueueTimeoutMS
is optional and not required if the language already has an idiomatic timeout mechanism. Go has contexts, so we don't support the option.
be21ade
to
b753c20
Compare
8ba56a8
to
7874a68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great!
.evergreen/config.yml
Outdated
fi | ||
fi | ||
|
||
# Verify that the required LB URI env vars are set to ensure that the test runner can correctly connect to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the extra check to avoid accidentally skipping these tests is a good precaution.
Note that this may not be required once an upstream service fully supports running behind an LB because the service should error if it's configured in LB mode but the driver connects without loadBalanced=true.
Right, since drivers send loadBalanced: true
as part of the hello
command, the server could reject non load balanced connections if it knows it is running behind a load balancer.
Co-authored-by: Kevin Albertson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some questions/nits! I don't really understand SetMockServiceID
so I'll ask offline.
@@ -355,6 +350,8 @@ func setClientOptionsFromURIOptions(clientOpts *options.ClientOptions, uriOpts b | |||
case "w": | |||
wc.W = value | |||
wcSet = true | |||
case "waitQueueTimeoutMS": | |||
return newSkipTestError("the waitQueueTimeoutMS client option is not supported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why do we not support WaitQueueTimeoutMS
in Go ?
Co-authored-by: Benjamin Rewis <[email protected]>
Co-authored-by: Benjamin Rewis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a quick question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* 'master' of https://github.com/mongodb/mongo-go-driver: (39 commits) GODRIVER-2004 Add Versioned API connection examples for Docs (mongodb#665) GODRIVER-1961 Run OCSP tests against RHEL 7.0 (mongodb#664) GODRIVER-1844 finer precision for getSecondsSinceEpoch (mongodb#666) GODRIVER-1973 create internal copy of aws v4 signing code (mongodb#657) GODRIVER-1951 Update the Go version for Evergreen builds to 1.16 (mongodb#663) GODRIVER-1949 add more ignored killAllSessions errors for unified tes… (mongodb#658) GODRIVER-1963 remove dropDatabase result (mongodb#660) GODRIVER-1180 Remove legacy transform functions from mongo (mongodb#583) GODRIVER-1937 Update legacy ListCollections to support the BatchSize option for server version 2.6 (mongodb#656) GODRIVER-1933 remove xtrace from shell scripts (mongodb#661) fix README error handling of FindOne (mongodb#636) GODRIVER-1938 update mongocryptd serverSelectionTimeout to 10 seconds (mongodb#659) GODRIVER-1925 Surface cursor errors in DownloadStream fillBuffer (mongodb#653) GODRIVER-1955 create labeledError interface (mongodb#651) GODRIVER-1947 Unmarshal unicode surrogate pairs correctly in UnmarshalExtJSON. (mongodb#649) Changed order of actions in ObjectIDFromHex func (mongodb#637) GODRIVER-1750 Ensure contexts are always cancelled during server monitoring (mongodb#654) GODRIVER-1931 Sync new cursors and SDAM LB tests (mongodb#655) GODRIVER-1981 Sync new transactions tests (mongodb#652) GODRIVER-1931 Run tests against LBs in Evergreen (mongodb#648) ...
This PR contains the changes needed to run load balancers in Evergreen and some updates to the mtest packakge to handle load balancer URIs. I also added a
load_balancer_prose_test.go
file to fill in some missing test coverage. There were a couple of missing/untested operations in the unified test runner so there are some changes required for that as well.I called out some notable changes in PR comments, but there are additional changes that span multiple files:
SetServiceID
flag ininternal/const.go
. This flag is used indescription/server.go
when parsinghello
command responses and enables a mode in which we mock the server returningserviceId
. It's set to true inmongo/integration/main_test.go
andmongo/integration/unified/main_test.go
if required.skipTestError
type inunified_spec_runner.go
.