Skip to content

DRIVERS-1603 Unified test format updates for serverless testing #944

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

Conversation

patrickfreed
Copy link
Contributor

@patrickfreed patrickfreed commented Apr 7, 2021

DRIVERS-1603

This PR adds a testing-only spec which requires that drivers run a certain set of tests against a live Atlas serverless instance. As part of this, the unified test format was updated to include a Serverless-specific runOnRequirement, and some tests were updated to use it as necessary.

Example patch: https://evergreen.mongodb.com/version/606e3ba332f4171c4c8b406e

@@ -0,0 +1,79 @@
description: "aggregate"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and find.yml ensure that cursors work even with multiple batches (test required by scope).

@@ -34,6 +34,7 @@ tests:
- description: "estimatedDocumentCount uses $collStats on 4.9.0 or greater"
runOnRequirements:
- minServerVersion: "4.9.0"
serverlessMode: forbidServerless
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ironically, serverless does not support counting via $collStats, so these need to be skipped until that has been fixed (CLOUDP-86318)

@@ -1,6 +1,7 @@
runOn:
-
minServerVersion: "3.6.0"
serverlessMode: "forbidServerless"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$listLocalSessions is not supported in serverless.

enabled. Additionally, Serverless requires the usage of the versioned API, so
the tests MUST be run with a server API version specified.

Required Variables
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering what would be the best way to store the values of these for drivers to refer to. The atlas connectivity ones are in a google doc, so maybe we should go that route too.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we have any great options for sharing secrets only to the DBX team. So a google doc seems OK.

Copy link
Member

Choose a reason for hiding this comment

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

@agolin95: this sounds like another thing that could ultimately benefit from some structure/process

Choose a reason for hiding this comment

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

Agreed @jmikola thank you for the tag! Taking a reminder to investigate what kind of secret sharing platform options we have available to us.

``find`` and a single ``getMore`` (e.g. specify ``batchSize=1`` for a query
that would match 3+ documents).

Other Tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Required by the "existing tests using cursors" portion of the spec.

@patrickfreed patrickfreed marked this pull request as ready for review April 7, 2021 23:57
@patrickfreed patrickfreed requested a review from jmikola as a code owner April 7, 2021 23:57
@patrickfreed patrickfreed requested a review from kevinAlbs April 7, 2021 23:57
@@ -61,6 +61,14 @@ Each YAML file has the following keys:
and "sharded". If this field is omitted, the default is all topologies (i.e.
``["single", "replicaset", "sharded"]``).

- ``serverlessMode``: (optional) Whether or not the test should be run on
Copy link
Member

Choose a reason for hiding this comment

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

May I humbly suggest serverless: "allow|require|forbid"? I feel it's less verbose and less confusing (serverlessMode makes it sound like it's about the configuration of the serverless proxy, not whether we're testing against it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, updated.

@@ -3,13 +3,13 @@ Unified Test Format
===================

:Spec Title: Unified Test Format
:Spec Version: 1.2.3
:Spec Version: 1.3.0
Copy link
Member

Choose a reason for hiding this comment

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

Please remember to add a changelog entry for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

createEntities:
- client:
id: &client0 client0
useMultipleMongoses: true # ensure cursors pin to a single server
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh good thinking!

