Skip to content

PHPLIB-510: Implement spec test runner for FLE #715

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 9 commits into from
Feb 3, 2020
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ addons:
apt:
packages:
- gdb
- libcurl3
- libgssapi-krb5-2
- libkrb5-dbg
- libldap-2.4-2
- libpcap0.8
- libsasl2-2
- snmp
- openssl

cache:
directories:
Expand All @@ -17,7 +25,7 @@ env:
- DRIVER_VERSION=1.7.0
# TODO: remove once a 1.7 driver release has been tagged
- DRIVER_BRANCH="master"
- SERVER_DISTRO=ubuntu1604
- SERVER_DISTRO=enterprise-ubuntu1604
- SERVER_VERSION=4.2.0
- DEPLOYMENT=STANDALONE
- COMPOSER_OPTIONS=
Expand Down Expand Up @@ -65,7 +73,7 @@ jobs:
php: "7.0"
dist: trusty
env:
- SERVER_DISTRO=ubuntu1404
- SERVER_DISTRO=enterprise-ubuntu1404
- SERVER_VERSION=3.0.15
- DEPLOYMENT=STANDALONE_OLD
- stage: Test
Expand Down Expand Up @@ -131,7 +139,7 @@ jobs:
before_install:
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
- export SERVER_FILENAME=mongodb-linux-x86_64-${SERVER_DISTRO}-${SERVER_VERSION}
- wget -qO- http://fastdl.mongodb.org/linux/${SERVER_FILENAME}.tgz | tar xz
- wget -qO- https://downloads.mongodb.com/linux/${SERVER_FILENAME}.tgz | tar xz
- export PATH=${PWD}/${SERVER_FILENAME}/bin:${PATH}
- mongod --version
- mongo-orchestration --version
Expand Down
2 changes: 1 addition & 1 deletion .travis/debug-core.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

if [ "${TRAVIS_OS_NAME}" != "osx" ]; then
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
# https://www.ics.uci.edu/~pattis/common/handouts/macmingweclipse/allexperimental/mac-gdb-install.html
echo "Cannot debug core files on macOS: ${1}"
exit 1
Expand Down
37 changes: 37 additions & 0 deletions tests/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@
use function is_object;
use function is_string;
use function key;
use function ob_get_clean;
use function ob_start;
use function parse_url;
use function phpinfo;
use function preg_match;
use function preg_quote;
use function sprintf;
use function version_compare;
use const INFO_MODULES;

abstract class FunctionalTestCase extends TestCase
{
Expand Down Expand Up @@ -375,6 +381,17 @@ protected function skipIfCausalConsistencyIsNotSupported()
}
}

protected function skipIfClientSideEncryptionIsNotSupported()
{
if (version_compare($this->getFeatureCompatibilityVersion(), '4.2', '<')) {
$this->markTestSkipped('Client Side Encryption only supported on FCV 4.2 or higher');
}

if ($this->getModuleInfo('libmongocrypt') === 'disabled') {
$this->markTestSkipped('Client Side Encryption is not enabled in the MongoDB extension');
}
}

protected function skipIfTransactionsAreNotSupported()
{
if ($this->getPrimaryServer()->getType() === Server::TYPE_STANDALONE) {
Expand Down Expand Up @@ -420,6 +437,26 @@ private function disableFailPoints()
}
}

/**
* @param string $row
*
* @return string|null
*/
private function getModuleInfo($row)
{
ob_start();
phpinfo(INFO_MODULES);
$info = ob_get_clean();

$pattern = sprintf('/^%s([\w ]+)$/m', preg_quote($row . ' => '));

if (preg_match($pattern, $info, $matches) !== 1) {
return null;
}

return $matches[1];
}

/**
* Checks if the failCommand command is supported on this server version
*
Expand Down
6 changes: 2 additions & 4 deletions tests/SpecTests/ChangeStreamsSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class ChangeStreamsSpecTest extends FunctionalTestCase
/**
* Assert that the expected and actual command documents match.
*
* Note: this method may modify the $expected object.
*
* @param stdClass $expected Expected command document
* @param stdClass $actual Actual command document
*/
Expand Down Expand Up @@ -180,7 +178,7 @@ private function createChangeStream(stdClass $test)

switch ($test->target) {
case 'client':
return $context->client->watch($pipeline, $options);
return $context->getClient()->watch($pipeline, $options);
case 'database':
return $context->getDatabase()->watch($pipeline, $options);
case 'collection':
Expand Down Expand Up @@ -228,7 +226,7 @@ private function dropDatabasesAndCreateCollection($databaseName, $collectionName
{
$context = $this->getContext();

$database = $context->client->selectDatabase($databaseName);
$database = $context->getClient()->selectDatabase($databaseName);
$database->drop($context->defaultWriteOptions);
$database->createCollection($collectionName, $context->defaultWriteOptions);
}
Expand Down
Loading