Skip to content

Commit 3d3473c

Browse files
committed
Merge branch 'v1.7' into v1.8
* v1.7: PHPLIB-615 Matrix testing for 4.4 era drivers (#813) 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 ec2f3ca + 1ba1892 commit 3d3473c

14 files changed

+157
-53
lines changed

.evergreen/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ functions:
261261
${PREPARE_SHELL}
262262
file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"
263263
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
264-
[ -f "$file" ] && PHP_VERSION=${PHP_VERSION} DRIVER_VERSION=${DRIVER_VERSION} DRIVER_REPO=${DRIVER_REPO} DRIVER_BRANCH=${DRIVER_BRANCH} DEPENDENCIES=${DEPENDENCIES} sh $file || echo "$file not available, skipping"
264+
[ -f "$file" ] && PHP_VERSION=${PHP_VERSION} EXTENSION_VERSION=${EXTENSION_VERSION} EXTENSION_REPO=${EXTENSION_REPO} EXTENSION_BRANCH=${EXTENSION_BRANCH} DEPENDENCIES=${DEPENDENCIES} sh $file || echo "$file not available, skipping"
265265
266266
pre:
267267
- func: "fetch source"
@@ -437,23 +437,23 @@ axes:
437437
- id: "lowest-supported"
438438
display_name: "1.8.1"
439439
variables:
440-
DRIVER_VERSION: "1.8.1"
440+
EXTENSION_VERSION: "1.8.1"
441441
- id: "latest-stable"
442442
display_name: "1.9-stable"
443443
variables:
444-
DRIVER_VERSION: "stable"
444+
EXTENSION_VERSION: "stable"
445445
- id: "1.8-dev"
446446
display_name: "1.8-dev"
447447
variables:
448-
DRIVER_BRANCH: "v1.8"
448+
EXTENSION_BRANCH: "v1.8"
449449
- id: "1.9-dev"
450450
display_name: "1.9-dev"
451451
variables:
452-
DRIVER_BRANCH: "v1.9"
452+
EXTENSION_BRANCH: "v1.9"
453453
- id: "latest-dev"
454454
display_name: "1.10-dev (master)"
455455
variables:
456-
DRIVER_BRANCH: "master"
456+
EXTENSION_BRANCH: "master"
457457

458458
- id: os-php7
459459
display_name: OS

.evergreen/install-dependencies.sh

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
#!/bin/sh
2-
set -o xtrace # Write all commands first to stderr
32
set -o errexit # Exit the script with error if any of the commands fail
43

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+
529
install_extension ()
630
{
731
# Workaround to get PECL running on PHP 7.0
@@ -10,9 +34,9 @@ install_extension ()
1034

1135
rm -f ${PHP_PATH}/lib/php.ini
1236

13-
if [ "x${DRIVER_BRANCH}" != "x" ] || [ "x${DRIVER_REPO}" != "x" ]; then
14-
CLONE_REPO=${DRIVER_REPO:-https://github.com/mongodb/mongo-php-driver}
15-
CHECKOUT_BRANCH=${DRIVER_BRANCH:-master}
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}
1640

1741
echo "Compiling driver branch ${CHECKOUT_BRANCH} from repository ${CLONE_REPO}"
1842

@@ -29,25 +53,41 @@ install_extension ()
2953
make install
3054

3155
cd ${PROJECT_DIRECTORY}
32-
elif [ "x${DRIVER_VERSION}" != "x" ]; then
33-
echo "Installing driver version ${DRIVER_VERSION} from PECL"
34-
pecl install -f mongodb-${DRIVER_VERSION}
56+
elif [ "x${EXTENSION_VERSION}" != "x" ]; then
57+
echo "Installing driver version ${EXTENSION_VERSION} from PECL"
58+
pecl install -f mongodb-${EXTENSION_VERSION}
3559
else
3660
echo "Installing latest driver version from PECL"
3761
pecl install -f mongodb
3862
fi
3963

4064
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
4183
}
4284

43-
DIR=$(dirname $0)
4485
# Functions to fetch MongoDB binaries
45-
. $DIR/download-mongodb.sh
86+
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh
4687
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
4788

4889
get_distro
4990

50-
# See .evergreen/download-mongodb.sh for most possible values
5191
case "$DISTRO" in
5292
cygwin*)
5393
echo "Install Windows dependencies"
@@ -85,17 +125,8 @@ case "$DEPENDENCIES" in
85125
;;
86126
esac
87127

88-
PHP_PATH=/opt/php/${PHP_VERSION}-64bit
89-
OLD_PATH=$PATH
90-
PATH=$PHP_PATH/bin:$OLD_PATH
91-
128+
set_php_version $PHP_VERSION
92129
install_extension
93-
94-
php --ri mongodb
95-
96-
# Install composer
97-
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
98-
php composer-setup.php
99-
php -r "unlink('composer-setup.php');"
130+
install_composer
100131

101132
php composer.phar update $COMPOSER_FLAGS

.evergreen/run-tests.sh

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
2-
set -o xtrace # Write all commands first to stderr
32
set -o errexit # Exit the script with error if any of the commands fail
43

54
# Supported/used environment variables:
@@ -13,26 +12,53 @@ AUTH=${AUTH:-noauth}
1312
SSL=${SSL:-nossl}
1413
MONGODB_URI=${MONGODB_URI:-}
1514
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
1645

1746
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
1847
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
1948

20-
echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"
21-
22-
OLD_PATH=$PATH
23-
PATH=/opt/php/${PHP_VERSION}-64bit/bin:$OLD_PATH
49+
echo "Running tests with $AUTH and $SSL, connecting to: $MONGODB_URI"
2450

2551
# Disable failing PHPUnit due to deprecations
26-
SYMFONY_DEPRECATIONS_HELPER=999999
52+
export SYMFONY_DEPRECATIONS_HELPER=999999
2753

2854
# Run the tests, and store the results in a Evergreen compatible JSON results file
2955
case "$TESTS" in
3056
atlas-data-lake*)
3157
MONGODB_URI="mongodb://mhuser:[email protected]:27017"
32-
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --testsuite "Atlas Data Lake Test Suite"
58+
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --testsuite "Atlas Data Lake Test Suite" $PHPUNIT_OPTS
3359
;;
3460

3561
*)
36-
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml
62+
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml $PHPUNIT_OPTS
3763
;;
3864
esac

tests/Collection/CollectionFunctionalTest.php

Lines changed: 6 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ public function testExample_55_58()
933933
$this->assertInventoryCount(0);
934934
}
935935

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

tests/Model/IndexInfoFunctionalTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public function testIs2dSphere()
4949
$this->assertEquals($expectedVersion, $index['2dsphereIndexVersion']);
5050
}
5151

52+
/**
53+
* @group matrix-testing-exclude-server-5.0-driver-4.0
54+
* @group matrix-testing-exclude-server-5.0-driver-4.2
55+
* @group matrix-testing-exclude-server-5.0-driver-4.4
56+
*/
5257
public function testIsGeoHaystack()
5358
{
5459
$indexName = $this->collection->createIndex(['pos' => 'geoHaystack', 'x' => 1], ['bucketSize' => 5]);

tests/Operation/ListCollectionsFunctionalTest.php

Lines changed: 6 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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;

0 commit comments

Comments
 (0)