You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously the readme said that tests could be run with `make`.
This was not the case as a TOPOLOGY variable had to be set. This
patch adds a check to ensure that variables used in testing are
set to valid values. It also outlines usage of testing variables
in the readme.
Change-Id: I7f60fb78282f08ca528f64e40b87fed67b5780f7
Copy file name to clipboardExpand all lines: README.md
+57-2Lines changed: 57 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,8 +124,63 @@ New Features and bugs can be reported on jira: https://jira.mongodb.org/browse/G
124
124
-------------------------
125
125
## Testing / Development
126
126
127
-
To run driver tests, make sure a MongoDB server instance is running at localhost:27017. Using make, you can run `make` (on windows, run `nmake`).
128
-
This will run coverage, run go-lint, run go-vet, and build the examples.
127
+
The driver tests can be run against several database configurations. The most simple configuration is a standalone mongod with no auth, no ssl, and no compression. To run these basic driver tests, make sure a standalone MongoDB server instance is running at localhost:27017. To run the tests, you can run `make` (on Windows, run `nmake`) with the following:
128
+
129
+
```
130
+
TOPOLOGY=server make
131
+
```
132
+
133
+
The `TOPOLOGY`variable must be set to run tests. This will run coverage, run go-lint, run go-vet, and build the examples.
134
+
135
+
### Testing Different Topologies
136
+
137
+
To test a **replica set**, set `MONGODB_URI="<connection-string>"` and `TOPOLOGY=replica_set` for the `make` command. For example, for a local replica set named `rs1` comprised of three nodes on ports 27017, 27018, and 27019:
138
+
139
+
```
140
+
MONGODB_URI="mongodb://localhost:27017,localhost:27018,localhost:27018/?replicaSet=rs1" TOPOLOGY=replica_set make
141
+
```
142
+
143
+
To test a **sharded cluster**, set `MONGODB_URI="<connection-string>"` and `TOPOLOGY=sharded_cluster` variables for the `make` command. For example, for a sharded cluster with a single mongos on port 27017:
144
+
145
+
```
146
+
MONGODB_URI="mongodb://localhost:27017/" TOPOLOGY=sharder_cluster make
147
+
```
148
+
149
+
### Testing Auth and SSL
150
+
151
+
To test authentication and SSL, first set up a MongoDB cluster with auth and SSL configured. Testing authentication requires a user with the `root` role on the `admin` database. The Go Driver repository comes with example certificates in the `data/certificates` directory. These certs can be used for testing. Here is an example command that would run a mongod with SSL correctly configured for tests:
To run the tests with `make`, set `MONGO_GO_DRIVER_CA_FILE` to the location of the CA file used by the database, set `MONGODB_URI` to the connection string of the server, set `AUTH=auth`, and set `SSL=ssl`. For example:
163
+
164
+
```
165
+
AUTH=auth SSL=ssl MONGO_GO_DRIVER_CA_FILE=$(pwd)/data/certificates/ca.pem MONGODB_URI="mongodb://user:password@localhost:27017/?authSource=admin" make
166
+
```
167
+
168
+
Notes:
169
+
- The `--sslWeakCertificateValidation` flag is required on the server for the test suite to work correctly.
170
+
- The test suite requires the auth database to be set with `?authSource=admin`, not `/admin`.
171
+
172
+
### Testing Compression
173
+
174
+
The MongoDB Go Driver supports wire protocol compression using Snappy or zLib. To run tests with wire protocol compression, set `MONGO_GO_DRIVER_COMPRESSOR` to `snappy` or `zlib`. For example:
175
+
176
+
```
177
+
MONGO_GO_DRIVER_COMPRESSOR=snappy make
178
+
```
179
+
180
+
Ensure the [`--networkMessageCompressors` flag](https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-networkmessagecompressors) on mongod or mongos includes `zlib` if testing zLib compression.
181
+
182
+
-------------------------
183
+
## Feedback
129
184
130
185
The MongoDB Go Driver is not feature complete, so any help is appreciated. Check out the [project page](https://jira.mongodb.org/browse/GODRIVER)
131
186
for tickets that need completing. See our [contribution guidelines](CONTRIBUTING.md) for details.
0 commit comments