Skip to content

Commit 0e8cf55

Browse files
committed
PHPC-1159: Test on specific server versions in Travis CI
1 parent c841679 commit 0e8cf55

20 files changed

+171
-29
lines changed

.travis.scripts/mo.sh

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/bin/bash
2+
# Copyright 2012-2014 MongoDB, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
function eval_params {
17+
local params=$(sed -e 's|["]|\\\"|g' $1)
18+
echo $(eval echo \"$params\")
19+
}
20+
21+
function r {
22+
echo $1| cut -d'/' -f 2
23+
}
24+
25+
function a {
26+
echo $(cd $(dirname $1); pwd)/$(basename $1)
27+
}
28+
29+
function id {
30+
local id_line=$(grep id $1 | head -n 1)
31+
echo $(expr "$id_line" : '.*: *"\(.*\)" *,*')
32+
}
33+
34+
function get {
35+
echo "GET $1 $(curl --header 'Accept: application/json' --include --silent --request GET $1)"
36+
}
37+
38+
function post {
39+
echo "POST $1 $(curl --header 'Accept: application/json' --include --silent --request POST --data "$2" $1)"
40+
}
41+
42+
function delete {
43+
echo "DELETE $1 $(curl --header 'Accept: application/json' --include --silent --request DELETE $1)"
44+
}
45+
46+
function code {
47+
expr "$1" : '.*HTTP/1.[01] \([0-9]*\)'
48+
}
49+
50+
function usage {
51+
echo "usage: $0 configurations/cluster/file.json action"
52+
echo "cluster: servers|replica_sets|sharded_clusters"
53+
echo "action: start|status|stop"
54+
exit 1
55+
}
56+
57+
SSL_FILES=$(a ./ssl-files)
58+
BASE_URL=${MONGO_ORCHESTRATION:-'http://localhost:8889'}
59+
60+
if [ $# -ne 2 ]; then usage; fi
61+
if [ ! -f "$1" ]; then echo "configuration file '$1' not found"; exit 1; fi
62+
63+
ID=$(id $1)
64+
if [ ! "$ID" ]; then echo "id field not found in configuration file '$1'"; exit 1; fi
65+
R=$(r $1)
66+
67+
GET=$(get $BASE_URL/$R/$ID)
68+
HTTP_CODE=$(code "$GET")
69+
EXIT_CODE=0
70+
71+
case $2 in
72+
start)
73+
if [ "$HTTP_CODE" != "200" ]
74+
then
75+
WORKSPACE=${TRAVIS_BUILD_DIR}/orchestrations
76+
rm -fr $WORKSPACE
77+
mkdir $WORKSPACE
78+
LOGPATH=$WORKSPACE
79+
DBPATH=$WORKSPACE
80+
POST_DATA=$(eval_params $1)
81+
echo "DBPATH=$DBPATH"
82+
echo "LOGPATH=$LOGPATH"
83+
echo "POST_DATA='$POST_DATA'"
84+
echo
85+
POST=$(post $BASE_URL/$R "$POST_DATA")
86+
echo "$POST"
87+
HTTP_CODE=$(code "$POST")
88+
if [ "$HTTP_CODE" != 200 ]; then EXIT_CODE=1; fi
89+
else
90+
echo "$GET"
91+
fi
92+
;;
93+
stop)
94+
if [ "$HTTP_CODE" == "200" ]
95+
then
96+
DELETE=$(delete $BASE_URL/$R/$ID)
97+
echo "$DELETE"
98+
HTTP_CODE=$(code "$DELETE")
99+
if [ "$HTTP_CODE" != 204 ]; then EXIT_CODE=1; fi
100+
else
101+
echo "$GET"
102+
fi
103+
;;
104+
status)
105+
if [ "$HTTP_CODE" == "200" ]
106+
then
107+
echo "$GET"
108+
else
109+
echo "$GET"
110+
EXIT_CODE=1
111+
fi
112+
;;
113+
*)
114+
usage
115+
;;
116+
esac
117+
exit $EXIT_CODE

