-
Notifications
You must be signed in to change notification settings - Fork 208
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
Changes from all commits
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,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 |
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 | ||
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` | ||
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. 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? 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. I expect this is due to older version of Python on the Travis images. Perhaps @ShaneHarvey can chime in here. 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. 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 | ||
|
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.