Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d39706

Browse files
RUBY-3395 Vector Search GA (#2897)
1 parent abb7765 commit 5d39706

File tree

10 files changed

+240
-31
lines changed

10 files changed

+240
-31
lines changed

‎.evergreen/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pre_error_fails_task: true
1414
command_type: system
1515

1616
# Protect ourself against rogue test case, or curl gone wild, that runs forever.
17-
exec_timeout_secs: 3600
17+
exec_timeout_secs: 5400
1818

1919
# What to do when evergreen hits the timeout (`post:` tasks are run automatically)
2020
timeout:
@@ -346,7 +346,7 @@ functions:
346346
"upload test results":
347347
- command: attach.xunit_results
348348
params:
349-
file: ./src/tmp/rspec.xml
349+
file: ./src/rspec.xml
350350

351351
"delete private environment":
352352
- command: shell.exec
@@ -482,7 +482,7 @@ post:
482482
# Removed, causing timeouts
483483
# - func: "upload working dir"
484484
- func: "upload mo artifacts"
485-
#- func: "upload test results"
485+
#- func: "upload test results"
486486
- func: "upload test results to s3"
487487

488488
task_groups:

‎.evergreen/config/common.yml.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pre_error_fails_task: true
1111
command_type: system
1212

1313
# Protect ourself against rogue test case, or curl gone wild, that runs forever.
14-
exec_timeout_secs: 3600
14+
exec_timeout_secs: 5400
1515

1616
# What to do when evergreen hits the timeout (`post:` tasks are run automatically)
1717
timeout:
@@ -343,7 +343,7 @@ functions:
343343
"upload test results":
344344
- command: attach.xunit_results
345345
params:
346-
file: ./src/tmp/rspec.xml
346+
file: ./src/rspec.xml
347347

348348
"delete private environment":
349349
- command: shell.exec
@@ -479,7 +479,7 @@ post:
479479
# Removed, causing timeouts
480480
# - func: "upload working dir"
481481
- func: "upload mo artifacts"
482-
#- func: "upload test results"
482+
#- func: "upload test results"
483483
- func: "upload test results to s3"
484484

485485
task_groups:

‎.evergreen/run-tests.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ elif test "$SOLO" = 1; then
353353
fi
354354
done
355355
else
356+
export JRUBY_OPTS=-J-Xmx2g
356357
bundle exec rake spec:ci
357358
fi
358359

@@ -364,18 +365,18 @@ if test -f tmp/rspec-all.json; then
364365
mv tmp/rspec-all.json tmp/rspec.json
365366
fi
366367

367-
kill_jruby
368+
kill_jruby||true
368369

369370
if test -n "$OCSP_MOCK_PID"; then
370371
kill "$OCSP_MOCK_PID"
371372
fi
372373

373-
python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"
374+
python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"||true
374375

375376
if test -n "$FLE" && test "$DOCKER_PRELOAD" != 1; then
376377
# Terminate all kmip servers... and whatever else happens to be running
377378
# that is a python script.
378-
pkill python3
379+
pkill python3||true
379380
fi
380381

381382
exit ${test_status}

‎.mod/drivers-evergreen-tools

‎lib/mongo/search_index/view.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def initialize(collection, options = {})
4848
# @param [ nil | String ] name The name to give the new search index.
4949
#
5050
# @return [ String ] the name of the new search index.
51-
def create_one(definition, name: nil)
52-
create_many([ { name: name, definition: definition } ]).first
51+
def create_one(definition, name: nil,type: 'search')
52+
create_many([ { name: name, definition: definition,type: type } ]).first
5353
end
5454

5555
# Create multiple search indexes with a single command.
@@ -99,7 +99,7 @@ def each(&block)
9999
s[:name] = requested_index_name if requested_index_name
100100
end
101101

102-
collection.aggregate(
102+
collection.with(read_concern: {}).aggregate(
103103
[ { '$listSearchIndexes' => spec } ],
104104
aggregate_options
105105
)
@@ -200,7 +200,7 @@ def validate_search_index!(doc)
200200
#
201201
# @raise [ ArgumentError ] if the list contains any invalid keys
202202
def validate_search_index_keys!(keys)
203-
extras = keys - [ 'name', 'definition', :name, :definition ]
203+
extras = keys - [ 'name', 'definition', 'type',:name, :definition,:type ]
204204

205205
raise ArgumentError, "invalid keys in search index creation: #{extras.inspect}" if extras.any?
206206
end

‎spec/runners/unified/search_index_operations.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def create_search_index(op)
1111
model = args.use('model')
1212
name = model.use('name')
1313
definition = model.use('definition')
14-
collection.search_indexes.create_one(definition, name: name)
14+
type = model.use('type')
15+
collection.search_indexes.create_one(definition, name: name, type: type)
1516
end
1617
end
1718

‎spec/spec_tests/data/index_management/createSearchIndex.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ createEntities:
1616
collectionName: *collection0
1717

1818
runOnRequirements:
19-
- minServerVersion: "7.0.0"
19+
# Skip server versions without fix of SERVER-83107 to avoid error message "BSON field 'createSearchIndexes.indexes.type' is an unknown field."
20+
# SERVER-83107 was not backported to 7.1.
21+
- minServerVersion: "7.0.5"
22+
maxServerVersion: "7.0.99"
23+
topologies: [ replicaset, load-balanced, sharded ]
24+
serverless: forbid
25+
- minServerVersion: "7.2.0"
2026
topologies: [ replicaset, load-balanced, sharded ]
2127
serverless: forbid
2228

@@ -26,7 +32,7 @@ tests:
2632
- name: createSearchIndex
2733
object: *collection0
2834
arguments:
29-
model: { definition: &definition { mappings: { dynamic: true } } }
35+
model: { definition: &definition { mappings: { dynamic: true } } , type: 'search' }
3036
expectError:
3137
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
3238
# that the driver constructs and sends the correct command.
@@ -39,15 +45,37 @@ tests:
3945
- commandStartedEvent:
4046
command:
4147
createSearchIndexes: *collection0
42-
indexes: [ { definition: *definition} ]
48+
indexes: [ { definition: *definition, type: 'search'} ]
4349
$db: *database0
4450

4551
- description: "name provided for an index definition"
4652
operations:
4753
- name: createSearchIndex
4854
object: *collection0
4955
arguments:
50-
model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index' }
56+
model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index', type: 'search' }
57+
expectError:
58+
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
59+
# that the driver constructs and sends the correct command.
60+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
61+
isError: true
62+
errorContains: Atlas
63+
expectEvents:
64+
- client: *client0
65+
events:
66+
- commandStartedEvent:
67+
command:
68+
createSearchIndexes: *collection0
69+
indexes: [ { definition: *definition, name: 'test index', type: 'search' } ]
70+
$db: *database0
71+
72+
- description: "create a vector search index"
73+
operations:
74+
- name: createSearchIndex
75+
object: *collection0
76+
arguments:
77+
model: { definition: &definition { fields: [ {"type": "vector", "path": "plot_embedding", "numDimensions": 1536, "similarity": "euclidean"} ] }
78+
, name: 'test index', type: 'vectorSearch' }
5179
expectError:
5280
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
5381
# that the driver constructs and sends the correct command.
@@ -60,5 +88,5 @@ tests:
6088
- commandStartedEvent:
6189
command:
6290
createSearchIndexes: *collection0
63-
indexes: [ { definition: *definition, name: 'test index' } ]
91+
indexes: [ { definition: *definition, name: 'test index', type: 'vectorSearch' } ]
6492
$db: *database0

‎spec/spec_tests/data/index_management/createSearchIndexes.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ createEntities:
1616
collectionName: *collection0
1717

1818
runOnRequirements:
19-
- minServerVersion: "7.0.0"
19+
# Skip server versions without fix of SERVER-83107 to avoid error message "BSON field 'createSearchIndexes.indexes.type' is an unknown field."
20+
# SERVER-83107 was not backported to 7.1.
21+
- minServerVersion: "7.0.5"
22+
maxServerVersion: "7.0.99"
23+
topologies: [ replicaset, load-balanced, sharded ]
24+
serverless: forbid
25+
- minServerVersion: "7.2.0"
2026
topologies: [ replicaset, load-balanced, sharded ]
2127
serverless: forbid
2228

@@ -48,7 +54,7 @@ tests:
4854
- name: createSearchIndexes
4955
object: *collection0
5056
arguments:
51-
models: [ { definition: &definition { mappings: { dynamic: true } } } ]
57+
models: [ { definition: &definition { mappings: { dynamic: true } } , type: 'search' } ]
5258
expectError:
5359
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
5460
# that the driver constructs and sends the correct command.
@@ -61,15 +67,37 @@ tests:
6167
- commandStartedEvent:
6268
command:
6369
createSearchIndexes: *collection0
64-
indexes: [ { definition: *definition} ]
70+
indexes: [ { definition: *definition, type: 'search'} ]
6571
$db: *database0
6672

6773
- description: "name provided for an index definition"
6874
operations:
6975
- name: createSearchIndexes
7076
object: *collection0
7177
arguments:
72-
models: [ { definition: &definition { mappings: { dynamic: true } } , name: 'test index' } ]
78+
models: [ { definition: &definition { mappings: { dynamic: true } } , name: 'test index' , type: 'search' } ]
79+
expectError:
80+
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
81+
# that the driver constructs and sends the correct command.
82+
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
83+
isError: true
84+
errorContains: Atlas
85+
expectEvents:
86+
- client: *client0
87+
events:
88+
- commandStartedEvent:
89+
command:
90+
createSearchIndexes: *collection0
91+
indexes: [ { definition: *definition, name: 'test index', type: 'search' } ]
92+
$db: *database0
93+
94+
- description: "create a vector search index"
95+
operations:
96+
- name: createSearchIndexes
97+
object: *collection0
98+
arguments:
99+
models: [ { definition: &definition { fields: [ {"type": "vector", "path": "plot_embedding", "numDimensions": 1536, "similarity": "euclidean"} ] },
100+
name: 'test index' , type: 'vectorSearch' } ]
73101
expectError:
74102
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
75103
# that the driver constructs and sends the correct command.
@@ -82,5 +110,5 @@ tests:
82110
- commandStartedEvent:
83111
command:
84112
createSearchIndexes: *collection0
85-
indexes: [ { definition: *definition, name: 'test index' } ]
113+
indexes: [ { definition: *definition, name: 'test index', type: 'vectorSearch' } ]
86114
$db: *database0

‎spec/spec_tests/data/index_management/listSearchIndexes.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ createEntities:
1515
database: *database0
1616
collectionName: *collection0
1717

18+
initialData:
19+
- collectionName: *collection0
20+
databaseName: *database0
21+
documents:
22+
- x: 1
23+
1824
runOnRequirements:
1925
- minServerVersion: "7.0.0"
2026
topologies: [ replicaset, load-balanced, sharded ]
2127
serverless: forbid
2228

2329
tests:
2430
- description: "when no name is provided, it does not populate the filter"
25-
skipReason: https://jira.mongodb.org/browse/DRIVERS-2794
2631
operations:
2732
- name: listSearchIndexes
2833
object: *collection0
@@ -42,11 +47,10 @@ tests:
4247
- $listSearchIndexes: {}
4348

4449
- description: "when a name is provided, it is present in the filter"
45-
skipReason: https://jira.mongodb.org/browse/DRIVERS-2794
4650
operations:
4751
- name: listSearchIndexes
4852
object: *collection0
49-
arguments:
53+
arguments:
5054
name: &indexName "test index"
5155
expectError:
5256
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
@@ -65,13 +69,12 @@ tests:
6569
$db: *database0
6670

6771
- description: aggregation cursor options are supported
68-
skipReason: https://jira.mongodb.org/browse/DRIVERS-2794
6972
operations:
7073
- name: listSearchIndexes
7174
object: *collection0
72-
arguments:
75+
arguments:
7376
name: &indexName "test index"
74-
aggregationOptions:
77+
aggregationOptions:
7578
batchSize: 10
7679
expectError:
7780
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /