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
Copy file name to clipboardExpand all lines: test/spec/connection-monitoring-and-pooling/README.rst
+76-6Lines changed: 76 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,15 +24,32 @@ Common Test Format
24
24
Each YAML file has the following keys:
25
25
26
26
- ``version``: A version number indicating the expected format of the spec tests (current version = 1)
27
-
- ``style``: A string indicating what style of tests this file contains. Currently ``unit`` is the only valid value
27
+
- ``style``: A string indicating what style of tests this file contains. Contains one of the following:
28
+
29
+
- ``"unit"``: a test that may be run without connecting to a MongoDB deployment.
30
+
- ``"integration"``: a test that MUST be run against a real MongoDB deployment.
31
+
28
32
- ``description``: A text description of what the test is meant to assert
29
33
30
34
Unit Test Format:
31
35
=================
32
36
33
37
All Unit Tests have some of the following fields:
34
38
35
-
- ``poolOptions``: if present, connection pool options to use when creating a pool
39
+
- ``poolOptions``: If present, connection pool options to use when creating a pool;
40
+
both `standard ConnectionPoolOptions <https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#connection-pool-options-1>`__
41
+
and the following test-specific options are allowed:
42
+
43
+
- ``backgroundThreadIntervalMS``: A time interval between the end of a
44
+
`Background Thread Run <https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#background-thread>`__
45
+
and the beginning of the next Run. If a Connection Pool does not implement a Background Thread, the Test Runner MUST ignore the option.
46
+
If the option is not specified, an implementation is free to use any value it finds reasonable.
47
+
48
+
Possible values (0 is not allowed):
49
+
50
+
- A negative value: never begin a Run.
51
+
- A positive value: the interval between Runs in milliseconds.
52
+
36
53
- ``operations``: A list of operations to perform. All operations support the following fields:
37
54
38
55
- ``name``: A string describing which operation to issue.
@@ -68,10 +85,11 @@ Valid Unit Test Operations are the following:
68
85
69
86
- ``target``: The name of the thread to wait for.
70
87
71
-
- ``waitForEvent(event, count)``: block the current thread until ``event`` has occurred ``count`` times
88
+
- ``waitForEvent(event, count, timeout)``: block the current thread until ``event`` has occurred ``count`` times
72
89
73
90
- ``event``: The name of the event
74
91
- ``count``: The number of times the event must occur (counting from the start of the test)
92
+
- ``timeout``: If specified, time out with an error after waiting for this many milliseconds without seeing the required events
75
93
76
94
- ``label = pool.checkOut()``: call ``checkOut`` on pool, returning the checked out connection
77
95
@@ -83,6 +101,35 @@ Valid Unit Test Operations are the following:
83
101
84
102
- ``pool.clear()``: call ``clear`` on Pool
85
103
- ``pool.close()``: call ``close`` on Pool
104
+
- ``pool.ready()``: call ``ready`` on Pool
105
+
106
+
107
+
Integration Test Format
108
+
=======================
109
+
110
+
The integration test format is identical to the unit test format with
111
+
the addition of the following fields to each test:
112
+
113
+
- ``runOn`` (optional): An array of server version and/or topology requirements
114
+
for which the tests can be run. If the test environment satisfies one or more
115
+
of these requirements, the tests may be executed; otherwise, this test should
116
+
be skipped. If this field is omitted, the tests can be assumed to have no
117
+
particular requirements and should be executed. Each element will have some or
118
+
all of the following fields:
119
+
120
+
- ``minServerVersion`` (optional): The minimum server version (inclusive)
121
+
required to successfully run the tests. If this field is omitted, it should
122
+
be assumed that there is no lower bound on the required server version.
123
+
124
+
- ``maxServerVersion`` (optional): The maximum server version (inclusive)
125
+
against which the tests can be run successfully. If this field is omitted,
126
+
it should be assumed that there is no upper bound on the required server
127
+
version.
128
+
129
+
- ``failPoint``: optional, a document containing a ``configureFailPoint``
130
+
command to run against the endpoint being used for the test.
131
+
132
+
- ``poolOptions.appName`` (optional): appName attribute to be set in connections, which will be affected by the fail point.
86
133
87
134
Spec Test Match Function
88
135
========================
@@ -122,11 +169,10 @@ For each YAML file with ``style: unit``:
122
169
- If ``poolOptions`` is specified, use those options to initialize both pools
123
170
- The returned pool must have an ``address`` set as a string value.
124
171
125
-
- Execute each ``operation`` in ``operations``
172
+
- Process each ``operation`` in ``operations`` (on the main thread)
126
173
127
-
- If a ``thread`` is specified, execute in that corresponding thread. Otherwise, execute in the main thread.
174
+
- If a ``thread`` is specified, the main thread MUST schedule the operation to execute in the corresponding thread. Otherwise, execute the operation directly in the main thread.
128
175
129
-
- Wait for the main thread to finish executing all of its operations
130
176
- If ``error`` is presented
131
177
132
178
- Assert that an actual error ``actualError`` was thrown by the main thread
@@ -145,6 +191,30 @@ For each YAML file with ``style: unit``:
145
191
146
192
It is important to note that the ``ignore`` list is used for calculating ``actualEvents``, but is NOT used for the ``waitForEvent`` command
147
193
194
+
Integration Test Runner
195
+
=======================
196
+
197
+
The steps to run the integration tests are the same as those used to run the
198
+
unit tests with the following modifications:
199
+
200
+
- The integration tests MUST be run against an actual endpoint. If the
201
+
deployment being tested contains multiple endpoints, then the runner MUST
202
+
only use one of them to run the tests against.
203
+
204
+
- For each test, if `failPoint` is specified, its value is a
205
+
``configureFailPoint`` command. Run the command on the admin database of the
206
+
endpoint being tested to enable the fail point.
207
+
208
+
- At the end of each test, any enabled fail point MUST be disabled to avoid
209
+
spurious failures in subsequent tests. The fail point may be disabled like
0 commit comments