Skip to content

Commit 31f0f19

Browse files
committed
Merge branch 'v1.6' into v1.7
* v1.6: Rename matrix testing exclusion groups PHPLIB-616 Continuous Matrix Testing for 4.2 era drivers (#812) PHPLIB-617 Continuous Matrix Testing for 4.0 era drivers (#810)
2 parents 38b6851 + 7a0f4d8 commit 31f0f19

15 files changed

+271
-0
lines changed

.evergreen/config/php.ini

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extension=mongodb.so

.evergreen/install-dependencies.sh

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/sh
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
set_php_version ()
5+
{
6+
PHP_VERSION=$1
7+
8+
if [ ! -d "/opt/php" ]; then
9+
echo "PHP is not available"
10+
exit 1
11+
fi
12+
13+
if [ -d "/opt/php/${PHP_VERSION}-64bit/bin" ]; then
14+
export PHP_PATH="/opt/php/${PHP_VERSION}-64bit/bin"
15+
else
16+
# Try to find the newest version matching our constant
17+
export PHP_PATH=`find /opt/php/ -maxdepth 1 -type d -name "${PHP_VERSION}.*-64bit" -print | sort -V -r | head -1`
18+
fi
19+
20+
if [ ! -d "$PHP_PATH" ]; then
21+
echo "Could not find PHP binaries for version ${PHP_VERSION}. Listing available versions..."
22+
ls -1 /opt/php
23+
exit 1
24+
fi
25+
26+
export PATH=$PHP_PATH/bin:$PATH
27+
}
28+
29+
install_extension ()
30+
{
31+
# Workaround to get PECL running on PHP 7.0
32+
# export PHP_PEAR_PHP_BIN=${PHP_PATH}/bin/php
33+
# export PHP_PEAR_INSTALL_DIR=${PHP_PATH}/bin/php
34+
35+
rm -f ${PHP_PATH}/lib/php.ini
36+
37+
if [ "x${EXTENSION_BRANCH}" != "x" ] || [ "x${EXTENSION_REPO}" != "x" ]; then
38+
CLONE_REPO=${EXTENSION_REPO:-https://github.com/mongodb/mongo-php-driver}
39+
CHECKOUT_BRANCH=${EXTENSION_BRANCH:-master}
40+
41+
echo "Compiling driver branch ${CHECKOUT_BRANCH} from repository ${CLONE_REPO}"
42+
43+
mkdir -p /tmp/compile
44+
rm -rf /tmp/compile/mongo-php-driver
45+
git clone ${CLONE_REPO} /tmp/compile/mongo-php-driver
46+
cd /tmp/compile/mongo-php-driver
47+
48+
git checkout ${CHECKOUT_BRANCH}
49+
git submodule update --init
50+
phpize
51+
./configure --enable-mongodb-developer-flags
52+
make all -j20 > /dev/null
53+
make install
54+
55+
cd ${PROJECT_DIRECTORY}
56+
elif [ "x${EXTENSION_VERSION}" != "x" ]; then
57+
echo "Installing driver version ${EXTENSION_VERSION} from PECL"
58+
pecl install -f mongodb-${EXTENSION_VERSION}
59+
else
60+
echo "Installing latest driver version from PECL"
61+
pecl install -f mongodb
62+
fi
63+
64+
sudo cp ${PROJECT_DIRECTORY}/.evergreen/config/php.ini ${PHP_PATH}/lib/php.ini
65+
66+
php --ri mongodb
67+
}
68+
69+
install_composer ()
70+
{
71+
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
72+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
73+
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
74+
75+
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
76+
>&2 echo 'ERROR: Invalid installer checksum'
77+
rm composer-setup.php
78+
exit 1
79+
fi
80+
81+
php composer-setup.php --quiet
82+
rm composer-setup.php
83+
}
84+
85+
# Functions to fetch MongoDB binaries
86+
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh
87+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
88+
89+
get_distro
90+
91+
case "$DISTRO" in
92+
cygwin*)
93+
echo "Install Windows dependencies"
94+
;;
95+
96+
darwin*)
97+
echo "Install macOS dependencies"
98+
;;
99+
100+
linux-rhel*)
101+
echo "Install RHEL dependencies"
102+
;;
103+
104+
linux-ubuntu*)
105+
echo "Install Ubuntu dependencies"
106+
sudo apt-get install -y awscli || true
107+
;;
108+
109+
sunos*)
110+
echo "Install Solaris dependencies"
111+
sudo /opt/csw/bin/pkgutil -y -i sasl_dev || true
112+
;;
113+
114+
*)
115+
echo "All other platforms..."
116+
;;
117+
esac
118+
119+
case "$DEPENDENCIES" in
120+
lowest*)
121+
COMPOSER_FLAGS="${COMPOSER_FLAGS} --prefer-lowest"
122+
;;
123+
124+
*)
125+
;;
126+
esac
127+
128+
set_php_version $PHP_VERSION
129+
install_extension
130+
install_composer
131+
132+
php composer.phar update $COMPOSER_FLAGS