- database:
id: &database0 database0
client: *client0
databaseName: &database0Name edc-tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
databaseName: &database0Name edc-tests
databaseName: &database0Name aggregate-tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. (didn't use the "commit suggestion" to group the JSON changes in the same commit).

- database:
id: &database0 database0
client: *client0
databaseName: &database0Name edc-tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
databaseName: &database0Name edc-tests
databaseName: &database0Name find-tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -34,6 +34,7 @@ tests:
- description: "estimatedDocumentCount uses $collStats on 4.9.0 or greater"
runOnRequirements:
- minServerVersion: "4.9.0"
serverless: forbid
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this forbidden? I think the new aggregation pipeline for estimatedDocumentCount would work against serverless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed a little bit in slack, the proxy doesn't yet support count via $collStats yet (https://jira.mongodb.org/browse/CLOUDP-86318)

Copy link
Member

Choose a reason for hiding this comment

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

Is that intended to be addressed before public release?

Either way, I think this warrants a comment (as you did for db.aggregate) and maybe a reference to the issue number so we can come back to this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -1,6 +1,7 @@
runOn:
-
minServerVersion: "3.6.0"
serverless: "forbid"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you note in a comment saying that serverless does not support $listLocalSessions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


All tests MUST be run with wire protocol compression and authentication
enabled. Additionally, Serverless requires the usage of the versioned API, so
the tests MUST be run with a server API version specified.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, I was going to ask why client entities did not have a serverApi field. I think I prefer having this noted in the readme. Otherwise, every test we run against serverless would need to be modified to have a serverApi.

enabled. Additionally, Serverless requires the usage of the versioned API, so
the tests MUST be run with a server API version specified.

Required Variables
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we have any great options for sharing secrets only to the DBX team. So a google doc seems OK.

@@ -170,6 +170,7 @@ tests:
- description: "Aggregate with $listLocalSessions"
runOnRequirements:
- minServerVersion: "3.6.0"
serverless: forbid
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here, can you add a comment noting $listLocalSessions is prohibited in serverless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -62,6 +62,8 @@ tests:
<<: *expectedApiVersion

- description: "aggregate on database appends declared API version"
runOnRequirements:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this test use the $currentOp stage instead of bypassing on serverless?

Edit: nevermind, $currentOp appears also forbidden.

MongoDB Enterprise mongos> db.aggregate([{$currentOp: 1}])
uncaught exception: Error: command failed: {
	"ok" : 0,
	"errmsg" : "$currentOp is not allowed in this atlas tier",
	"code" : 8000,
	"codeName" : "AtlasError"
} with original command request: {
	"aggregate" : 1,
	"pipeline" : [
		{
			"$currentOp" : 1
		}
	],
	"cursor" : {

	},
	"lsid" : {
		"id" : UUID("2318af3d-5565-4a71-9a68-63d9081939eb")
	},
	"$clusterTime" : {
		"clusterTime" : Timestamp(1617905922, 1),
		"signature" : {
			"hash" : BinData(0,"yWzyYH2VLZix/Wj3qp3mmupzm2Q="),
			"keyId" : NumberLong("6945905481428762627")
		}
	}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I don't think we can test db-aggregate on serverless for the time being.

@@ -1,6 +1,7 @@
runOn:
-
minServerVersion: "3.6.0"
serverless: "forbid"
Copy link
Member

Choose a reason for hiding this comment

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

Presumably this is the only reason you needed to modify the CRUD v2 test format. Is there no other alternative we can use to run db.aggregate() on serverless, or are all of its pipeline stages unsupported?

I'll note that this test was changed to use $listLocalSessions instead of $currentOp in #565 (comment).

This relates to @kevinAlbs's comment in https://github.com/mongodb/specifications/pull/944/files#r609975158. As a side question, I'm curious if these restrictions only have to do with "serverless" or more generally might apply to other parts of Atlas (e.g. free tier proxy). AFAIK, they are separate things, but correct me if I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the only options for db-level aggregate are $listLocalSessions and $currentOp, both of which are unsupported by the proxy.

And yeah, I believe whatever restrictions apply to the serverless proxy probably also apply to the free-tier proxy, since I think the former is a descendant of / shares a lot of code with the latter, not sure about how tightly coupled they are though.

enabled. Additionally, Serverless requires the usage of the versioned API, so
the tests MUST be run with a server API version specified.

Required Variables
Copy link
Member

Choose a reason for hiding this comment

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

@agolin95: this sounds like another thing that could ultimately benefit from some structure/process

@@ -3,13 +3,13 @@ Unified Test Format
===================

:Spec Title: Unified Test Format
:Spec Version: 1.2.3
:Spec Version: 1.3.0
Copy link
Member

Choose a reason for hiding this comment

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

FYI: this and the corresponding schema version are going to conflict #935. Please reach out to @divjotarora and decide if you should use 1.4.0 here or vice versa.

I'll note that the schema versioning doesn't force drivers to implement the projects in a particular order. IIRC, I was working on Atlas testing (1.2 with loop, etc.) in PHPLIB before we had implemented versioned API (1.1).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I think whichever one is ready to merge first ought to take the 1.3 and the other can do 1.4. I'll check with him before merging anything to ensure we're on the same page.

@patrickfreed patrickfreed force-pushed the DRIVERS-1603/serverless-atlas-testing branch from b1703d3 to a0dfb5e Compare April 9, 2021 17:46
- ``serverless``: (optional) Whether or not the test should be run on
serverless instances imitating sharded clusters. Valid values are "require",
"forbid", and "allow". If "require", the test MUST only be run on serverless
instances. If "forbid", the test MUST NOT be run on Serverless instances. If
Copy link
Member

Choose a reason for hiding this comment

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

"Serverless" is still capitalized here.

@@ -1,6 +1,7 @@
runOn:
-
minServerVersion: "3.6.0"
serverless: "forbid" # serverless does not support $listLocalSessions or $currentOp
Copy link
Member

Choose a reason for hiding this comment

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

$currentOp isn't used in this file. If you keep this (no harm), perhaps you want to ensure poc-crud.yml has the same comment for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I included both in case any future readers might wonder why we don't just use $currentOp, updated both this and poc-crud.yml to use the same comment that should be a bit clearer.

@@ -34,6 +34,7 @@ tests:
- description: "estimatedDocumentCount uses $collStats on 4.9.0 or greater"
runOnRequirements:
- minServerVersion: "4.9.0"
serverless: forbid
Copy link
Member

Choose a reason for hiding this comment

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

Is that intended to be addressed before public release?

Either way, I think this warrants a comment (as you did for db.aggregate) and maybe a reference to the issue number so we can come back to this later.

serverless instances imitating sharded clusters. Valid values are "require",
"forbid", and "allow". If "require", the test MUST only be run on serverless
instances. If "forbid", the test MUST NOT be run on Serverless instances. If
omitted or "allow", this option has no effect.
Copy link
Member

@jmikola jmikola Apr 9, 2021

Choose a reason for hiding this comment

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

Can you confirm that serverless is entirely distinct from load balancers, in that a load balancer can front mongos or serverless instances, but drivers can also connect directly to serverless without a load balancer?

I just want to make sure I'm understanding both projects correctly before we codify any runOnRequirement changes.

For context, let me quote @patrickfreed's previous comment (now hidden) from this thread:

And yeah, I believe whatever restrictions apply to the serverless proxy probably also apply to the free-tier proxy, since I think the former is a descendant of / shares a lot of code with the latter, not sure about how tightly coupled they are though.

In #935, @divjotarora explained that drivers cannot infer what is behind a load balancer. This came up with respect with useMultipleMongoses. The solution there was to feed test runners two additional connection strings (one for an LB fronting a single mongos, and another for a LB fronting multiple mongoses), which can then be used as needed based on whether useMultipleMongoses is true or false. While this works in practice, it does invert the typical behavior for useMultipleMongoses in that drivers simply decide which connection string to use instead of inspecting the topology and possibly raising an error.

If serverless presents itself as mongos and cannot be differentiated, how is the test runner supposed to enforce the serverless option? I assume the test runner (either unified or legacy) will need to consult some explicit indicator (e.g. environment variable, configuration option) and decide based on that. If so, I think we need to clarify that. The test runners themselves need not be prescriptive beyond saying that it must be possible to inform them whether or not serverless is being used. The serverless testing doc itself can advise on a particular method for doing so.

Whatever mechanism is suggested will need to play nice with #935 in the event we ever test load balancers fronting serverless. #935 initially assumes that drivers will only test load balancers with mongos, but I think we should consider how the serverless option will interact should we ever add load balancers fronting serverless to the test matrix. Expecting serverless usage to be communicated explicitly (e.g. environment variable or otherwise configuring the test runner) seems like a good way to avoid potential conflict there.


On a separate note, if we expect that Atlas free tier has the same restrictions as serverless (at least with respect to db.aggregate, which is the main reason serverless is being introduced as a runOnRequirement), should we amend the definition to cover both environments? Or perhaps no language changes are needed in this PR and we can just consider having Atlas free tier testing make use of the same indicator (e.g. environment variable) when the time comes.

I'll confess I'm not aware of how we test on free tier today beyond the basic connectivity tests. DRIVERS-362 and DRIVERS-382 are quite old and I don't believe we have an actual spec or design for free tier testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

By the time Serverless is GA, the only way to interact with it will be via a load balancer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per slack discussion, it is expected that drivers use something like an environment variable to determine if serverless is being tested, regardless of whether or not there's a load balancer in front of it or not. I've updated the specs to indicate as much.

Regarding the free tier testing, I don't think we're planning on introducing any new tests for it, so I'm not sure how much of a concern it is. Furthermore, we may want to have separate runOnRequirements for the free tier and serverless anyways even if we do add such tests.

@patrickfreed patrickfreed changed the title DRIVERS-1603 Serverless drivers testing spec DRIVERS-1603 Unified test format updates for serverless testing Apr 19, 2021
@patrickfreed
Copy link
Contributor Author

Continued in #964 (couldn't re-open this since a force-push occurred while it was closed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants