Skip to content

Commit d0d3cc7

Browse files
committed
Ensure these tests only run with wiredTiger engine
1 parent 0465d4f commit d0d3cc7

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

tests/manager/manager-executeReadCommand-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Manager::executeReadCommand()
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); ?>
5+
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); NEEDS_STORAGE_ENGINE(STANDALONE, "wiredTiger"); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/server/server-executeReadCommand-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Server::executeReadCommand()
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); CLEANUP(STANDALONE); ?>
5+
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); NEEDS_STORAGE_ENGINE(STANDALONE, "wiredTiger"); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/utils/tools.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ function NEEDS_ATLEAST_MONGODB_VERSION($uri, $version) {
156156
}
157157
}
158158

159+
function NEEDS_STORAGE_ENGINE($uri, $engine) {
160+
$manager = new MongoDB\Driver\Manager($uri);
161+
$cmd = new MongoDB\Driver\Command(["serverStatus" => 1]);
162+
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_PRIMARY);
163+
164+
try {
165+
$cursor = $manager->executeCommand("admin", $cmd, $rp);
166+
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
167+
$document = current($cursor->toArray());
168+
169+
if ($document['storageEngine']['name'] != $engine) {
170+
echo "skip Needs storage engine '$engine', but is '{$document['storageEngine']['name']}'";
171+
}
172+
} catch(Exception $e) {
173+
echo "skip (needs version); $uri ($version): " . $e->getCode(), ": ", $e->getMessage();
174+
exit(1);
175+
}
176+
}
177+
159178
function CLEANUP($uri, $dbname = DATABASE_NAME, $collname = COLLECTION_NAME) {
160179
try {
161180
$manager = new MongoDB\Driver\Manager($uri);

0 commit comments

Comments
 (0)