Skip to content

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

Merged
merged 35 commits into from
May 3, 2018

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Mar 23, 2018


register_shutdown_function(function() {
Copy link
Member Author

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/');
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 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)
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'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.

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 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)
Copy link
Member Author

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.

@jmikola jmikola force-pushed the phpc-1113 branch 4 times, most recently from 46a4273 to 2e80266 Compare March 28, 2018 21:17
@jmikola jmikola force-pushed the phpc-1113 branch 3 times, most recently from 897329d to a6a4e62 Compare May 1, 2018 20:12
@jmikola
Copy link
Member Author

jmikola commented May 1, 2018

Status Update

I ran the test suite against standalone, standalone-auth, standalone-ssl, and replica set topologies by setting the MONGODB_URI environment variable to one of the URIs in make list-servers and running make test. The standalone and standalone-auth environments pass completely. The standalone-ssl environment required manually adding "/?ssl=true" to the URI but failed due to self-signed certificates (PHPC-1180). The replica set topology had the following failures, which I'll look into next:

Causal consistency: $clusterTime is not sent in commands to unsupported deployments [tests/causal-consistency/causal-consistency-011.phpt]
MongoDB\Driver\Manager::executeCommand() [tests/manager/manager-executeCommand-001.phpt]
MongoDB\Driver\Manager::executeWriteCommand() throws CommandException for unsupported update operator [tests/manager/manager-executeWriteCommand_error-003.phpt]
MongoDB\Driver\Manager::getServers() (standalone) [tests/manager/manager-getservers-001.phpt]
MongoDB\Driver\Manager: Constructing invalid manager [tests/manager/manager-var-dump-001.phpt]
PHPC-671: Segfault if Manager is already freed when using selected Server [tests/server/bug0671-002.phpt]
MongoDB\Driver\Server debugInfo [tests/server/server-debug.phpt]
MongoDB\Driver\Server::executeCommand() [tests/server/server-executeCommand-001.phpt]
MongoDB\Driver\Server::executeReadWriteCommand() [tests/server/server-executeReadWriteCommand-001.phpt]
MongoDB\Driver\Server::executeWriteCommand() [tests/server/server-executeWriteCommand-001.phpt]
MongoDB\Driver\Server::getTags() with standalone [tests/server/server-getTags-001.phpt]
MongoDB\Driver\Manager::executeInsert() [tests/standalone/write-error-001.phpt]
PHPC-671: Segfault if Manager is already freed when using WriteResult's Server [tests/writeResult/bug0671-003.phpt]

These are likely related to the expected output making assumptions about running on a standalone.

@jmikola
Copy link
Member Author

jmikola commented May 2, 2018

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.

@jmikola jmikola requested a review from derickr May 2, 2018 22:57
@jmikola jmikola changed the title [WIP] PHPC-1113: Migrate tests to use a common URI env var PHPC-1113: Migrate tests to use a common URI env var May 2, 2018
Copy link
Contributor

@derickr derickr left a 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'); ?>
Copy link
Contributor

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' ?

Copy link
Member Author

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"; ?>
Copy link
Contributor

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.

Copy link
Member Author

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"; ?>
Copy link
Contributor

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);
Copy link
Contributor

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? :-)

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 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"; ?>
Copy link
Contributor

Choose a reason for hiding this comment

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

XFAIL again, please.

@@ -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"; ?>
Copy link
Contributor

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 );
Copy link
Contributor

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.

Copy link
Member Author

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"; ?>
Copy link
Contributor

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));
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah! 👍

Copy link
Contributor

@derickr derickr left a comment

Choose a reason for hiding this comment

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

LGTM

@jmikola jmikola merged commit e70c79d into mongodb:master May 3, 2018
jmikola added a commit that referenced this pull request May 3, 2018
@jmikola jmikola deleted the phpc-1113 branch May 3, 2018 17:20
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