-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-617 Continuous Matrix Testing for 4.0 era drivers #810
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
Changes from all commits
c989da5
9830552
e44e98b
49650ea
fb2efed
4005292
a5bd42b
38072fe
199cd73
2129841
ba0c0f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extension=mongodb.so |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#!/bin/sh | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
set_php_version () | ||
{ | ||
PHP_VERSION=$1 | ||
|
||
if [ ! -d "/opt/php" ]; then | ||
echo "PHP is not available" | ||
exit 1 | ||
fi | ||
|
||
if [ -d "/opt/php/${PHP_VERSION}-64bit/bin" ]; then | ||
export PHP_PATH="/opt/php/${PHP_VERSION}-64bit/bin" | ||
else | ||
# Try to find the newest version matching our constant | ||
export PHP_PATH=`find /opt/php/ -maxdepth 1 -type d -name "${PHP_VERSION}.*-64bit" -print | sort -V -r | head -1` | ||
fi | ||
|
||
if [ ! -d "$PHP_PATH" ]; then | ||
echo "Could not find PHP binaries for version ${PHP_VERSION}. Listing available versions..." | ||
ls -1 /opt/php | ||
exit 1 | ||
fi | ||
|
||
export PATH=$PHP_PATH/bin:$PATH | ||
} | ||
|
||
install_extension () | ||
{ | ||
# Workaround to get PECL running on PHP 7.0 | ||
# export PHP_PEAR_PHP_BIN=${PHP_PATH}/bin/php | ||
# export PHP_PEAR_INSTALL_DIR=${PHP_PATH}/bin/php | ||
|
||
rm -f ${PHP_PATH}/lib/php.ini | ||
|
||
if [ "x${EXTENSION_BRANCH}" != "x" ] || [ "x${EXTENSION_REPO}" != "x" ]; then | ||
CLONE_REPO=${EXTENSION_REPO:-https://github.com/mongodb/mongo-php-driver} | ||
CHECKOUT_BRANCH=${EXTENSION_BRANCH:-master} | ||
|
||
echo "Compiling driver branch ${CHECKOUT_BRANCH} from repository ${CLONE_REPO}" | ||
|
||
mkdir -p /tmp/compile | ||
rm -rf /tmp/compile/mongo-php-driver | ||
git clone ${CLONE_REPO} /tmp/compile/mongo-php-driver | ||
cd /tmp/compile/mongo-php-driver | ||
|
||
git checkout ${CHECKOUT_BRANCH} | ||
git submodule update --init | ||
phpize | ||
./configure --enable-mongodb-developer-flags | ||
make all -j20 > /dev/null | ||
make install | ||
|
||
cd ${PROJECT_DIRECTORY} | ||
elif [ "x${EXTENSION_VERSION}" != "x" ]; then | ||
echo "Installing driver version ${EXTENSION_VERSION} from PECL" | ||
pecl install -f mongodb-${EXTENSION_VERSION} | ||
else | ||
echo "Installing latest driver version from PECL" | ||
pecl install -f mongodb | ||
fi | ||
|
||
sudo cp ${PROJECT_DIRECTORY}/.evergreen/config/php.ini ${PHP_PATH}/lib/php.ini | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
php --ri mongodb | ||
} | ||
|
||
install_composer () | ||
{ | ||
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" | ||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" | ||
|
||
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then | ||
>&2 echo 'ERROR: Invalid installer checksum' | ||
rm composer-setup.php | ||
exit 1 | ||
fi | ||
|
||
php composer-setup.php --quiet | ||
rm composer-setup.php | ||
} | ||
|
||
# Functions to fetch MongoDB binaries | ||
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh | ||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
|
||
get_distro | ||
|
||
case "$DISTRO" in | ||
cygwin*) | ||
echo "Install Windows dependencies" | ||
;; | ||
|
||
darwin*) | ||
echo "Install macOS dependencies" | ||
;; | ||
|
||
linux-rhel*) | ||
echo "Install RHEL dependencies" | ||
;; | ||
|
||
linux-ubuntu*) | ||
echo "Install Ubuntu dependencies" | ||
sudo apt-get install -y awscli || true | ||
;; | ||
|
||
sunos*) | ||
echo "Install Solaris dependencies" | ||
sudo /opt/csw/bin/pkgutil -y -i sasl_dev || true | ||
;; | ||
|
||
*) | ||
echo "All other platforms..." | ||
;; | ||
esac | ||
|
||
case "$DEPENDENCIES" in | ||
lowest*) | ||
COMPOSER_FLAGS="${COMPOSER_FLAGS} --prefer-lowest" | ||
;; | ||
|
||
*) | ||
;; | ||
esac | ||
|
||
set_php_version $PHP_VERSION | ||
install_extension | ||
install_composer | ||
|
||
php composer.phar update $COMPOSER_FLAGS |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
# Supported/used environment variables: | ||
# AUTH Set to enable authentication. Defaults to "noauth" | ||
# SSL Set to enable SSL. Defaults to "nossl" | ||
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info) | ||
# MARCH Machine Architecture. Defaults to lowercase uname -m | ||
|
||
|
||
AUTH=${AUTH:-noauth} | ||
SSL=${SSL:-nossl} | ||
MONGODB_URI=${MONGODB_URI:-} | ||
TESTS=${TESTS:-} | ||
IS_MATRIX_TESTING=${IS_MATRIX_TESTING:-false} | ||
alcaeus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# For matrix testing, we have to determine the correct driver version | ||
if [ "$IS_MATRIX_TESTING" == "true" ]; then | ||
case "${DRIVER_MONGODB_VERSION}" in | ||
'4.4') | ||
export EXTENSION_VERSION='1.8.2' | ||
;; | ||
'4.2') | ||
export EXTENSION_VERSION='1.6.1' | ||
;; | ||
'4.0') | ||
export EXTENSION_VERSION='1.5.5' | ||
;; | ||
esac | ||
|
||
case "${MONGODB_VERSION}" in | ||
latest) | ||
MONGODB_VERSION_NUMBER='5.0' | ||
;; | ||
*) | ||
MONGODB_VERSION_NUMBER=$MONGODB_VERSION | ||
;; | ||
esac | ||
|
||
PHPUNIT_OPTS="--dont-report-useless-tests --exclude-group matrix-testing-server-${MONGODB_VERSION_NUMBER}-driver-${DRIVER_MONGODB_VERSION},matrix-testing-server-${MONGODB_VERSION_NUMBER}-driver-${DRIVER_MONGODB_VERSION}-topology-${TOPOLOGY}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, not happy about the formatting, but your suggestion to use groups to skip tests was great. |
||
|
||
DIR=$(dirname $0) | ||
. $DIR/install-dependencies.sh | ||
fi | ||
|
||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]') | ||
|
||
echo "Running tests with $AUTH and $SSL, connecting to: $MONGODB_URI" | ||
|
||
# Disable failing PHPUnit due to deprecations | ||
export SYMFONY_DEPRECATIONS_HELPER=999999 | ||
|
||
# Run the tests, and store the results in a Evergreen compatible JSON results file | ||
case "$TESTS" in | ||
*) | ||
php vendor/bin/phpunit --configuration phpunit.evergreen.xml $PHPUNIT_OPTS | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.3/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/bootstrap.php" | ||
> | ||
|
||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<env name="MONGODB_URI" value="mongodb://127.0.0.1:27017/?serverSelectionTimeoutMS=100"/> | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<env name="MONGODB_DATABASE" value="phplib_test"/> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="Default Test Suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<logging> | ||
<log type="junit" target="test-results.xml" /> | ||
</logging> | ||
</phpunit> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,10 @@ protected function assertSameObjectId($expectedObjectId, $actualObjectId) | |
|
||
protected function getFeatureCompatibilityVersion(ReadPreference $readPreference = null) | ||
{ | ||
if ($this->isShardedCluster()) { | ||
return $this->getServerVersion($readPreference); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backport? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Fixed a number of tests 😉 |
||
if (version_compare($this->getServerVersion(), '3.4.0', '<')) { | ||
return $this->getServerVersion($readPreference); | ||
} | ||
|
@@ -133,4 +137,9 @@ protected function skipIfTransactionsAreNotSupported() | |
$this->markTestSkipped('Transactions require WiredTiger storage engine'); | ||
} | ||
} | ||
|
||
protected function isShardedCluster() | ||
{ | ||
return $this->getPrimaryServer()->getType() == Server::TYPE_MONGOS; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.