Skip to content

Commit 3678fa5

Browse files
committed
PHPC-1184: Add alternative topologies to Travis
1 parent 200b1a2 commit 3678fa5

25 files changed

+371
-252
lines changed

.travis.scripts/mo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function eval_params {
1919
}
2020

2121
function r {
22-
echo $1| cut -d'/' -f 2
22+
echo $1| awk -F'/' '{print $(NF-1)}'| sed 's/standalone/servers/'
2323
}
2424

2525
function a {

.travis.scripts/setup_mo.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
echo Loading MO for $DEPLOYMENT
4+
5+
case $DEPLOYMENT in
6+
SHARDED_CLUSTER)
7+
${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh ${TRAVIS_BUILD_DIR}/scripts/presets/travis/sharded_clusters/cluster.json start > /tmp/mo-result.json
8+
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri;' > /tmp/uri.txt
9+
;;
10+
STANDALONE_AUTH)
11+
${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh ${TRAVIS_BUILD_DIR}/scripts/presets/travis/standalone/standalone-auth.json start > /tmp/mo-result.json
12+
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_auth_uri;' > /tmp/uri.txt
13+
;;
14+
STANDALONE_OLD)
15+
${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh ${TRAVIS_BUILD_DIR}/scripts/presets/travis/standalone/standalone-old.json start > /tmp/mo-result.json
16+
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri;' > /tmp/uri.txt
17+
;;
18+
STANDALONE_SSL)
19+
${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh ${TRAVIS_BUILD_DIR}/scripts/presets/travis/standalone/standalone-ssl.json start > /tmp/mo-result.json
20+
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri, "/?ssl=true&sslallowinvalidcertificates=true";' > /tmp/uri.txt
21+
;;
22+
REPLICASET)
23+
${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh ${TRAVIS_BUILD_DIR}/scripts/presets/travis/replica_sets/replicaset.json start > /tmp/mo-result.json
24+
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri;' > /tmp/uri.txt
25+
;;
26+
*)
27+
${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh ${TRAVIS_BUILD_DIR}/scripts/presets/travis/standalone/standalone.json start > /tmp/mo-result.json
28+
cat /tmp/mo-result.json | tail -n 1 | php -r 'echo json_decode(file_get_contents("php://stdin"))->mongodb_uri;' > /tmp/uri.txt
29+
;;
30+
esac
31+
32+
echo -n "MongoDB Test URI: "
33+
cat /tmp/uri.txt
34+
echo
35+
36+
echo "Raw MO Response:"
37+
cat /tmp/mo-result.json
38+
39+
echo

.travis.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
- TEST_PHP_ARGS="-q -s output.txt -g XFAIL,FAIL,BORK,WARN,LEAK,SKIP -x --show-diff"
1313
- REPORT_EXIT_STATUS=1
1414
- SERVER_VERSION=4.0.0
15+
- DEPLOYMENT=STANDALONE
1516

1617
matrix:
1718
include:
@@ -20,25 +21,40 @@ matrix:
2021
- php: 7.0
2122
- php: 7.1
2223
- php: 7.2
24+
- php: 7.2
25+
env:
26+
- DEPLOYMENT=STANDALONE_SSL
27+
- php: 7.2
28+
env:
29+
- DEPLOYMENT=SHARDED_CLUSTER
30+
- php: 7.2
31+
env:
32+
- DEPLOYMENT=STANDALONE_AUTH
33+
- php: 7.2
34+
env:
35+
- DEPLOYMENT=REPLICASET
2336
- php: 7.0
2437
env:
2538
- SERVER_VERSION=3.0.15
39+
- DEPLOYMENT=STANDALONE_OLD
2640
- php: 7.0
2741
env:
2842
- SERVER_VERSION=3.2.20
43+
- DEPLOYMENT=STANDALONE_OLD
2944
- php: 7.0
3045
env:
3146
- SERVER_VERSION=3.4.15
47+
- DEPLOYMENT=STANDALONE_OLD
3248
- php: 7.0
3349
env:
3450
- SERVER_VERSION=3.6.5
3551

3652
before_install:
3753
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
3854
- .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}
55+
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-${SERVER_VERSION}.tgz
56+
- tar zxf mongodb-linux-x86_64-ubuntu1404-${SERVER_VERSION}.tgz
57+
- export PATH=${PWD}/mongodb-linux-x86_64-ubuntu1404-${SERVER_VERSION}/bin:${PATH}
4258
- mongod --version
4359
- mongo-orchestration --version
4460
- export MO_PATH=`python -c 'import mongo_orchestration; from os import path;
@@ -47,12 +63,14 @@ before_install:
4763

4864
before_script:
4965
- mongo-orchestration start
50-
- pushd ${MO_PATH} && ${TRAVIS_BUILD_DIR}/.travis.scripts/mo.sh configurations/servers/clean.json start && popd
66+
- .travis.scripts/setup_mo.sh
5167
- ulimit -a
5268
- ulimit -c unlimited || true
5369
- .travis.scripts/before_script.sh
5470

5571
script:
72+
- export MONGODB_URI=`cat /tmp/uri.txt`
73+
- echo $MONGODB_URI
5674
- make test
5775

5876
after_success:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"id": "REPLICASET",
3+
"name": "mongod",
4+
"members": [
5+
{
6+
"procParams": {
7+
"dbpath": "/tmp/REPLICASET/3000/",
8+
"ipv6": true,
9+
"logappend": true,
10+
"logpath": "/tmp/REPLICASET/3000/mongod.log",
11+
"journal": true,
12+
"nssize": 1,
13+
"port": 3000,
14+
"bind_ip_all": true,
15+
"smallfiles": true
16+
},
17+
"rsParams": {
18+
"priority": 99,
19+
"tags": {
20+
"ordinal": "one",
21+
"dc": "pa"
22+
}
23+
},
24+
"server_id": "RS-one"
25+
},
26+
{
27+
"procParams": {
28+
"dbpath": "/tmp/REPLICASET/3001/",
29+
"ipv6": true,
30+
"logappend": true,
31+
"logpath": "/tmp/REPLICASET/3001/mongod.log",
32+
"journal": true,
33+
"nssize": 1,
34+
"port": 3001,
35+
"bind_ip_all": true,
36+
"smallfiles": true
37+
},
38+
"rsParams": {
39+
"priority": 1.1,
40+
"tags": {
41+
"ordinal": "two",
42+
"dc": "nyc"
43+
}
44+
},
45+
"server_id": "RS-two"
46+
},
47+
{
48+
"procParams": {
49+
"dbpath": "/tmp/REPLICASET/3002/",
50+
"ipv6": true,
51+
"logappend": true,
52+
"logpath": "/tmp/REPLICASET/3002/mongod.log",
53+
"journal": true,
54+
"nssize": 1,
55+
"port": 3002,
56+
"bind_ip_all": true,
57+
"smallfiles": true
58+
},
59+
"rsParams": {
60+
"arbiterOnly": true
61+
62+
},
63+
"server_id": "RS-arbiter"
64+
}
65+
]
66+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"configsvrs": [ {
3+
"members" : [
4+
{
5+
"procParams": {
6+
"dbpath": "/tmp/SHARDED/CFG/4000",
7+
"logpath": "/tmp/SHARDED/CFG/4000/mongod.log",
8+
"ipv6": true,
9+
"journal": true,
10+
"logappend": true,
11+
"nssize": 1,
12+
"port": 4000,
13+
"bind_ip_all": true,
14+
"smallfiles": true
15+
}
16+
},
17+
{
18+
"procParams": {
19+
"dbpath": "/tmp/SHARDED/CFG/4001",
20+
"logpath": "/tmp/SHARDED/CFG/4001/mongod.log",
21+
"ipv6": true,
22+
"journal": true,
23+
"logappend": true,
24+
"nssize": 1,
25+
"port": 4001,
26+
"bind_ip_all": true,
27+
"smallfiles": true
28+
}
29+
},
30+
{
31+
"procParams": {
32+
"dbpath": "/tmp/SHARDED/CFG/4002",
33+
"logpath": "/tmp/SHARDED/CFG/4002/mongod.log",
34+
"ipv6": true,
35+
"journal": true,
36+
"logappend": true,
37+
"nssize": 1,
38+
"port": 4002,
39+
"bind_ip_all": true,
40+
"smallfiles": true
41+
}
42+
}
43+
]
44+
} ],
45+
"id": "cluster_1",
46+
"shards": [
47+
{
48+
"id": "sh01",
49+
"shardParams": {
50+
"procParams": {
51+
"dbpath": "/tmp/SHARDED/SHARD1/4100",
52+
"logpath": "/tmp/SHARDED/SHARD1/4100/mongod.log",
53+
"ipv6": true,
54+
"journal": true,
55+
"logappend": true,
56+
"nssize": 1,
57+
"port": 4100,
58+
"bind_ip_all": true,
59+
"smallfiles": true
60+
}
61+
}
62+
},
63+
{
64+
"id": "sh02",
65+
"shardParams": {
66+
"procParams": {
67+
"dbpath": "/tmp/SHARDED/SHARD2/4200",
68+
"logpath": "/tmp/SHARDED/SHARD2/4200/mongod.log",
69+
"ipv6": true,
70+
"journal": true,
71+
"logappend": true,
72+
"nssize": 1,
73+
"port": 4200,
74+
"bind_ip_all": true,
75+
"smallfiles": true
76+
}
77+
}
78+
}
79+
],
80+
"routers": [
81+
{
82+
"logpath": "/tmp/SHARDED/ROUTER/4300/mongod.log",
83+
"ipv6": true,
84+
"logappend": true,
85+
"port": 4300,
86+
"bind_ip_all": true
87+
}
88+
]
89+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "mongod",
3+
"id" : "STANDALONE_AUTH",
4+
"auth_key": "secret",
5+
"login": "root",
6+
"password": "toor",
7+
"procParams": {
8+
"dbpath": "/tmp/standalone-auth/",
9+
"ipv6": true,
10+
"logappend": true,
11+
"logpath": "/tmp/standalone-auth/m.log",
12+
"journal": true,
13+
"nssize": 1,
14+
"port": 2200,
15+
"bind_ip_all": true,
16+
"smallfiles": true,
17+
"setParameter": {"enableTestCommands": 1}
18+
}
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "mongod",
3+
"id" : "STANDALONE",
4+
"procParams": {
5+
"dbpath": "/tmp/standalone/",
6+
"ipv6": true,
7+
"logappend": true,
8+
"logpath": "/tmp/standalone/mongod.log",
9+
"journal": true,
10+
"nssize": 1,
11+
"port": 2700,
12+
"bind_ip": "::,0.0.0.0",
13+
"smallfiles": true,
14+
"setParameter": {"enableTestCommands": 1}
15+
}
16+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "mongod",
3+
"id" : "STANDALONE_SSL",
4+
"procParams": {
5+
"dbpath": "/tmp/standalone-ssl/",
6+
"ipv6": true,
7+
"logappend": true,
8+
"logpath": "/tmp/standalone-ssl/m.log",
9+
"journal": true,
10+
"nssize": 1,
11+
"port": 2100,
12+
"bind_ip_all": true,
13+
"smallfiles": true,
14+
"setParameter": {"enableTestCommands": 1}
15+
},
16+
"sslParams": {
17+
"sslMode": "requireSSL",
18+
"sslCAFile": "$TRAVIS_BUILD_DIR/scripts/ssl/ca.pem",
19+
"sslPEMKeyFile": "$TRAVIS_BUILD_DIR/scripts/ssl/server.pem",
20+
"sslWeakCertificateValidation": true,
21+
"sslAllowInvalidHostnames": true
22+
}
23+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "mongod",
3+
"id" : "STANDALONE",
4+
"procParams": {
5+
"dbpath": "/tmp/standalone/",
6+
"ipv6": true,
7+
"logappend": true,
8+
"logpath": "/tmp/standalone/mongod.log",
9+
"journal": true,
10+
"nssize": 1,
11+
"port": 2000,
12+
"bind_ip_all": true,
13+
"smallfiles": true,
14+
"setParameter": {"enableTestCommands": 1}
15+
}
16+
}

tests/apm/monitoring-commandFailed-001.phpt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@ $subscriber = new MySubscriber;
4141

4242
MongoDB\Driver\Monitoring\addSubscriber( $subscriber );
4343

44-
drop_collection(URI, DATABASE_NAME, COLLECTION_NAME);
44+
$primary = get_primary_server(URI);
45+
$command = new \MongoDB\Driver\Command([
46+
'aggregate' => COLLECTION_NAME,
47+
'pipeline' => [['$unsupported' => 1]]
48+
]);
49+
try {
50+
$primary->executeCommand(DATABASE_NAME, $command);
51+
} catch (Exception $e) {
52+
/* Swallow */
53+
}
4554
?>
4655
--EXPECT--
47-
started: drop
48-
failed: drop
56+
started: aggregate
57+
failed: aggregate
4958
- getError() returns an object: yes
5059
- getError() returns an MongoDB\Driver\Exception\Exception object: yes
5160
- getDurationMicros() returns an integer: yes
5261
- getDurationMicros() returns > 0: yes
5362
- getCommandName() returns a string: yes
54-
- getCommandName() returns 'drop'
63+
- getCommandName() returns 'aggregate'
5564
- getServer() returns an object: yes
5665
- getServer() returns a Server object: yes
5766
- getOperationId() returns a string: yes

0 commit comments

Comments
 (0)