Skip to content

Commit a23b2aa

Browse files
committed
Merge branch 'v1.8'
* v1.8: Fix test failures due to wrong merge 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 a9ab2fc + 0202106 commit a23b2aa

14 files changed

+180
-64
lines changed

.evergreen/config.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ functions:
214214
export AZURE_CLIENT_SECRET="${client_side_encryption_azure_client_secret}"
215215
export GCP_EMAIL="${client_side_encryption_gcp_email}"
216216
export GCP_PRIVATEKEY="${client_side_encryption_gcp_privatekey}"
217+
export PATH="${PHP_PATH}/bin:$PATH"
217218
PHP_VERSION=${PHP_VERSION} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
218219
219220
"run atlas data lake test":
@@ -270,7 +271,11 @@ functions:
270271
${PREPARE_SHELL}
271272
file="${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"
272273
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
273-
[ -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"
274+
[ -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"
275+
# install-dependencies generates expansion file with the PHP_PATH for the chosen PHP version
276+
- command: expansions.update
277+
params:
278+
file: src/php-expansion.yml
274279

275280
pre:
276281
- func: "fetch source"
@@ -451,19 +456,19 @@ axes:
451456
# - id: "lowest-supported"
452457
# display_name: "1.10-dev (master)"
453458
# variables:
454-
# DRIVER_BRANCH: "master"
459+
# EXTENSION_BRANCH: "master"
455460
- id: "latest"
456461
display_name: "1.10-dev (master)"
457462
variables:
458-
DRIVER_BRANCH: "master"
463+
EXTENSION_BRANCH: "master"
459464
# - id: "1.10-dev"
460465
# display_name: "1.10-dev"
461466
# variables:
462-
# DRIVER_BRANCH: "v1.10"
467+
# EXTENSION_BRANCH: "v1.10"
463468
# - id: "latest-dev"
464469
# display_name: "1.11-dev (master)"
465470
# variables:
466-
# DRIVER_BRANCH: "master"
471+
# EXTENSION_BRANCH: "master"
467472

468473
- id: os-php7
469474
display_name: OS

.evergreen/install-dependencies.sh

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
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"
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+
echo 'PHP_PATH: "'$PHP_PATH'"' > php-expansion.yml
27+
export PATH=$PHP_PATH/bin:$PATH
28+
}
29+
530
install_extension ()
631
{
732
# Workaround to get PECL running on PHP 7.0
@@ -10,9 +35,9 @@ install_extension ()
1035

1136
rm -f ${PHP_PATH}/lib/php.ini
1237

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}
38+
if [ "x${EXTENSION_BRANCH}" != "x" ] || [ "x${EXTENSION_REPO}" != "x" ]; then
39+
CLONE_REPO=${EXTENSION_REPO:-https://github.com/mongodb/mongo-php-driver}
40+
CHECKOUT_BRANCH=${EXTENSION_BRANCH:-master}
1641

1742
echo "Compiling driver branch ${CHECKOUT_BRANCH} from repository ${CLONE_REPO}"
1843

@@ -29,15 +54,33 @@ install_extension ()
2954
make install
3055

3156
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}
57+
elif [ "x${EXTENSION_VERSION}" != "x" ]; then
58+
echo "Installing driver version ${EXTENSION_VERSION} from PECL"
59+
pecl install -f mongodb-${EXTENSION_VERSION}
3560
else
3661
echo "Installing latest driver version from PECL"
3762
pecl install -f mongodb
3863
fi
3964

4065
sudo cp ${PROJECT_DIRECTORY}/.evergreen/config/php.ini ${PHP_PATH}/lib/php.ini
66+
67+
php --ri mongodb
68+
}
69+
70+
install_composer ()
71+
{
72+
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
73+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
74+
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
75+
76+
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
77+
>&2 echo 'ERROR: Invalid installer checksum'
78+
rm composer-setup.php
79+
exit 1
80+
fi
81+
82+
php composer-setup.php --quiet
83+
rm composer-setup.php
4184
}
4285

4386
# Functions to fetch MongoDB binaries
@@ -83,17 +126,8 @@ case "$DEPENDENCIES" in
83126
;;
84127
esac
85128

86-
PHP_PATH=/opt/php/${PHP_VERSION}-64bit
87-
OLD_PATH=$PATH
88-
PATH=$PHP_PATH/bin:$OLD_PATH
89-
129+
set_php_version $PHP_VERSION
90130
install_extension
91-
92-
php --ri mongodb
93-
94-
# Install composer
95-
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
96-
php composer-setup.php
97-
php -r "unlink('composer-setup.php');"
131+
install_composer
98132

99133
php composer.phar update $COMPOSER_FLAGS

.evergreen/run-tests.sh

Lines changed: 33 additions & 7 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,14 +12,41 @@ AUTH=${AUTH:-noauth}
1312
SSL=${SSL:-nossl}
1413
MONGODB_URI=${MONGODB_URI:-}
1514
TESTS=${TESTS:-}
15+
IS_MATRIX_TESTING=${IS_MATRIX_TESTING:-}
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
2652
export SYMFONY_DEPRECATIONS_HELPER=999999
@@ -29,10 +55,10 @@ export SYMFONY_DEPRECATIONS_HELPER=999999
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
@@ -31,6 +31,8 @@
3131
* CRUD spec functional tests.
3232
*
3333
* @see https://github.com/mongodb/specifications/tree/master/source/crud/tests
34+
*
35+
* @group matrix-testing-exclude-server-5.0-driver-4.0
3436
*/
3537
class CrudSpecFunctionalTest extends FunctionalTestCase
3638
{

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
$this->skipIfGeoHaystackIndexIsNotSupported();

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)