.evergreen/run-tests.sh

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
# Supported/used environment variables:
5+
# AUTH Set to enable authentication. Defaults to "noauth"
6+
# SSL Set to enable SSL. Defaults to "nossl"
7+
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info)
8+
# MARCH Machine Architecture. Defaults to lowercase uname -m
9+
10+
11+
AUTH=${AUTH:-noauth}
12+
SSL=${SSL:-nossl}
13+
MONGODB_URI=${MONGODB_URI:-}
14+
TESTS=${TESTS:-}
15+
IS_MATRIX_TESTING=${IS_MATRIX_TESTING:-false}
16+
17+
# For matrix testing, we have to determine the correct driver version
18+
if [ "$IS_MATRIX_TESTING" == "true" ]; then
19+
case "${DRIVER_MONGODB_VERSION}" in
20+
'4.4')
21+
export EXTENSION_VERSION='1.8.2'
22+
;;
23+
'4.2')
24+
export EXTENSION_VERSION='1.6.1'
25+
;;
26+
'4.0')
27+
export EXTENSION_VERSION='1.5.5'
28+
;;
29+
esac
30+
31+
case "${MONGODB_VERSION}" in
32+
latest)
33+
MONGODB_VERSION_NUMBER='5.0'
34+
;;
35+
*)
36+
MONGODB_VERSION_NUMBER=$MONGODB_VERSION
37+
;;
38+
esac
39+
40+
PHPUNIT_OPTS="--dont-report-useless-tests --exclude-group matrix-testing-exclude-server-${MONGODB_VERSION_NUMBER}-driver-${DRIVER_MONGODB_VERSION},matrix-testing-exclude-server-${MONGODB_VERSION_NUMBER}-driver-${DRIVER_MONGODB_VERSION}-topology-${TOPOLOGY}"
41+
42+
DIR=$(dirname $0)
43+
. $DIR/install-dependencies.sh
44+
fi
45+
46+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
47+
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
48+
49+
echo "Running tests with $AUTH and $SSL, connecting to: $MONGODB_URI"
50+
51+
# Disable failing PHPUnit due to deprecations
52+
export SYMFONY_DEPRECATIONS_HELPER=999999
53+
54+
# Run the tests, and store the results in a Evergreen compatible JSON results file
55+
case "$TESTS" in
56+
*)
57+
php vendor/bin/phpunit --configuration phpunit.evergreen.xml $PHPUNIT_OPTS
58+
;;
59+
esac

phpunit.evergreen.xml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.3/phpunit.xsd"
6+
backupGlobals="false"
7+
backupStaticAttributes="false"
8+
colors="true"
9+
convertErrorsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertWarningsToExceptions="true"
12+
stopOnFailure="false"
13+
syntaxCheck="false"
14+
bootstrap="tests/bootstrap.php"
15+
>
16+
17+
<php>
18+
<ini name="error_reporting" value="-1"/>
19+
<env name="MONGODB_URI" value="mongodb://127.0.0.1:27017/?serverSelectionTimeoutMS=100"/>
20+
<env name="MONGODB_DATABASE" value="phplib_test"/>
21+
</php>
22+
23+
<testsuites>
24+
<testsuite name="Default Test Suite">
25+
<directory>./tests/</directory>
26+
</testsuite>
27+
</testsuites>
28+
29+
<logging>
30+
<log type="junit" target="test-results.xml" />
31+
</logging>
32+
</phpunit>

tests/Collection/CollectionFunctionalTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ public function testWithOptionsPassesOptions()
379379
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
380380
}
381381