.travis.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,53 @@
1-
sudo: false
21
language: php
2+
sudo: false
33

44
addons:
55
apt:
66
packages:
77
- gdb
88
- lcov
99

10+
env:
11+
global:
12+
- TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff"
13+
- REPORT_EXIT_STATUS=1
14+
- SERVER_VERSION=3.6.2
15+
1016
matrix:
1117
include:
1218
- php: 5.5
1319
- php: 5.6
1420
- php: 7.0
1521
- php: 7.1
1622
- php: 7.2
17-
18-
services:
19-
- mongodb
20-
21-
env:
22-
global:
23-
- TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff"
24-
- REPORT_EXIT_STATUS=1
23+
- php: 7.0
24+
env:
25+
- SERVER_VERSION=2.6.12
26+
- php: 7.0
27+
env:
28+
- SERVER_VERSION=3.0.15
29+
- php: 7.0
30+
env:
31+
- SERVER_VERSION=3.2.18
32+
- php: 7.0
33+
env:
34+
- SERVER_VERSION=3.4.11
2535

2636
before_install:
37+
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
2738
- .travis.scripts/before_install.sh
39+
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${SERVER_VERSION}.tgz
40+
- tar zxf mongodb-linux-x86_64-${SERVER_VERSION}.tgz
41+
- export PATH=${PWD}/mongodb-linux-x86_64-${SERVER_VERSION}/bin/:${PATH}
42+
- mongod --version
43+
- mongo-orchestration --version
44+
- export MO_PATH=`python -c 'import mongo_orchestration; from os import path;
45+
print(path.dirname(mongo_orchestration.__file__));'`
2846
- 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]);'
2947

3048
before_script:
49+
- mongo-orchestration start
50+
- pushd ${MO_PATH} && ${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh configurations/servers/clean.json start && popd
3151
- ulimit -a
3252
- ulimit -c unlimited || true
3353
- .travis.scripts/before_script.sh
@@ -41,3 +61,6 @@ after_success:
4161
after_failure:
4262
- find . -name 'core*' -exec .travis.scripts/debug-core.sh {} \;
4363
- find . -name '*.diff' -exec .travis.scripts/debug-diff.sh {} \;
64+
65+
after_script:
66+
- mongo-orchestration stop

tests/apm/overview.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--TEST--
22
PHPC-349: APM Specification
33
--SKIPIF--
4-
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE); ?>
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
56
--FILE--
67
<?php
78
require_once __DIR__ . "/../utils/basic.inc";

tests/command/cursor-tailable-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Command tailable cursor iteration with maxAwaitTimeMS option
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
5+
<?php NEEDS('REPLICASET'); NEEDS_ATLEAST_MONGODB_VERSION(REPLICASET, "3.2"); CLEANUP(REPLICASET); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/cursor/bug1050-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PHPC-1050: Command cursor should not invoke getMore at execution
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
5+
<?php NEEDS('REPLICASET'); NEEDS_ATLEAST_MONGODB_VERSION(REPLICASET, "3.2"); CLEANUP(REPLICASET); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/cursor/bug1050-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PHPC-1050: Command cursor should not invoke getMore at execution (rewind omitted)
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('REPLICASET'); CLEANUP(REPLICASET); ?>
5+
<?php NEEDS('REPLICASET'); NEEDS_ATLEAST_MONGODB_VERSION(REPLICASET, "3.2"); CLEANUP(REPLICASET); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/cursor/cursor-tailable-003.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Cursor tailable iteration with awaitData and maxAwaitTimeMS options
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
5+
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";
@@ -34,12 +34,12 @@ $startTime = microtime(true);
3434
echo "Awaiting results...\n";
3535
$it->next();
3636
printf("Waited for %.6f seconds\n", microtime(true) - $startTime);
37-
37+
// Sometimes the cursor will wait for 0.09999 seconds and sometimes it will wait for 0.1000.
3838
?>
3939
===DONE===
4040
<?php exit(0); ?>
4141
--EXPECTF--
4242
{_id: 1}
4343
Awaiting results...
44-
Waited for 0.01%d seconds
44+
Waited for 0.0%d seconds
4545
===DONE===

