Skip to content

Commit 3fc0085

Browse files
authored
RUST-1812 Fix index management spec tests (mongodb#1005)
1 parent e5e60e6 commit 3fc0085

15 files changed

+422
-242
lines changed

.evergreen/create-expansions.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ PREPARE_SHELL: |
5555
export PROJECT_DIRECTORY="${PROJECT_DIRECTORY}"
5656
export MONGOCRYPT_LIB_DIR="${MONGOCRYPT_LIB_DIR}"
5757
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
58-
export INDEX_MANAGEMENT_TEST_UNIFIED=1
5958
6059
export TMPDIR="${TMPDIR}"
6160
export PATH="${PATH}"

.evergreen/run-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ if [ "$COMPRESSION" = true ]; then
2222
fi
2323

2424
export SESSION_TEST_REQUIRE_MONGOCRYPTD=true
25+
export INDEX_MANAGEMENT_TEST_UNIFIED=1
2526

2627
echo "cargo test options: $(cargo_test_options)"
2728

src/test/spec/json/index-management/README.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,26 @@ Case 5: ``dropSearchIndex`` suppresses namespace not found errors
198198

199199
#. Create a driver-side collection object for a randomly generated collection name. Do not create this collection on the server.
200200
#. Run a ``dropSearchIndex`` command and assert that no error is thrown.
201+
202+
Case 6: Driver can successfully create and list search indexes with non-default readConcern and writeConcern
203+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204+
205+
#. 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 } }``

src/test/spec/json/index-management/createSearchIndex.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"expectError": {
5757
"isError": true,
58-
"errorContains": "Search index commands are only supported with Atlas"
58+
"errorContains": "Atlas"
5959
}
6060
}
6161
],
@@ -102,7 +102,7 @@
102102
},
103103
"expectError": {
104104
"isError": true,
105-
"errorContains": "Search index commands are only supported with Atlas"
105+
"errorContains": "Atlas"
106106
}
107107
}
108108
],

src/test/spec/json/index-management/createSearchIndex.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ tests:
3030
expectError:
3131
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
3232
# that the driver constructs and sends the correct command.
33+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
3334
isError: true
34-
errorContains: Search index commands are only supported with Atlas
35+
errorContains: Atlas
3536
expectEvents:
3637
- client: *client0
3738
events:
@@ -50,13 +51,14 @@ tests:
5051
expectError:
5152
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
5253
# that the driver constructs and sends the correct command.
54+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
5355
isError: true
54-
errorContains: Search index commands are only supported with Atlas
56+
errorContains: Atlas
5557
expectEvents:
5658
- client: *client0
5759
events:
5860
- commandStartedEvent:
5961
command:
6062
createSearchIndexes: *collection0
6163
indexes: [ { definition: *definition, name: 'test index' } ]
62-
$db: *database0
64+
$db: *database0

src/test/spec/json/index-management/createSearchIndexes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
},
5050
"expectError": {
5151
"isError": true,
52-
"errorContains": "Search index commands are only supported with Atlas"
52+
"errorContains": "Atlas"
5353
}
5454
}
5555
],
@@ -89,7 +89,7 @@
8989
},
9090
"expectError": {
9191
"isError": true,
92-
"errorContains": "Search index commands are only supported with Atlas"
92+
"errorContains": "Atlas"
9393
}
9494
}
9595
],
@@ -138,7 +138,7 @@
138138
},
139139
"expectError": {
140140
"isError": true,
141-
"errorContains": "Search index commands are only supported with Atlas"
141+
"errorContains": "Atlas"
142142
}
143143
}
144144
],

src/test/spec/json/index-management/createSearchIndexes.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ tests:
3030
expectError:
3131
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
3232
# that the driver constructs and sends the correct command.
33+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
3334
isError: true
34-
errorContains: Search index commands are only supported with Atlas
35+
errorContains: Atlas
3536
expectEvents:
3637
- client: *client0
3738
events:
@@ -51,8 +52,9 @@ tests:
5152
expectError:
5253
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
5354
# that the driver constructs and sends the correct command.
55+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
5456
isError: true
55-
errorContains: Search index commands are only supported with Atlas
57+
errorContains: Atlas
5658
expectEvents:
5759
- client: *client0
5860
events:
@@ -71,13 +73,14 @@ tests:
7173
expectError:
7274
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
7375
# that the driver constructs and sends the correct command.
76+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
7477
isError: true
75-
errorContains: Search index commands are only supported with Atlas
78+
errorContains: Atlas
7679
expectEvents:
7780
- client: *client0
7881
events:
7982
- commandStartedEvent:
8083
command:
8184
createSearchIndexes: *collection0
8285
indexes: [ { definition: *definition, name: 'test index' } ]
83-
$db: *database0
86+
$db: *database0

src/test/spec/json/index-management/dropSearchIndex.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
},
5050
"expectError": {
5151
"isError": true,
52-
"errorContains": "Search index commands are only supported with Atlas"
52+
"errorContains": "Atlas"
5353
}
5454
}
5555
],

src/test/spec/json/index-management/dropSearchIndex.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ tests:
3030
expectError:
3131
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
3232
# that the driver constructs and sends the correct command.
33+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
3334
isError: true
34-
errorContains: Search index commands are only supported with Atlas
35+
errorContains: Atlas
3536
expectEvents:
3637
- client: *client0
3738
events:

src/test/spec/json/index-management/listSearchIndexes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"object": "collection0",
4747
"expectError": {
4848
"isError": true,
49-
"errorContains": "Search index commands are only supported with Atlas"
49+
"errorContains": "Atlas"
5050
}
5151
}
5252
],
@@ -81,7 +81,7 @@
8181
},
8282
"expectError": {
8383
"isError": true,
84-
"errorContains": "Search index commands are only supported with Atlas"
84+
"errorContains": "Atlas"
8585
}
8686
}
8787
],
@@ -122,7 +122,7 @@
122122
},
123123
"expectError": {
124124
"isError": true,
125-
"errorContains": "Search index commands are only supported with Atlas"
125+
"errorContains": "Atlas"
126126
}
127127
}
128128
],

0 commit comments

Comments
 (0)