382+
/**
383+
* @group matrix-testing-exclude-server-4.4-driver-4.0
384+
* @group matrix-testing-exclude-server-4.4-driver-4.2
385+
* @group matrix-testing-exclude-server-5.0-driver-4.0
386+
* @group matrix-testing-exclude-server-5.0-driver-4.2
387+
*/
382388
public function testMapReduce()
383389
{
384390
$this->createFixtures(3);

tests/Collection/CrudSpecFunctionalTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* CRUD spec functional tests.
3333
*
3434
* @see https://github.com/mongodb/specifications/tree/master/source/crud/tests
35+
*
36+
* @group matrix-testing-exclude-server-5.0-driver-4.0
3537
*/
3638
class CrudSpecFunctionalTest extends FunctionalTestCase
3739
{

tests/Database/DatabaseFunctionalTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public function testGetSelectsCollectionAndInheritsOptions()
172172
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
173173
}
174174

175+
/**
176+
* @group matrix-testing-exclude-server-4.2-driver-4.0-topology-sharded_cluster
177+
* @group matrix-testing-exclude-server-4.4-driver-4.0-topology-sharded_cluster
178+
* @group matrix-testing-exclude-server-5.0-driver-4.0-topology-sharded_cluster
179+
*/
175180
public function testModifyCollection()
176181
{
177182
$this->database->createCollection($this->getCollectionName());

tests/DocumentationExamplesTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ public function testExample_55_58()
931931
$this->assertInventoryCount(0);
932932
}
933933

934+
/** @group matrix-testing-exclude-server-5.0-driver-4.0-topology-sharded_cluster */
934935
public function testChangeStreamExample_1_4()
935936
{
936937
$this->skipIfChangeStreamIsNotSupported();

tests/Model/IndexInfoFunctionalTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function testIs2dSphere()
4747
$this->assertEquals($expectedVersion, $index['2dsphereIndexVersion']);
4848
}
4949

50+
/**
51+
* @group matrix-testing-exclude-server-5.0-driver-4.0
52+
* @group matrix-testing-exclude-server-5.0-driver-4.2
53+
*/
5054
public function testIsGeoHaystack()
5155
{
5256
$indexName = $this->collection->createIndex(['pos' => 'geoHaystack', 'x' => 1], ['bucketSize' => 5]);

tests/Operation/ListCollectionsFunctionalTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public function testListCollectionsForNewlyCreatedDatabase()
3636
}
3737
}
3838

39+
/**
40+
* @group matrix-testing-exclude-server-4.4-driver-4.0
41+
* @group matrix-testing-exclude-server-4.4-driver-4.2
42+
* @group matrix-testing-exclude-server-5.0-driver-4.0
43+
* @group matrix-testing-exclude-server-5.0-driver-4.2
44+
*/
3945
public function testIdIndexAndInfo()
4046
{
4147
if (version_compare($this->getServerVersion(), '3.4.0', '<')) {

tests/Operation/MapReduceFunctionalTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
use function usort;
1515
use function version_compare;
1616

17+
/**
18+
* @group matrix-testing-exclude-server-4.4-driver-4.0
19+
* @group matrix-testing-exclude-server-4.4-driver-4.2
20+
* @group matrix-testing-exclude-server-5.0-driver-4.0
21+
* @group matrix-testing-exclude-server-5.0-driver-4.2
22+
*/
1723
class MapReduceFunctionalTest extends FunctionalTestCase
1824
{
1925
public function testDefaultReadConcernIsOmitted()

tests/Operation/ModifyCollectionFunctionalTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
class ModifyCollectionFunctionalTest extends FunctionalTestCase
1010
{
11+
/**
12+
* @group matrix-testing-exclude-server-4.2-driver-4.0-topology-sharded_cluster
13+
* @group matrix-testing-exclude-server-4.4-driver-4.0-topology-sharded_cluster
14+
* @group matrix-testing-exclude-server-5.0-driver-4.0-topology-sharded_cluster
15+
*/
1116
public function testCollMod()
1217
{
1318
$this->createCollection();

tests/Operation/WatchFunctionalTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
use function sprintf;
3232
use function version_compare;
3333

34+
/**
35+
* @group matrix-testing-exclude-server-4.2-driver-4.0-topology-sharded_cluster
36+
* @group matrix-testing-exclude-server-4.4-driver-4.0-topology-sharded_cluster
37+
* @group matrix-testing-exclude-server-5.0-driver-4.0-topology-sharded_cluster
38+
*/
3439
class WatchFunctionalTest extends FunctionalTestCase
3540
{
3641
use SetUpTearDownTrait;

tests/SpecTests/FunctionalTestCase.php

+4
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ protected function dropTestAndOutcomeCollections()
198198
{
199199
$context = $this->getContext();
200200

201+
if ($context->databaseName === 'admin') {
202+
return;
203+
}
204+
201205
if ($context->bucketName !== null) {
202206
$bucket = $context->getGridFSBucket($context->defaultWriteOptions);
203207
$bucket->drop();

tests/SpecTests/RetryableReadsSpecTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public static function assertCommandMatches(stdClass $expected, stdClass $actual
3838
* Execute an individual test case from the specification.
3939
*
4040
* @dataProvider provideTests
41+
* @group matrix-testing-exclude-server-4.4-driver-4.2
42+
* @group matrix-testing-exclude-server-5.0-driver-4.2
43+
*
4144
* @param stdClass $test Individual "tests[]" document
4245
* @param array $runOn Top-level "runOn" array with server requirements
4346
* @param array|object $data Top-level "data" array to initialize collection

0 commit comments

Comments
 (0)