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/index-management/README.rst
+177-2
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,6 @@ For each of the configurations:
31
31
indicated indexes act on
32
32
33
33
Tests
34
-
-----
35
34
36
35
- Run the driver's method that returns a list of index names, and:
37
36
@@ -45,4 +44,180 @@ Tests
45
44
- verify the "unique" flags show up for the unique index
46
45
- verify there are no duplicates in the returned list
47
46
- if the result consists of statically defined index models that include an ``ns`` field, verify
48
-
that its value is accurate
47
+
that its value is accurate
48
+
49
+
Search Index Management Helpers
50
+
-------------------------------
51
+
52
+
These tests are intended to smoke test the search management helpers end-to-end against a live Atlas cluster.
53
+
54
+
The search index management commands are asynchronous and mongod/mongos returns before the changes to a clusters' search indexes have completed. When
55
+
these prose tests specify "waiting for the changes", drivers should repeatedly poll the cluster with ``listSearchIndexes``
56
+
until the changes are visible. Each test specifies the condition that is considered "ready". For example, when creating a
57
+
new search index, waiting until the inserted index has a status ``queryable: true`` indicates that the index was successfully
58
+
created.
59
+
60
+
The commands tested in these prose tests take a while to successfully complete. Drivers should raise the timeout for each test to avoid timeout errors if
61
+
the test timeout is too low. 5 minutes is a sufficiently large timeout that any timeout that occurs indicates a real failure, but this value is not required and can be tweaked per-driver.
62
+
63
+
There is a server-side limitation that prevents multiple search indexes from being created with the same name, definition and
64
+
collection name. This limitation does not take into account collection uuid. Because these commands are asynchronous, any cleanup
65
+
code that may run after a test (cleaning a database or dropping search indexes) may not have completed by the next iteration of the
66
+
test (or the next test run, if running locally). To address this issue, each test uses a randomly generated collection name. Drivers
67
+
may generate this collection name however they like, but a suggested implementation is a hex representation of an
68
+
ObjectId (``new ObjectId().toHexString()`` in Node).
69
+
70
+
Setup
71
+
~~~~~
72
+
73
+
These tests must run against an Atlas cluster with a 7.0+ server. `Scripts are available <https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/atlas>`_ in drivers-evergreen-tools which can setup and teardown
74
+
Atlas clusters. To ensure that the Atlas cluster is cleaned up after each CI run, drivers should configure evergreen to run these tests
75
+
as a part of a task group. Be sure that the cluster gets torn down!
76
+
77
+
When working locally on these tests, the same Atlas setup and teardown scripts can be used locally to provision a cluster for development.
78
+
79
+
Case 1: Driver can successfully create and list search indexes
#. Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``).
83
+
#. Create a new search index on ``coll0`` with the ``createSearchIndex`` helper. Use the following definition:
84
+
85
+
.. code:: typescript
86
+
87
+
{
88
+
name: 'test-search-index',
89
+
definition: {
90
+
mappings: { dynamic: false }
91
+
}
92
+
}
93
+
94
+
#. Assert that the command returns the name of the index: ``"test-search-index"``.
95
+
#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until the following condition is satisfied and store the value in a variable ``index``:
96
+
97
+
- An index with the ``name`` of ``test-search-index`` is present and the index has a field ``queryable`` with a value of ``true``.
98
+
99
+
#. Assert that ``index`` has a property ``latestDefinition`` whose value is ``{ 'mappings': { 'dynamic': false } }``
100
+
101
+
Case 2: Driver can successfully create multiple indexes in batch
#. Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``).
105
+
#. Create two new search indexes on ``coll0`` with the ``createSearchIndexes`` helper. Use the following
106
+
definitions when creating the indexes. These definitions are referred to as ``indexDefinitions``.
107
+
108
+
.. code:: typescript
109
+
110
+
{
111
+
name: 'test-search-index-1',
112
+
definition: {
113
+
mappings: { dynamic: false }
114
+
}
115
+
}
116
+
117
+
{
118
+
name: 'test-search-index-2',
119
+
definition: {
120
+
mappings: { dynamic: false }
121
+
}
122
+
}
123
+
124
+
#. Assert that the command returns an array containing the new indexes' names: ``["test-search-index-1", "test-search-index-2"]``.
125
+
#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until the following conditions are satisfied.
126
+
127
+
- An index with the ``name`` of ``test-search-index-1`` is present and index has a field ``queryable`` with the value of ``true``. Store result in ``index1``.
128
+
- An index with the ``name`` of ``test-search-index-2`` is present and index has a field ``queryable`` with the value of ``true``. Store result in ``index2``.
129
+
130
+
#. Assert that ``index1`` and ``index2`` have the property ``latestDefinition`` whose value is ``{ "mappings" : { "dynamic" : false } }``
131
+
132
+
Case 3: Driver can successfully drop search indexes
#. Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``).
136
+
#. Create a new search index on ``coll0`` with the following definition:
137
+
138
+
.. code:: typescript
139
+
140
+
{
141
+
name: 'test-search-index',
142
+
definition: {
143
+
mappings: { dynamic: false }
144
+
}
145
+
}
146
+
147
+
#. Assert that the command returns the name of the index: ``"test-search-index"``.
148
+
#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until the following condition is satisfied:
149
+
150
+
- An index with the ``name`` of ``test-search-index`` is present and index has a field ``queryable`` with the value of ``true``.
151
+
152
+
#. Run a ``dropSearchIndex`` on ``coll0``, using ``test-search-index`` for the name.
153
+
#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until ``listSearchIndexes`` returns an empty array.
154
+
155
+
This test fails if it times out waiting for the deletion to succeed.
156
+
157
+
Case 4: Driver can update a search index
158
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159
+
160
+
#. Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``).
161
+
#. Create a new search index on ``coll0`` with the following definition:
162
+
163
+
.. code:: typescript
164
+
165
+
{
166
+
name: 'test-search-index',
167
+
definition: {
168
+
mappings: { dynamic: false }
169
+
}
170
+
}
171
+
172
+
#. Assert that the command returns the name of the index: ``"test-search-index"``.
173
+
#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until the following condition is satisfied:
174
+
175
+
- An index with the ``name`` of ``test-search-index`` is present and index has a field ``queryable`` with the value of ``true``.
176
+
177
+
#. Run a ``updateSearchIndex`` on ``coll0``, using the following definition.
178
+
179
+
.. code:: typescript
180
+
181
+
{
182
+
name: 'test-search-index',
183
+
definition: {
184
+
mappings: { dynamic: true }
185
+
}
186
+
}
187
+
188
+
#. Assert that the command does not error and the server responds with a success.
189
+
#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until the following conditions are satisfied:
190
+
191
+
- An index with the ``name`` of ``test-search-index`` is present. This index is referred to as ``index``.
192
+
- The index has a field ``queryable`` with a value of ``true`` and has a field ``status`` with the value of ``READY``.
193
+
194
+
#. Assert that an index is present with the name ``test-search-index`` and the definition has a property ``latestDefinition`` whose value is ``{ 'mappings': { 'dynamic': true } }``.
195
+
196
+
Case 5: ``dropSearchIndex`` suppresses namespace not found errors
#. Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``).
206
+
#. Apply a write concern ``WriteConcern(w=1)`` and a read concern with ``ReadConcern(level="majority")`` to ``coll0``.
207
+
#. Create a new search index on ``coll0`` with the ``createSearchIndex`` helper. Use the following definition:
208
+
209
+
.. code:: typescript
210
+
211
+
{
212
+
name: 'test-search-index-case6',
213
+
definition: {
214
+
mappings: { dynamic: false }
215
+
}
216
+
}
217
+
218
+
#. Assert that the command returns the name of the index: ``"test-search-index-case6"``.
219
+
#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until the following condition is satisfied and store the value in a variable ``index``:
220
+
221
+
- An index with the ``name`` of ``test-search-index-case6`` is present and the index has a field ``queryable`` with a value of ``true``.
222
+
223
+
#. Assert that ``index`` has a property ``latestDefinition`` whose value is ``{ 'mappings': { 'dynamic': false } }``
0 commit comments