Skip to content

Commit ff41c31

Browse files
committed
Add Atlas connectivity tests
1 parent 3624e5a commit ff41c31

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

.travis.scripts/atlas-uris.txt.enc

1.36 KB
Binary file not shown.

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ env:
1616

1717
matrix:
1818
include:
19+
- php: 7.2
20+
env:
21+
- TESTS=tests/atlas.phpt
22+
- TEST_PHP_ARGS="-q -s output.txt -x --show-diff"
1923
- php: 5.5
2024
- php: 5.6
2125
- php: 7.0
@@ -57,6 +61,7 @@ matrix:
5761
- SERVER_VERSION=3.6.5
5862

5963
before_install:
64+
- openssl aes-256-cbc -K $encrypted_b354efda2943_key -iv $encrypted_b354efda2943_iv -in .travis.scripts/atlas-uris.txt.enc -out .travis.scripts/atlas-uris.txt -d || true
6065
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`
6166
- .travis.scripts/before_install.sh
6267
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-${SERVER_VERSION}.tgz

tests/atlas.phpt

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Atlas Connectivity Tests
3+
--SKIPIF--
4+
<?php
5+
if (!file_exists('.travis.scripts/atlas-uris.txt')) { echo "skip Atlas URIs not found\n"; }
6+
if (filesize('.travis.scripts/atlas-uris.txt') < 10) { echo "skip Atlas URI file empty\n"; }
7+
if ($_ENV['TESTS'] !== 'tests/atlas.phpt') { echo "skip Atlas tests not wanted\n"; }
8+
?>
9+
--FILE--
10+
<?php
11+
$urls = explode("\n", file_get_contents('.travis.scripts/atlas-uris.txt'));
12+
13+
$isMasterCmd = new \MongoDB\Driver\Command(['isMaster' => 1]);
14+
$query = new \MongoDB\Driver\Query([]);
15+
16+
foreach ($urls as $url) {
17+
$url = trim($url);
18+
if ($url == '') {
19+
continue;
20+
}
21+
22+
try {
23+
$m = new \MongoDB\Driver\Manager($url);
24+
$m->executeCommand('admin', $isMasterCmd);
25+
iterator_to_array($m->executeQuery('test.test', $query));
26+
echo "PASS\n";
27+
} catch(Exception $e) {
28+
echo "FAIL: ", $e->getMessage(), "\n";
29+
}
30+
}
31+
?>
32+
===DONE===
33+
<?php exit(0); ?>
34+
--EXPECTF--
35+
PASS
36+
PASS
37+
PASS
38+
PASS
39+
PASS
40+
FAIL: %s
41+
===DONE===

0 commit comments

Comments
 (0)