Skip to content

PHPLIB-683 Test against Proxy as a Mongos #854

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

Merged
merged 13 commits into from
Sep 2, 2021
Merged

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Aug 11, 2021

PHPLIB-683

I've decided to vendor in the setup scripts for better local testing. For now this works, but I'd like to figure out a better alternative in the long-term to avoid having to duplicate changes made in drivers-evergreen-tools.

@alcaeus alcaeus requested review from jmikola and tanlisu August 11, 2021 09:28
@alcaeus alcaeus self-assigned this Aug 11, 2021
private static function appendAuthenticationOptions(array $options): array
{
if (isset($options['username']) || isset($options['password'])) {
return $options;
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it makes sense to raise an exception here, or maybe only if the options are later specified and would try to append themselves?

I reckon there isn't a use case where we'd actually want MONGODB_USERNAME or MONGODB_PASSWORD to override anything, apart from the previous edge case I mentioned about the connection string already having auth credentials.

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is called automatically, and only appends default options if the URI being given doesn't already contain them. This allows us to specifically test with invalid credentials on clusters with auth enabled, which would otherwise be impossible (either due to the exception we'd raise, or because we'd always inject the credentials from the environment).

Copy link
Member

@jmikola jmikola Aug 26, 2021

Choose a reason for hiding this comment

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

I'm still a bit confused.

only appends default options if the URI being given doesn't already contain them

Is "URI" referring to the connection string or the options array? If the connection string, I don't see the logic that avoids calling appendAuthenticationOptions when credentials are already present.

Alternatively, are you intentionally expecting the array options to override credentials in the connection string? Perhaps that's what b5212a0 is clarifying?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I should've clarified. Yes, this does not catch credentials sent through the connection string, which we currently don't do in tests. This ensures that any client created with URI options that set specific credentials (e.g. to test failing authentication) does not get correct credentials injected.


if ($this->isServerRequirementSatisifed($minServerVersion, $maxServerVersion, $topologies)) {
if ($this->isServerRequirementSatisifed($minServerVersion, $maxServerVersion, $topologies, $serverlessMode)) {
Copy link
Member

Choose a reason for hiding this comment

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

Should serverless pre-empt any requirement checking for server version? Feel free to point me to some language in the spec test READMEs that say as much. I don't recall the requirements being mutually exclusive, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Theoretically, the check should pre-empt any other checks, as it's entirely based on the environment variable being set or not. That said, the unified test format currently prescribes that the requirements MUST be checked in the following order:

  1. minServerVersion
  2. maxServerVersion
  3. topologies
  4. serverless
  5. serverParameters
  6. auth

I don't think this order is efficient or even necessary, so I'm happy to have the spec updated to suggest a more efficient order without mandating it (to avoid unnecessary downstream changes in drivers)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

DRIVERS-1885 is now resolved if you'd like to restructure this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd defer that work to a separate PR in an interest to get this merged.

jmikola added a commit to jmikola/mongo-php-library that referenced this pull request Aug 26, 2021
Synced with mongodb/specifications#1057

Note: aggregate tests are intentionally excluded since those will be synced by mongodb#854
jmikola added a commit to jmikola/mongo-php-library that referenced this pull request Aug 27, 2021
Synced with mongodb/specifications#1057

Note: aggregate tests are intentionally excluded since those will be synced by mongodb#854
jmikola added a commit to jmikola/mongo-php-library that referenced this pull request Aug 30, 2021
Synced with mongodb/specifications#1057

Note: aggregate tests are intentionally excluded since those will be synced by mongodb#854
jmikola added a commit to jmikola/mongo-php-library that referenced this pull request Aug 31, 2021
Synced with mongodb/specifications@59a5dad

Note: aggregate tests are intentionally excluded since those will be synced by mongodb#854
jmikola added a commit that referenced this pull request Aug 31, 2021
…pported by the server (#859)

* Sync unified CRUD spec tests

Synced with mongodb/specifications@59a5dad

Note: aggregate tests are intentionally excluded since those will be synced by #854

* PHPLIB-711: Unwrap BulkWriteException when evaluating isClientError

* Client-side errors for hint with update, delete, and findAndModify

The CRUD spec requires a client-side error if hint is used and the server would not otherwise raise an error for an unsupported option. This was already being done, but this commit renames an internal constant and adds functional tests.

A client-side error is also required if hint is used with an unacknowledged write concern and the server does not support hint for the operation (regardless of error reporting for unsupported options). This was previously done only for FindAndModify; however, it failed to detect some acknowledged write concerns (PHPLIB-712). That issue has been fixed and the commit additionally adds this behavior for update and delete operations.
@alcaeus alcaeus merged commit ce61fc8 into mongodb:master Sep 2, 2021
@alcaeus alcaeus deleted the phplib-683 branch September 2, 2021 13:48
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.

2 participants