Skip to content
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

Test failure with upcoming mongodb extension 1.3.0 #185

Closed
remicollet opened this issue Aug 11, 2017 · 6 comments
Closed

Test failure with upcoming mongodb extension 1.3.0 #185

remicollet opened this issue Aug 11, 2017 · 6 comments
Assignees
Labels
Milestone

Comments

@remicollet
Copy link

Seems minor (connection fail with different exception)

There was 1 failure:

1) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoCollectionTest::testFindOneConnectionIssue
Failed asserting that exception of type "MongoDB\Driver\Exception\InvalidArgumentException" matches expected exception "MongoConnectionException". Message was: "Failed to parse MongoDB URI: 'mongodb://localhost:28888?connectTimeoutMS=1'. Invalid host string in URI." at
/usr/share/php/MongoDB/Client.php:81
/builddir/build/BUILDROOT/php-alcaeus-mongo-php-adapter-1.1.2-1.fc26.remi.x86_64/usr/share/php/Alcaeus/Mongo/MongoClient.php:95
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/TestCase.php:45
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/Mongo/MongoCollectionTest.php:668
.
@remicollet
Copy link
Author

@jmikola @derickr for your information

@remicollet
Copy link
Author

Sorry, I forget the errors (seems important)

There were 4 errors:

1) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoBinDataTest::testCreateWithBsonBinary
MongoDB\Driver\Exception\InvalidArgumentException: Expected UUID length to be 16 bytes, 3 given

/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/Mongo/MongoBinDataTest.php:42

2) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoClientTest::testReadPreferenceOptionsAreInherited with data set "optionsArray" (array('secondaryPreferred', 'a:b'), 'mongodb://localhost', array(array('b')))
MongoDB\Driver\Exception\InvalidArgumentException: Expected array for "readPreferenceTags" URI option, string given

/usr/share/php/MongoDB/Client.php:81
/builddir/build/BUILDROOT/php-alcaeus-mongo-php-adapter-1.1.2-2.fc26.remi.x86_64/usr/share/php/Alcaeus/Mongo/MongoClient.php:95
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/TestCase.php:45
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/Mongo/MongoClientTest.php:126

3) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoClientTest::testReadPreferenceOptionsAreInherited with data set "overridden" (array('secondaryPreferred', 'a:b'), 'mongodb://localhost/?readPref...gs=c:d', array(array('d'), array('b')))
MongoDB\Driver\Exception\InvalidArgumentException: Expected array for "readPreferenceTags" URI option, string given

/usr/share/php/MongoDB/Client.php:81
/builddir/build/BUILDROOT/php-alcaeus-mongo-php-adapter-1.1.2-2.fc26.remi.x86_64/usr/share/php/Alcaeus/Mongo/MongoClient.php:95
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/TestCase.php:45
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/Mongo/MongoClientTest.php:126

4) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoClientTest::testReadPreferenceOptionsAreInherited with data set "multipleTagsetsOptions" (array('secondaryPreferred', 'a:b,c:d'), 'mongodb://localhost', array(array('b', 'd')))
MongoDB\Driver\Exception\InvalidArgumentException: Expected array for "readPreferenceTags" URI option, string given

/usr/share/php/MongoDB/Client.php:81
/builddir/build/BUILDROOT/php-alcaeus-mongo-php-adapter-1.1.2-2.fc26.remi.x86_64/usr/share/php/Alcaeus/Mongo/MongoClient.php:95
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/TestCase.php:45
/builddir/build/BUILD/mongo-php-adapter-052cd5d1f0698b96993d8b1b613ff9c6d25b912f/tests/Alcaeus/MongoDbAdapter/Mongo/MongoClientTest.php:126

@alcaeus
Copy link
Owner

alcaeus commented Aug 11, 2017

Thanks Remi! I'll add beta 1 to the build pipeline later today and get on fixing these issues! 👍

@alcaeus alcaeus added this to the 1.1.3 milestone Aug 11, 2017
@alcaeus alcaeus self-assigned this Aug 11, 2017
@alcaeus alcaeus added the bug label Aug 11, 2017
@jmikola
Copy link
Contributor

jmikola commented Aug 11, 2017

@remicollet: Thanks for checking this as well!

1) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoCollectionTest::testFindOneConnectionIssue
Failed asserting that exception of type "MongoDB\Driver\Exception\InvalidArgumentException" matches expected exception "MongoConnectionException". Message was: "Failed to parse MongoDB URI: 'mongodb://localhost:28888?connectTimeoutMS=1'. Invalid host string in URI." at

This appears to be due to a libmongoc change, as "/" is required to separate the host and query string. I'll ask @bjori and @ajdavis about that later, but I believe this behavior is consistent with the connection string spec, which states:

The host information section of the connection string is delimited by the trailing slash ("/") or end of string.

"?" is not considered to be a delimiter that ends host parsing.

1) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoBinDataTest::testCreateWithBsonBinary
MongoDB\Driver\Exception\InvalidArgumentException: Expected UUID length to be 16 bytes, 3 given

We now validate argument length for Binary objects with UUID subtypes (PHPC-895).

2) Alcaeus\MongoDbAdapter\Tests\Mongo\MongoClientTest::testReadPreferenceOptionsAreInherited with data set "optionsArray" (array('secondaryPreferred', 'a:b'), 'mongodb://localhost', array(array('b')))
MongoDB\Driver\Exception\InvalidArgumentException: Expected array for "readPreferenceTags" URI option, string given

This and the related errors that follow are likely caused by throwing if a value in the URI options array has an unexpected type (PHPC-887). Previously, we would have simply ignored the option. I'm curious how the adapter was testing this, though. Were you purposefully constructing a client with invalid types and then checking that they were ignored, or did we just uncover a subtle gap in the adapter mimicking the ext-mongo API where it missed converting legacy option values to the new format?

@ajdavis
Copy link

ajdavis commented Aug 11, 2017

That's right, I did some rewriting of the parser here:

https://jira.mongodb.org/browse/CDRIVER-2190

and in the process fixed a related bug, which is that we thought this was valid:

mongodb://host?option=value

It must be:

mongodb://host/?option=value

@alcaeus
Copy link
Owner

alcaeus commented Aug 14, 2017

I'm curious how the adapter was testing this, though. Were you purposefully constructing a client with invalid types and then checking that they were ignored, or did we just uncover a subtle gap in the adapter mimicking the ext-mongo API where it missed converting legacy option values to the new format?

That last one would be my guess. Since the test passes against ext-mongo but no longer passes when converting for ext-mongodb, I'm guessing that the adapter will have to do some additional conversion there.

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

No branches or pull requests

4 participants