|
1 | 1 | # Contributing to the PHP Driver for MongoDB |
2 | 2 |
|
3 | | - |
4 | 3 | ## Building from VCS (GitHub) |
5 | 4 |
|
6 | | -Developers who would like to contribute to the driver will need to build it from VCS |
7 | | -like so: |
| 5 | +Developers who would like to contribute to the driver will need to build it from |
| 6 | +VCS. The repository may be initialized with: |
8 | 7 |
|
9 | 8 | ``` |
10 | | -$ git clone https://github.com/mongodb/mongo-php-driver.git phongo |
11 | | -$ cd phongo |
| 9 | +$ git clone https://github.com/mongodb/mongo-php-driver.git |
| 10 | +$ cd mongo-php-driver |
12 | 11 | $ git submodule update --init |
13 | | -$ phpize |
14 | | -$ ./configure --enable-developer-flags |
15 | | -$ make -j8 all |
| 12 | +``` |
| 13 | + |
| 14 | +The following script may be used to build the driver: |
| 15 | + |
| 16 | +``` |
| 17 | +#!/bin/sh |
| 18 | +
|
| 19 | +phpize > /dev/null && \ |
| 20 | +./configure --enable-developer-flags > /dev/null && \ |
| 21 | +make clean > /dev/null && make all > /dev/null && make install |
16 | 22 | ``` |
17 | 23 |
|
18 | 24 | ## Testing |
19 | 25 |
|
20 | | -The test suites expects to find `PHONGO-SERVERS.json` in the system temp directory (typically `/tmp`). |
21 | | -This file should contain JSON object with MONGODB URIs, similar to the following template |
| 26 | +The test suites expects to find `PHONGO-SERVERS.json` in the system temp |
| 27 | +directory (e.g. `/tmp`). This file should contain JSON object with MONGODB URIs, |
| 28 | +similar to the following template: |
22 | 29 |
|
23 | 30 | ``` |
24 | 31 | { |
25 | 32 | "STANDALONE": "mongodb:\/\/192.168.112.10:2000", |
| 33 | + "STANDALONE_24": "mongodb:\/\/192.168.112.10:2500", |
| 34 | + "STANDALONE_26": "mongodb:\/\/192.168.112.10:2600", |
| 35 | + "STANDALONE_30": "mongodb:\/\/192.168.112.10:2700", |
26 | 36 | "STANDALONE_SSL": "mongodb:\/\/192.168.112.10:2100", |
27 | 37 | "STANDALONE_AUTH": "mongodb:\/\/root:toor@192.168.112.10:2200\/?authSource=admin", |
28 | 38 | "STANDALONE_X509": "mongodb:\/\/C=US,ST=New York,L=New York City,O=MongoDB,OU=KernelUser,CN=client@192.168.112.10:2300\/?authSource=$external&authMechanism=MONGODB-X509", |
29 | 39 | "STANDALONE_PLAIN": "mongodb:\/\/root:toor@192.168.112.10:2400\/?authSource=admin", |
30 | | - "REPLICASET": "mongodb:\/\/192.168.112.10:3000,192.168.112.10:3001,192.168.112.10:3002\/?replicaSet=REPLICASET" |
| 40 | + "REPLICASET": "mongodb:\/\/192.168.112.10:3000,192.168.112.10:3001,192.168.112.10:3002\/?replicaSet=REPLICASET", |
| 41 | + "REPLICASET_30": "mongodb:\/\/192.168.112.10:3100,192.168.112.10:3101,192.168.112.10:3102\/?replicaSet=REPLICASET_30" |
31 | 42 | } |
32 | 43 | ``` |
33 | | -The location of this PHONGO-SERVERS.json file can be configured by exporting |
34 | | -`PHONGO_SERVERS` environment variable with a absolute path to the json configuration file. |
35 | 44 |
|
36 | | -Alternatively, we provide, and use, [Vagrant](https://www.vagrantup.com/) to spin up handful of VMs |
37 | | -where we setup and configure MongoDB according to our needs. |
38 | | -This is the preferred way of creating PHONGO-SERVERS.json and running the test suite. |
| 45 | +The location of this `PHONGO-SERVERS.json` file can be configured by exporting a |
| 46 | +`PHONGO_SERVERS` environment variable with the absolute path to the JSON |
| 47 | +configuration file. |
39 | 48 |
|
| 49 | +Our test suite also includes scripts to configure the necessary test environment |
| 50 | +with [Vagrant](https://www.vagrantup.com/) and |
| 51 | +[Mongo Orchestration](https://github.com/10gen/mongo-orchestration). This is the |
| 52 | +preferred way of creating `PHONGO-SERVERS.json` and running the test suite: |
40 | 53 |
|
41 | 54 | ``` |
42 | | -$ make vm # requires vagrant (www.vagrantup.com) |
43 | | -$ make test-bootstrap # Spins up mongod's in the virtual machines |
| 55 | +$ make vm # Starts the test VMs with Vagrant |
| 56 | +$ make test-bootstrap # Starts the mongod servers within the test VM |
44 | 57 | ``` |
45 | 58 |
|
46 | | -The `test-bootstrap` make target will then generate the required `PHONGO-SERVERS.json`. |
47 | | - |
| 59 | +The `test-bootstrap` make target also generates the required |
| 60 | +`PHONGO-SERVERS.json` file. |
48 | 61 |
|
49 | | -To execute the test suite: |
| 62 | +The `test` make target may be used to execute the test suite: |
50 | 63 |
|
51 | 64 | ``` |
52 | | -$ make test # Executes the test suite against the virtual machines |
| 65 | +$ make test # Executes the test suite against the VMs |
53 | 66 | ``` |
54 | 67 |
|
55 | | -The bundled [Vagrantfile](Vagrantfile) also contains few other (growing) list of VMs |
56 | | -that can be provisioned to execute the test suite on various platforms. |
| 68 | +### Mongo Orchestration |
57 | 69 |
|
58 | | -These are automatically executed by the `make distcheck`, which will package a new PECL archive, |
59 | | -spin up the various operating systems, install the newly packaged archive, and execute |
60 | | -the test suite. |
| 70 | +Some tests interact directly with Mongo Orchestration to start their own servers |
| 71 | +for cluster testing (e.g. replica set failovers). These tests depend on |
| 72 | +`MONGODB_ORCHESTRATION_HOST` and `MONGODB_ORCHESTRATION_PORT` environment |
| 73 | +variables. |
| 74 | + |
| 75 | +By default, these tests will use the Mongo Orchestration instance within the |
| 76 | +test VM. |
| 77 | + |
| 78 | +### Restarting Mongo Orchestration |
| 79 | + |
| 80 | +If something goes awry in the test VM, it may be helpful to start the VM and |
| 81 | +Mongo Orchestration with the following script: |
| 82 | + |
| 83 | +``` |
| 84 | +#!/bin/sh |
| 85 | +
|
| 86 | +rm -f /tmp/PHONGO-SERVERS.json |
| 87 | +vagrant reload mo |
| 88 | +vagrant ssh mo -c 'sudo rm /home/vagrant/server.pid' |
| 89 | +vagrant ssh mo -c 'sudo mongo-orchestration -f mongo-orchestration-config.json -b 192.168.112.10 --enable-majority-read-concern start' |
| 90 | +make test-bootstrap |
| 91 | +``` |
61 | 92 |
|
62 | 93 | ## Releasing |
63 | 94 |
|
|
0 commit comments