tests/cursor/cursor-tailable_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Cursor cursor killed during tailable iteration
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
5+
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/cursorid/cursorid-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MongoDB\Driver\CursorID BSON serialization for killCursors command
33
--SKIPIF--
44
<?php if (8 !== PHP_INT_SIZE) { die('skip Only for 64-bit platform'); } ?>
55
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
6-
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
6+
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
77
--FILE--
88
<?php
99

tests/manager/manager-executeBulkWrite-011.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\BulkWrite: bypassDocumentValidation option
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
5+
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/manager/manager-executeBulkWrite_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var_dump(iterator_to_array($cursor));
3333
===DONE===
3434
<?php exit(0); ?>
3535
--EXPECTF--
36-
BulkWriteException: E11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_001%sdup key: { : 1 }
36+
BulkWriteException:%S E11000 duplicate key error %s: phongo.manager_manager_executeBulkWrite_error_001%sdup key: { : 1 }
3737

3838
===> WriteResult
3939
server: %s:%d

tests/manager/manager-executeBulkWrite_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var_dump(iterator_to_array($cursor));
3333
===DONE===
3434
<?php exit(0); ?>
3535
--EXPECTF--
36-
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 }"
36+
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 }"
3737

3838
===> WriteResult
3939
server: %s:%d

tests/manager/manager-executeBulkWrite_error-008.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Manager::executeBulkWrite() with empty BulkWrite
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); ?>
5+
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/manager/manager-executeReadWriteCommand-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Manager::executeReadWriteCommand()
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
5+
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/server/server-executeBulkWrite_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Server::executeBulkWrite() with empty BulkWrite
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); ?>
5+
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/server/server-executeReadWriteCommand-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Server::executeReadWriteCommand()
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
5+
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.2"); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/server/server-getTags-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MongoDB\Driver\Server::getTags() with standalone
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5-
<?php NEEDS('STANDALONE'); ?>
5+
<?php NEEDS('STANDALONE'); CLEANUP(STANDALONE); ?>
66
--FILE--
77
<?php
88
require_once __DIR__ . "/../utils/basic.inc";

tests/standalone/manager-as-singleton.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
PHPC-431: Segfault when using Manager through singleton class
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS('STANDALONE'); ?>
56
--FILE--
67
<?php
78
use MongoDB\Driver\Manager;

tests/writeResult/writeresult-getwriteerrors-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ array(1) {
3131
[0]=>
3232
object(MongoDB\Driver\WriteError)#%d (%d) {
3333
["message"]=>
34-
string(%d) "E11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_001%sdup key: { : 2 }"
34+
string(%d) "%SE11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_001%sdup key: { : 2 }"
3535
["code"]=>
3636
int(11000)
3737
["index"]=>

tests/writeResult/writeresult-getwriteerrors-002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ array(2) {
3131
[0]=>
3232
object(MongoDB\Driver\WriteError)#%d (%d) {
3333
["message"]=>
34-
string(%d) "E11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 2 }"
34+
string(%d) "%SE11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 2 }"
3535
["code"]=>
3636
int(11000)
3737
["index"]=>
@@ -42,7 +42,7 @@ array(2) {
4242
[1]=>
4343
object(MongoDB\Driver\WriteError)#%d (%d) {
4444
["message"]=>
45-
string(%d) "E11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 4 }"
45+
string(%d) "%SE11000 duplicate key error %s: phongo.writeResult_writeresult_getwriteerrors_002%sdup key: { : 4 }"
4646
["code"]=>
4747
int(11000)
4848
["index"]=>

0 commit comments

Comments
 (0)