-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-1113: Migrate tests to use a common URI env var #787
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
|
||
register_shutdown_function(function() { |
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.
See: http://php.net/manual/en/function.set-error-handler.php#112291
At the moment, I'm using all of these handlers to catch errors during SKIPIF
refactoring. We can decide if they're worth keeping later on. It may be preferable to ignore SKIPIF
errors/exceptions entirely and allow a test to fail outright.
"NS" => DATABASE_NAME . "." . COLLECTION_NAME, | ||
); | ||
def($consts); | ||
define('URI', getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1/'); |
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 going to require changes to make test
, which I intend to document in CONTRIBUTING.md
. The C driver takes a similar approach: https://github.com/mongodb/mongo-c-driver/blob/master/CONTRIBUTING.md#testing
* @param integer $type | ||
* @return string | ||
*/ | ||
function server_type_as_string($type) |
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.
I'm aware that this function isn't currently used. I created it when the topology-based skip functions were producing more verbose messages (e.g. "we need a replica set but found a standalone"). If I don't find a use for it later, I'll delete this before merging.
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.
I'd like to leave this in for now, as it may be useful down the line.
* @param integer $errno | ||
* @param string | ||
*/ | ||
function errno_as_string($errno) |
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.
Oh how I wish this was a built-in PHP function. Likewise for translating JSON constants.
46a4273
to
2e80266
Compare
897329d
to
a6a4e62
Compare
Status UpdateI ran the test suite against standalone, standalone-auth, standalone-ssl, and replica set topologies by setting the
These are likely related to the expected output making assumptions about running on a standalone. |
This sentence has been dangling since ae0219d.
This removes previous assumptions about the structure of the URI string.
Some of these calls are NOPs and can be removed, while others should use drop_collection().
Tests should now be passing a replica set topology. I believe all that's left will be to add additional topologies to Travis, which I can handle in another ticket. @derickr: Please review. |
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 largely fine. I have some questions, and I would prefer the deferred tests to be XFAILs, but I'm not too hung up about that.
@@ -2,7 +2,8 @@ | |||
MongoDB\Driver\Cursor iteration beyond last document (OP_QUERY) | |||
--SKIPIF-- | |||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | |||
<?php NEEDS('STANDALONE_30'); ?> | |||
<?php skip_if_not_live(); ?> | |||
<?php skip_if_server_version('>', '3.0.99'); ?> |
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.
Don't want to make these '>=', '3.1'
?
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.
That's technically cleaner. I'll do so.
@@ -1,8 +1,8 @@ | |||
--TEST-- | |||
Connect to MongoDB with using PLAIN auth mechanism | |||
--SKIPIF-- | |||
<?php echo "skip authMechanism=PLAIN (LDAP) tests must be reimplemented (PHPC-1172)\n"; ?> |
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.
I prefer having these as XFAIL for now, and not just skipped.
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.
Will make the change across the board for these.
@@ -1,6 +1,7 @@ | |||
--TEST-- | |||
MongoDB\Driver\Manager: Connecting to Replica Set with only secondary in seedlist | |||
--SKIPIF-- | |||
<?php echo "skip replica set seedlist tests must be reimplemented (PHPC-1173)\n"; ?> |
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.
These as XFAIL too please.
@@ -8,7 +8,7 @@ PHPC-950: Segfault killing cursor after subscriber HashTable is destroyed (no su | |||
<?php | |||
require_once __DIR__ . "/../utils/basic.inc"; | |||
|
|||
$manager = new MongoDB\Driver\Manager(STANDALONE); | |||
$manager = new MongoDB\Driver\Manager(URI); |
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.
You did write a script for this one, right? :-)
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 scripted search and replace, but everything else was manual as it required adding c conditional skips (e.g. REPLICASET
needed to require a replica set topology). After bulk-changing these to URI
, I then ran the suite against various topologies to determine which tests were not topology-agnostic.
@@ -1,6 +1,7 @@ | |||
--TEST-- | |||
Connect to MongoDB with using default auth mechanism #002 | |||
--SKIPIF-- | |||
<?php echo "skip parse_url() tests must be reimplemented (PHPC-1177)\n"; ?> |
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.
XFAIL again, please.
tests/functional/cursor-001.phpt
Outdated
@@ -1,6 +1,7 @@ | |||
--TEST-- | |||
Sorting single field, ascending, using the Cursor Iterator | |||
--SKIPIF-- | |||
<?php echo "skip LOAD() tests must be reimplemented (PHPC-1178)\n"; ?> |
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.
XFAIL again, please.
@@ -26,7 +26,6 @@ class MySubscriber implements MongoDB\Driver\Monitoring\CommandSubscriber | |||
} | |||
} | |||
|
|||
CLEANUP( STANDALONE ); |
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.
Does this not mean we're not cleaning up data? Maybe I misunderstand.
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.
These instances of CLEANUP()
were redundant, as it was already done in SKIPIF
. See:
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?> |
@@ -1,6 +1,7 @@ | |||
--TEST-- | |||
MongoDB\Driver\BulkWrite::update with arrayFilters | |||
--SKIPIF-- | |||
<?php echo "skip START() tests must be reimplemented (PHPC-1179)\n"; ?> |
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.
XFAIl, please.
@@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc"; | |||
require_once __DIR__ . "/../utils/observer.php"; | |||
|
|||
$manager = new MongoDB\Driver\Manager(URI); | |||
$server = $manager->selectServer(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY)); | |||
$server = $manager->selectServer(new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY)); |
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.
There must be a reason why RP_SECONDARY worked before — do you know why that is?
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.
If the topology type is single (i.e. standalone), mongoc_topology_description_select()
ignores the read preference. This conforms to the server selection spec's rules for Topology type: Single.
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.
Ah! 👍
Left in, this raises a warning which results in skipping the test, which defeats the point of XFAIL.
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
https://jira.mongodb.org/browse/PHPC-1113