Skip to content

PHPC-1159: Test on specific server versions in Travis CI #804

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

Merged
merged 2 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .travis.scripts/mo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash
# Copyright 2012-2014 MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function eval_params {
local params=$(sed -e 's|["]|\\\"|g' $1)
echo $(eval echo \"$params\")
}

function r {
echo $1| cut -d'/' -f 2
}

function a {
echo $(cd $(dirname $1); pwd)/$(basename $1)
}

function id {
local id_line=$(grep id $1 | head -n 1)
echo $(expr "$id_line" : '.*: *"\(.*\)" *,*')
}

function get {
echo "GET $1 $(curl --header 'Accept: application/json' --include --silent --request GET $1)"
}

function post {
echo "POST $1 $(curl --header 'Accept: application/json' --include --silent --request POST --data "$2" $1)"
}

function delete {
echo "DELETE $1 $(curl --header 'Accept: application/json' --include --silent --request DELETE $1)"
}

function code {
expr "$1" : '.*HTTP/1.[01] \([0-9]*\)'
}

function usage {
echo "usage: $0 configurations/cluster/file.json action"
echo "cluster: servers|replica_sets|sharded_clusters"
echo "action: start|status|stop"
exit 1
}

SSL_FILES=$(a ./ssl-files)
BASE_URL=${MONGO_ORCHESTRATION:-'http://localhost:8889'}

if [ $# -ne 2 ]; then usage; fi
if [ ! -f "$1" ]; then echo "configuration file '$1' not found"; exit 1; fi

ID=$(id $1)
if [ ! "$ID" ]; then echo "id field not found in configuration file '$1'"; exit 1; fi
R=$(r $1)

GET=$(get $BASE_URL/$R/$ID)
HTTP_CODE=$(code "$GET")
EXIT_CODE=0

case $2 in
start)
if [ "$HTTP_CODE" != "200" ]
then
WORKSPACE=${TRAVIS_BUILD_DIR}/orchestrations
rm -fr $WORKSPACE
mkdir $WORKSPACE
LOGPATH=$WORKSPACE
DBPATH=$WORKSPACE
POST_DATA=$(eval_params $1)
echo "DBPATH=$DBPATH"
echo "LOGPATH=$LOGPATH"
echo "POST_DATA='$POST_DATA'"
echo
POST=$(post $BASE_URL/$R "$POST_DATA")
echo "$POST"
HTTP_CODE=$(code "$POST")
if [ "$HTTP_CODE" != 200 ]; then EXIT_CODE=1; fi
else
echo "$GET"
fi
;;
stop)
if [ "$HTTP_CODE" == "200" ]
then
DELETE=$(delete $BASE_URL/$R/$ID)
echo "$DELETE"
HTTP_CODE=$(code "$DELETE")
if [ "$HTTP_CODE" != 204 ]; then EXIT_CODE=1; fi
else
echo "$GET"
fi
;;
status)
if [ "$HTTP_CODE" == "200" ]
then
echo "$GET"
else
echo "$GET"
EXIT_CODE=1
fi
;;
*)
usage
;;
esac
exit $EXIT_CODE
41 changes: 32 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,53 @@
sudo: false
language: php
sudo: false

addons:
apt:
packages:
- gdb
- lcov

env:
global:
- TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff"
- REPORT_EXIT_STATUS=1
- SERVER_VERSION=3.6.2

matrix:
include:
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2

services:
- mongodb

env:
global:
- TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff"
- REPORT_EXIT_STATUS=1
- php: 7.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for doing this with PHP 7.0, and not 7.2 for example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason in particular. The test for PHPLIB just happened to use PHP 7.0 to test older server versions.

env:
- SERVER_VERSION=2.6.12
- php: 7.0
env:
- SERVER_VERSION=3.0.15
- php: 7.0
env:
- SERVER_VERSION=3.2.18
- php: 7.0
env:
- SERVER_VERSION=3.4.11

before_install:
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This produced a warning in the Travis run: https://travis-ci.org/mongodb/mongo-php-driver/jobs/366254607#L553 — is that going to be a problem in the near future?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect this is due to older version of Python on the Travis images. Perhaps @ShaneHarvey can chime in here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per @behackett, we don't need to worry about this warning. A legitimate concern would be if the version of OpenSSL on these old CI environments causes connectivity issues due to not supporting TLS v1.2, but that's a completely different class of error.

- .travis.scripts/before_install.sh
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${SERVER_VERSION}.tgz
- tar zxf mongodb-linux-x86_64-${SERVER_VERSION}.tgz
- export PATH=${PWD}/mongodb-linux-x86_64-${SERVER_VERSION}/bin/:${PATH}
- mongod --version
- mongo-orchestration --version
- export MO_PATH=`python -c 'import mongo_orchestration; from os import path;
print(path.dirname(mongo_orchestration.__file__));'`
- php -r 'if ( ! ($f = php_ini_loaded_file())) { $f = PHP_CONFIG_FILE_PATH . "/php.ini"; } file_put_contents($f, "variables_order=EGPCS\n", FILE_APPEND); $a = file($f, FILE_IGNORE_NEW_LINES); var_dump($a[count($a)-1]);'

