Skip to content

Commit 689d12b

Browse files
committed
PHPLIB-299: Ensure Travis uses expected server versions
Disable the "mongodb" service and remove installation through Travis' unmaintained apt package whitelist. Server versions are now manually downloaded and run with mongo-orchestration.
1 parent 7f165f5 commit 689d12b

File tree

2 files changed

+140
-30
lines changed

2 files changed

+140
-30
lines changed

.travis.yml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,50 @@
11
language: php
22
dist: trusty
3-
sudo: false
4-
5-
services:
6-
- mongodb
3+
sudo: false
74

85
addons:
96
apt:
10-
packages: &common_packages
7+
packages:
118
- gdb
129

1310
env:
1411
global:
1512
- DRIVER_VERSION=1.4.0RC1
16-
- SERVER_VERSION=3.4
13+
- SERVER_VERSION=3.6.2
1714

1815
matrix:
1916
fast_finish: true
2017
include:
2118
- php: 5.5
22-
addons: &common_addons
23-
apt:
24-
sources: [ mongodb-3.4-precise ]
25-
packages: [ mongodb-org, *common_packages ]
2619
- php: 5.6
27-
addons: *common_addons
2820
- php: 7.0
29-
addons: *common_addons
3021
- php: 7.1
31-
addons: *common_addons
3222
- php: 7.2
33-
addons: *common_addons
3423
- php: 7.0
3524
env:
36-
- SERVER_VERSION=2.6
37-
addons:
38-
apt:
39-
sources: [ mongodb-upstart ]
40-
packages: [ mongodb-org, *common_packages ]
25+
- SERVER_VERSION=2.6.12
26+
- php: 7.0
27+
env:
28+
- SERVER_VERSION=3.0.15
4129
- php: 7.0
4230
env:
43-
- SERVER_VERSION=3.0
44-
addons:
45-
apt:
46-
sources: [ mongodb-3.0-precise ]
47-
packages: [ mongodb-org, *common_packages ]
31+
- SERVER_VERSION=3.2.18
4832
- php: 7.0
4933
env:
50-
- SERVER_VERSION=3.2
51-
addons:
52-
apt:
53-
sources: [ mongodb-3.2-precise ]
54-
packages: [ mongodb-org, *common_packages ]
34+
- SERVER_VERSION=3.4.11
5535

56-
before_script:
36+
before_install:
37+
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
38+
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${SERVER_VERSION}.tgz
39+
- tar zxf mongodb-linux-x86_64-${SERVER_VERSION}.tgz
40+
- export PATH=${PWD}/mongodb-linux-x86_64-${SERVER_VERSION}/bin/:${PATH}
5741
- mongod --version
42+
- mongo-orchestration --version
43+
- export MO_PATH=`python -c 'import mongo_orchestration; from os import path; print(path.dirname(mongo_orchestration.__file__));'`
44+
45+
before_script:
46+
- mongo-orchestration start
47+
- pushd ${MO_PATH} && ${TRAVIS_BUILD_DIR}/.travis/mo.sh configurations/servers/clean.json start && popd
5848
- pecl install -f mongodb-${DRIVER_VERSION}
5949
- php --ri mongodb
6050
- composer install --dev --no-interaction --prefer-source
@@ -66,3 +56,6 @@ script:
6656

6757
after_failure:
6858
- find . -name 'core*' -exec ${TRAVIS_BUILD_DIR}/.travis/debug-core.sh {} \;
59+
60+
after_script:
61+
- mongo-orchestration stop

.travis/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=~/tmp/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

0 commit comments

Comments
 (0)