Skip to content

Commit 7777e63

Browse files
authored
PHPLIB-944: Document env vars supported by the test suite (#964)
1 parent a315cc0 commit 7777e63

File tree

1 file changed

+62
-9
lines changed

1 file changed

+62
-9
lines changed

CONTRIBUTING.md

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,80 @@ $ vendor/bin/simple-phpunit
3131
```
3232

3333
The `phpunit.xml.dist` file is used as the default configuration file for the
34-
test suite. In addition to various PHPUnit options, it defines required
35-
`MONGODB_URI` and `MONGODB_DATABASE` environment variables. You may customize
34+
test suite. In addition to various PHPUnit options, it defines environment
35+
variables such as `MONGODB_URI` and `MONGODB_DATABASE`. You may customize
3636
this configuration by creating your own `phpunit.xml` file based on the
3737
`phpunit.xml.dist` file we provide. To run the tests in serverless mode, set the
3838
`MONGODB_IS_SERVERLESS` environment variable to `on`.
3939

4040
To run tests against a cluster that requires authentication, either include the
41-
credentials in the connection string given in the `MONGODB_URI` environment
42-
variable, or set the `MONGODB_USERNAME` and `MONGODB_PASSWORD` environment
43-
variables accordingly. Note that values defined through the environment override
44-
credentials present in the URI.
41+
credentials in the connection string (i.e. `MONGODB_URI`) or set the
42+
`MONGODB_USERNAME` and `MONGODB_PASSWORD` environment variables accordingly.
43+
Note that `MONGODB_USERNAME` and `MONGODB_PASSWORD` will override any
44+
credentials present in the connection string.
4545

4646
By default, the `simple-phpunit` binary chooses the correct PHPUnit version for
47-
the PHP version you are running. To run tests against a specific PHPUnit version,
48-
use the `SYMFONY_PHPUNIT_VERSION` environment variable:
47+
the PHP version you are running. To run tests against a specific PHPUnit
48+
version, use the `SYMFONY_PHPUNIT_VERSION` environment variable:
4949

5050
```
5151
$ SYMFONY_PHPUNIT_VERSION=7.5 vendor/bin/simple-phpunit
5252
```
5353

54+
### Environment Variables
55+
56+
The test suite references the following environment variables:
57+
58+
* `MONGODB_DATABASE`: Default database to use in tests. Defaults to
59+
`phplib_test`.
60+
* `MONGODB_PASSWORD`: If specified, this value will be appended as the
61+
`password` URI option for clients constructed by the test suite, which will
62+
override any credentials in the connection string itself.
63+
* `MONGODB_URI`: Connection string. Defaults to `mongodb://127.0.0.1/`, which
64+
assumes a MongoDB server is listening on localhost port 27017.
65+
* `MONGODB_USERNAME`: If specified, this value will be appended as the
66+
`username` URI option for clients constructed by the test suite, which will
67+
override any credentials in the connection string itself.
68+
69+
The following environment variable is used for [stable API testing](https://github.com/mongodb/specifications/blob/master/source/versioned-api/tests/README.rst):
70+
71+
* `API_VERSION`: If defined, this value will be used to construct a
72+
[`MongoDB\Driver\ServerApi`](https://www.php.net/manual/en/mongodb-driver-serverapi.construct.php),
73+
which will then be specified as the `serverApi` driver option for clients
74+
created by the test suite.
75+
76+
The following environment variable is used for [serverless testing](https://github.com/mongodb/specifications/blob/master/source/serverless-testing/README.rst):
77+
78+
* `MONGODB_IS_SERVERLESS`: Specify a true boolean string
79+
(see: [`FILTER_VALIDATE_BOOLEAN`](https://www.php.net/manual/en/filter.filters.validate.php))
80+
if `MONGODB_URI` points to a serverless instance. Defaults to false.
81+
82+
The following environment variables are used for [load balancer testing](https://github.com/mongodb/specifications/blob/master/source/load-balancers/tests/README.rst):
83+
84+
* `MONGODB_SINGLE_MONGOS_LB_URI`: Connection string to a load balancer backed
85+
by a single mongos host.
86+
* `MONGODB_MULTI_MONGOS_LB_URI`: Connection string to a load balancer backed by
87+
multiple mongos hosts.
88+
89+
The following environment variables are used for [CSFLE testing](https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/tests/README.rst):
90+
91+
* `AWS_ACCESS_KEY_ID`
92+
* `AWS_SECRET_ACCESS_KEY`
93+
* `AZURE_TENANT_ID`
94+
* `AZURE_CLIENT_ID`
95+
* `AZURE_CLIENT_SECRET`
96+
* `CRYPT_SHARED_LIB_PATH`: If defined, this value will be used to set the
97+
`cryptSharedLibPath` autoEncryption driver option for clients created by the
98+
test suite.
99+
* `GCP_EMAIL`
100+
* `GCP_PRIVATE_KEY`
101+
* `KMIP_ENDPOINT`
102+
* `KMS_ENDPOINT_EXPIRED`
103+
* `KMS_ENDPOINT_WRONG_HOST`
104+
* `KMS_ENDPOINT_REQUIRE_CLIENT_CERT`
105+
* `KMS_TLS_CA_FILE`
106+
* `KMS_TLS_CERTIFICATE_KEY_FILE`
107+
54108
## Checking coding standards
55109

56110
The library's code is checked using [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer),
@@ -243,4 +297,3 @@ projects:
243297

244298
These tasks can be initiated prior to tagging a new release to ensure that the
245299
updated content becomes accessible soon after the release is published.
246-

0 commit comments

Comments
 (0)