before_script:
- mongo-orchestration start
- pushd ${MO_PATH} && ${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh configurations/servers/clean.json start && popd
- ulimit -a
- ulimit -c unlimited || true
- .travis.scripts/before_script.sh
Expand All @@ -41,3 +61,6 @@ after_success:
after_failure:
- find . -name 'core*' -exec .travis.scripts/debug-core.sh {} \;
- find . -name '*.diff' -exec .travis.scripts/debug-diff.sh {} \;

after_script:
- mongo-orchestration stop
3 changes: 2 additions & 1 deletion tests/apm/overview.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
--TEST--
PHPC-349: APM Specification
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE); ?>
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/command/cursor-tailable-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Command tailable cursor iteration with maxAwaitTimeMS option
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
<?php NEEDS('REPLICASET'); NEEDS_ATLEAST_MONGODB_VERSION(REPLICASET, "3.2"); CLEANUP(REPLICASET); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/cursor/bug1050-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PHPC-1050: Command cursor should not invoke getMore at execution
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
<?php NEEDS('REPLICASET'); NEEDS_ATLEAST_MONGODB_VERSION(REPLICASET, "3.2"); CLEANUP(REPLICASET); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/cursor/bug1050-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PHPC-1050: Command cursor should not invoke getMore at execution (rewind omitted)
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
<?php NEEDS('REPLICASET'); NEEDS_ATLEAST_MONGODB_VERSION(REPLICASET, "3.2"); CLEANUP(REPLICASET); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
6 changes: 3 additions & 3 deletions tests/cursor/cursor-tailable-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Cursor tailable iteration with awaitData and maxAwaitTimeMS options
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down Expand Up @@ -34,12 +34,12 @@ $startTime = microtime(true);
echo "Awaiting results...\n";
$it->next();
printf("Waited for %.6f seconds\n", microtime(true) - $startTime);

// Sometimes the cursor will wait for 0.0099 seconds and sometimes it will wait for 0.01.
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
{_id: 1}
Awaiting results...
Waited for 0.01%d seconds
Waited for 0.0%d seconds
===DONE===
2 changes: 1 addition & 1 deletion tests/cursor/cursor-tailable_error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Cursor cursor killed during tailable iteration
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/cursorid/cursorid-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MongoDB\Driver\CursorID BSON serialization for killCursors command
--SKIPIF--
<?php if (8 !== PHP_INT_SIZE) { die('skip Only for 64-bit platform'); } ?>
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
--FILE--
<?php

Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-executeBulkWrite-011.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\BulkWrite: bypassDocumentValidation option
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-executeBulkWrite_error-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var_dump(iterator_to_array($cursor));
===DONE===
<?php exit(0); ?>
--EXPECTF--
BulkWriteException: E11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_001%sdup key: { : 1 }
BulkWriteException:%S E11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_001%sdup key: { : 1 }

===> WriteResult
server: %s:%d
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-executeBulkWrite_error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var_dump(iterator_to_array($cursor));
===DONE===
<?php exit(0); ?>
--EXPECTF--
BulkWriteException: Multiple write errors: "E11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_002%sdup key: { : 1 }", "E11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_002%sdup key: { : 2 }"
BulkWriteException: Multiple write errors: "%SE11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_002%sdup key: { : 1 }", "%SE11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_002%sdup key: { : 2 }"

===> WriteResult
server: %s:%d
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-executeBulkWrite_error-008.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Manager::executeBulkWrite() with empty BulkWrite
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-executeReadWriteCommand-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Manager::executeReadWriteCommand()
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-executeBulkWrite_error-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Server::executeBulkWrite() with empty BulkWrite
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-executeReadWriteCommand-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Server::executeReadWriteCommand()
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/server/server-getTags-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\Server::getTags() with standalone
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
1 change: 1 addition & 0 deletions tests/standalone/manager-as-singleton.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
PHPC-431: Segfault when using Manager through singleton class
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); ?>
--FILE--
<?php
use MongoDB\Driver\Manager;
Expand Down
2 changes: 1 addition & 1 deletion tests/writeResult/writeresult-getupsertedids-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MongoDB\Driver\WriteResult::getUpsertedIds() with client-generated values
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.0"); CLEANUP(STANDALONE); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
Expand Down
2 changes: 1 addition & 1 deletion tests/writeResult/writeresult-getwriteerrors-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ array(1) {
[0]=>
object(MongoDB\Driver\WriteError)#%d (%d) {
["message"]=>
string(%d) "E11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_001%sdup key: { : 2 }"
string(%d) "%SE11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_001%sdup key: { : 2 }"
["code"]=>
int(11000)
["index"]=>
Expand Down
4 changes: 2 additions & 2 deletions tests/writeResult/writeresult-getwriteerrors-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ array(2) {
[0]=>
object(MongoDB\Driver\WriteError)#%d (%d) {
["message"]=>
string(%d) "E11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 2 }"
string(%d) "%SE11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 2 }"
["code"]=>
int(11000)
["index"]=>
Expand All @@ -42,7 +42,7 @@ array(2) {
[1]=>
object(MongoDB\Driver\WriteError)#%d (%d) {
["message"]=>
string(%d) "E11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 4 }"
string(%d) "%SE11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 4 }"
["code"]=>
int(11000)
["index"]=>
Expand Down