@@ -23,58 +23,84 @@ make clean > /dev/null && make all > /dev/null && make install
23
23
24
24
## Testing
25
25
26
- The test suite expects to find ` PHONGO-SERVERS.json ` in the system temp
27
- directory (e.g. ` /tmp ` ). This file should contain a JSON object with MongoDB
28
- URIs and resemble the following:
26
+ The test suite depends on [ Mongo Orchestration] ( https://github.com/10gen/mongo-orchestration ) .
27
+ Mongo Orchestration is an HTTP server that provides a REST API for maintaining
28
+ MongoDB configurations. These configurations are located in `` scripts/presets ``
29
+ and for Travis CI in `` scripts/presets/travis `` . The presets for Travis CI can
30
+ also be spun-up locally, and that is the preferred testing method. An older way
31
+ using a specific VM is also still available (see further down).
32
+
33
+ Mongo Orchestration expects that the `` mongod `` (and `` mongos `` ) binaries are
34
+ available in the `` PATH `` .
35
+
36
+ Once installed, Mongo Orchestration can be started with
37
+
38
+ ```
39
+ ~/.local/bin/mongo-orchestration start --no-fork --enable-majority-read-concern
40
+ ```
41
+
42
+ The Travis CI setup uses
43
+ [ deployments] ( https://github.com/mongodb/mongo-php-driver/blob/master/.travis.scripts/setup_mo.sh )
44
+ to test different topologies. Currently, it supports `` STANDALONE `` ,
45
+ `` STANDALONE_OLD `` (for MongoDB versions before 3.6), `` STANDALONE_SSL `` ,
46
+ `` REPLICASET `` and `` SHARDED_CLUSTER `` .
47
+
48
+ The test suite uses the `` MONGODB_URI `` environment variable as connection
49
+ string to run all tests. In order to make the URI available to the test suite,
50
+ you can run the following for a "deployment" in the * root* of the MongoDB
51
+ Driver GIT checkout:
29
52
30
53
```
31
- {
32
- "STANDALONE": "mongodb:\/\/192.168.112.10:2000",
33
- "STANDALONE_30": "mongodb:\/\/192.168.112.10:2700",
34
- "STANDALONE_SSL": "mongodb:\/\/192.168.112.10:2100",
35
- "STANDALONE_AUTH": "mongodb:\/\/root:[email protected] :2200\/?authSource=admin",
36
- "STANDALONE_X509": "mongodb:\/\/C=US,ST=New York,L=New York City,O=MongoDB,OU=KernelUser,[email protected] :2300\/?authSource=$external&authMechanism=MONGODB-X509",
37
- "STANDALONE_PLAIN": "mongodb:\/\/root:[email protected] :2400\/?authSource=admin",
38
- "REPLICASET": "mongodb:\/\/192.168.112.10:3000,192.168.112.10:3001,192.168.112.10:3002\/?replicaSet=REPLICASET",
39
- "REPLICASET_30": "mongodb:\/\/192.168.112.10:3100,192.168.112.10:3101,192.168.112.10:3102\/?replicaSet=REPLICASET_30",
40
- "REPLICASET_36": "mongodb:\/\/192.168.112.10:3200,192.168.112.10:3201,192.168.112.10:3202\/?replicaSet=REPLICASET_36"
41
- }
54
+ export TRAVIS_BUILD_DIR=`pwd`
55
+ DEPLOYMENT=STANDALONE_AUTH .travis.scripts/setup_mo.sh
56
+ export MONGODB_URI=`cat /tmp/uri.txt`
42
57
```
43
58
44
- The location of this ` PHONGO-SERVERS.json ` file can be configured by exporting a
45
- ` PHONGO_SERVERS ` environment variable with the absolute path to the JSON
46
- configuration file.
59
+ With this set-up, the tests can be run with ` make test ` .
47
60
48
- Our test suite also includes scripts to configure the necessary test environment
61
+ ### Legacy VM set-up
62
+
63
+ Alternative to the Travis CI set-up, our test suite also includes scripts to configure test environments
49
64
with [ Vagrant] ( https://www.vagrantup.com/ ) and
50
- [ Mongo Orchestration] ( https://github.com/10gen/mongo-orchestration ) . This is the
51
- preferred way of creating ` PHONGO-SERVERS.json ` and running the test suite:
65
+ [ Mongo Orchestration] ( https://github.com/10gen/mongo-orchestration ) .
66
+ The deployments started in this Vagrant image have hard coded URLs to be used
67
+ with the `` MONGODB_URI `` environment variable:
68
+
69
+ Deployment | URI
70
+ --------------------------- | ---
71
+ Standalone (MongoDB 4.0) | ` mongodb://192.168.112.10:2000 `
72
+ Standalone (MongoDB 3.0) | ` mongodb://192.168.112.10:2700 `
73
+ Standalone with SSL | ` mongodb://192.168.112.10:2100 `
74
+ Standalone with Auth |
` mongodb://root:[email protected] :2200/?authSource=admin `
75
+ Standalone with X509 Auth |
` mongodb://C=US,ST=New York,L=New York City,O=MongoDB,OU=KernelUser,[email protected] :2300/?authSource=$external&authMechanism=MONGODB-X509 `
76
+ Standalone with Plain Auth |
` mongodb://root:[email protected] :2400/?authSource=admin `
77
+ Replicaset (MongoDB 4.0) | ` mongodb://192.168.112.10:3000,192.168.112.10:3001,192.168.112.10:3002/?replicaSet=REPLICASET `
78
+ Replicaset (MongoDB 3.0) | ` mongodb://192.168.112.10:3100,192.168.112.10:3101,192.168.112.10:3102/?replicaSet=REPLICASET_30 `
79
+ Replicaset (MongoDB 3.6) | ` mongodb://192.168.112.10:3200,192.168.112.10:3201,192.168.112.10:3202/?replicaSet=REPLICASET_36 `
80
+
81
+ The Vagrant images can be started by using:
52
82
53
83
```
54
84
$ make vm # Starts the test VMs with Vagrant
55
85
$ make test-bootstrap # Starts the mongod servers within the test VM
56
86
```
57
87
58
- The ` test-bootstrap ` make target also generates the required
59
- ` PHONGO-SERVERS.json ` file. The ` test ` make target may be used to execute the
60
- test suite:
88
+ After this set-up is completed, you need to export the ` MONGODB_URI `
89
+ environment variables with one of the values from the table above. The ` test `
90
+ make target may be used to execute the test suite:
61
91
62
92
```
63
93
$ make test # Executes the test suite against the VMs
64
94
```
65
95
66
- ### Restarting Mongo Orchestration
96
+ To find out which VM servers are running at a later point in time, you can run
97
+ ` make test-bootstrap ` to obtain a list of deployments and their URIs.
67
98
68
- If something goes awry in the test VM, it may be helpful to start the VM and
69
- Mongo Orchestration with the following script:
99
+ #### Restarting Mongo Orchestration
70
100
71
- ```
72
- #!/bin/sh
101
+ If something goes awry in the test VM, you can reload it by running:
73
102
74
- rm -f /tmp/PHONGO-SERVERS.json
75
- vagrant reload mo
76
- vagrant ssh mo -c 'sudo rm /home/vagrant/server.pid'
77
- vagrant ssh mo -c 'sudo mongo-orchestration -f mongo-orchestration-config.json -b 192.168.112.10 --enable-majority-read-concern start'
103
+ ```
78
104
make test-bootstrap
79
105
```
80
106
0 commit comments