Skip to content

Commit

Permalink
RUBY-3395 Vector Search GA (#2897)
Browse files Browse the repository at this point in the history
  • Loading branch information
comandeo-mongo authored Oct 15, 2024
1 parent abb7765 commit 5d39706
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pre_error_fails_task: true
command_type: system

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

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

"delete private environment":
- command: shell.exec
Expand Down Expand Up @@ -482,7 +482,7 @@ post:
# Removed, causing timeouts
# - func: "upload working dir"
- func: "upload mo artifacts"
#- func: "upload test results"
# - func: "upload test results"
- func: "upload test results to s3"

task_groups:
Expand Down
6 changes: 3 additions & 3 deletions .evergreen/config/common.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pre_error_fails_task: true
command_type: system

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

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

"delete private environment":
- command: shell.exec
Expand Down Expand Up @@ -479,7 +479,7 @@ post:
# Removed, causing timeouts
# - func: "upload working dir"
- func: "upload mo artifacts"
#- func: "upload test results"
# - func: "upload test results"
- func: "upload test results to s3"

task_groups:
Expand Down
7 changes: 4 additions & 3 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ elif test "$SOLO" = 1; then
fi
done
else
export JRUBY_OPTS=-J-Xmx2g
bundle exec rake spec:ci
fi

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

kill_jruby
kill_jruby || true

if test -n "$OCSP_MOCK_PID"; then
kill "$OCSP_MOCK_PID"
fi

python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"
python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir" || true

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

exit ${test_status}
2 changes: 1 addition & 1 deletion .mod/drivers-evergreen-tools
Submodule drivers-evergreen-tools updated 61 files
+2 −2 .evergreen/atlas/atlas-utils.sh
+4 −2 .evergreen/atlas/setup-atlas-cluster.sh
+3 −0 .evergreen/atlas/setup-variables.sh
+1 −1 .evergreen/atlas/teardown-atlas-cluster.sh
+1 −1 .evergreen/auth_aws/lib/ecs_hosted_test.sh
+1 −0 .evergreen/auth_oidc/azure/create-and-setup-vm.sh
+1 −0 .evergreen/auth_oidc/azure/run-driver-test.sh
+1 −1 .evergreen/auth_oidc/azure_func/invoke.sh
+1 −1 .evergreen/auth_oidc/azure_func/run-driver-test.sh
+4 −2 .evergreen/auth_oidc/azure_func/setup.sh
+12 −8 .evergreen/auth_oidc/gcp/setup-instance.sh
+3 −2 .evergreen/auth_oidc/gcp/setup.sh
+1 −1 .evergreen/auth_oidc/k8s/remote-scripts/run-self-test.sh
+1 −1 .evergreen/auth_oidc/k8s/remote-scripts/start-server.sh
+6 −0 .evergreen/auth_oidc/k8s/run-driver-test.sh
+2 −1 .evergreen/auth_oidc/k8s/setup.sh
+3 −2 .evergreen/auth_oidc/oidc_get_tokens.sh
+3 −2 .evergreen/auth_oidc/setup.sh
+2 −1 .evergreen/aws_lambda/run-deployed-lambda-aws-tests.sh
+1 −0 .evergreen/compile-unix.sh
+2 −1 .evergreen/compile-windows.sh
+86 −13 .evergreen/config.yml
+2 −2 .evergreen/csfle/await-servers.sh
+1 −1 .evergreen/csfle/azurekms/create-and-setup-vm.sh
+1 −1 .evergreen/csfle/azurekms/create-vm.sh
+11 −9 .evergreen/csfle/azurekms/login.sh
+12 −11 .evergreen/csfle/azurekms/run-command.sh
+14 −11 .evergreen/csfle/gcpkms/copy-file.sh
+4 −2 .evergreen/csfle/gcpkms/create-and-setup-instance.sh
+18 −19 .evergreen/csfle/gcpkms/create-instance.sh
+1 −1 .evergreen/csfle/gcpkms/delete-instance.sh
+1 −0 .evergreen/csfle/gcpkms/download-gcloud.sh
+3 −2 .evergreen/csfle/gcpkms/remote-scripts/start-mongodb.sh
+2 −2 .evergreen/csfle/gcpkms/remote-scripts/startup.sh
+1 −1 .evergreen/csfle/gcpkms/run-command.sh
+1 −1 .evergreen/csfle/gcpkms/setup-instance.sh
+7 −4 .evergreen/csfle/set-temp-creds.sh
+2 −0 .evergreen/csfle/stop-servers.sh
+29 −27 .evergreen/download-mongodb.sh
+4 −4 .evergreen/ensure-binary.sh
+2 −1 .evergreen/find-python3.sh
+6 −9 .evergreen/handle-paths.sh
+0 −1 .evergreen/install-dependencies.sh
+3 −5 .evergreen/install-node.sh
+33 −0 .evergreen/install-rust.sh
+6 −3 .evergreen/k8s/aks/setup-cluster.sh
+2 −2 .evergreen/k8s/configure-pod.sh
+4 −3 .evergreen/retry-with-backoff.sh
+2 −1 .evergreen/run-atlas-proxy.sh
+1 −1 .evergreen/run-load-balancer.sh
+3 −1 .evergreen/run-orchestration.sh
+2 −2 .evergreen/secrets_handling/setup-secrets.sh
+6 −3 .evergreen/serverless/create-instance.sh
+1 −1 .evergreen/serverless/delete-instance.sh
+0 −5 .evergreen/setup.sh
+45 −20 .evergreen/start-orchestration.sh
+6 −1 .evergreen/stop-orchestration.sh
+4 −4 .evergreen/teardown.sh
+1 −0 .github/workflows/tests.yml
+2 −0 .gitignore
+1 −1 .pre-commit-config.yaml
8 changes: 4 additions & 4 deletions lib/mongo/search_index/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def initialize(collection, options = {})
# @param [ nil | String ] name The name to give the new search index.
#
# @return [ String ] the name of the new search index.
def create_one(definition, name: nil)
create_many([ { name: name, definition: definition } ]).first
def create_one(definition, name: nil, type: 'search')
create_many([ { name: name, definition: definition, type: type } ]).first
end

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

collection.aggregate(
collection.with(read_concern: {}).aggregate(
[ { '$listSearchIndexes' => spec } ],
aggregate_options
)
Expand Down Expand Up @@ -200,7 +200,7 @@ def validate_search_index!(doc)
#
# @raise [ ArgumentError ] if the list contains any invalid keys
def validate_search_index_keys!(keys)
extras = keys - [ 'name', 'definition', :name, :definition ]
extras = keys - [ 'name', 'definition', 'type', :name, :definition, :type ]

raise ArgumentError, "invalid keys in search index creation: #{extras.inspect}" if extras.any?
end
Expand Down
3 changes: 2 additions & 1 deletion spec/runners/unified/search_index_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def create_search_index(op)
model = args.use('model')
name = model.use('name')
definition = model.use('definition')
collection.search_indexes.create_one(definition, name: name)
type = model.use('type')
collection.search_indexes.create_one(definition, name: name, type: type)
end
end

Expand Down
38 changes: 33 additions & 5 deletions spec/spec_tests/data/index_management/createSearchIndex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ createEntities:
collectionName: *collection0

runOnRequirements:
- minServerVersion: "7.0.0"
# Skip server versions without fix of SERVER-83107 to avoid error message "BSON field 'createSearchIndexes.indexes.type' is an unknown field."
# SERVER-83107 was not backported to 7.1.
- minServerVersion: "7.0.5"
maxServerVersion: "7.0.99"
topologies: [ replicaset, load-balanced, sharded ]
serverless: forbid
- minServerVersion: "7.2.0"
topologies: [ replicaset, load-balanced, sharded ]
serverless: forbid

Expand All @@ -26,7 +32,7 @@ tests:
- name: createSearchIndex
object: *collection0
arguments:
model: { definition: &definition { mappings: { dynamic: true } } }
model: { definition: &definition { mappings: { dynamic: true } } , type: 'search' }
expectError:
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
# that the driver constructs and sends the correct command.
Expand All @@ -39,15 +45,37 @@ tests:
- commandStartedEvent:
command:
createSearchIndexes: *collection0
indexes: [ { definition: *definition } ]
indexes: [ { definition: *definition, type: 'search'} ]
$db: *database0

- description: "name provided for an index definition"
operations:
- name: createSearchIndex
object: *collection0
arguments:
model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index' }
model: { definition: &definition { mappings: { dynamic: true } } , name: 'test index', type: 'search' }
expectError:
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
# that the driver constructs and sends the correct command.
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
isError: true
errorContains: Atlas
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
createSearchIndexes: *collection0
indexes: [ { definition: *definition, name: 'test index', type: 'search' } ]
$db: *database0

- description: "create a vector search index"
operations:
- name: createSearchIndex
object: *collection0
arguments:
model: { definition: &definition { fields: [ {"type": "vector", "path": "plot_embedding", "numDimensions": 1536, "similarity": "euclidean"} ] }
, name: 'test index', type: 'vectorSearch' }
expectError:
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
# that the driver constructs and sends the correct command.
Expand All @@ -60,5 +88,5 @@ tests:
- commandStartedEvent:
command:
createSearchIndexes: *collection0
indexes: [ { definition: *definition, name: 'test index' } ]
indexes: [ { definition: *definition, name: 'test index', type: 'vectorSearch' } ]
$db: *database0
38 changes: 33 additions & 5 deletions spec/spec_tests/data/index_management/createSearchIndexes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ createEntities:
collectionName: *collection0

runOnRequirements:
- minServerVersion: "7.0.0"
# Skip server versions without fix of SERVER-83107 to avoid error message "BSON field 'createSearchIndexes.indexes.type' is an unknown field."
# SERVER-83107 was not backported to 7.1.
- minServerVersion: "7.0.5"
maxServerVersion: "7.0.99"
topologies: [ replicaset, load-balanced, sharded ]
serverless: forbid
- minServerVersion: "7.2.0"
topologies: [ replicaset, load-balanced, sharded ]
serverless: forbid

Expand Down Expand Up @@ -48,7 +54,7 @@ tests:
- name: createSearchIndexes
object: *collection0
arguments:
models: [ { definition: &definition { mappings: { dynamic: true } } } ]
models: [ { definition: &definition { mappings: { dynamic: true } } , type: 'search' } ]
expectError:
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
# that the driver constructs and sends the correct command.
Expand All @@ -61,15 +67,37 @@ tests:
- commandStartedEvent:
command:
createSearchIndexes: *collection0
indexes: [ { definition: *definition } ]
indexes: [ { definition: *definition, type: 'search'} ]
$db: *database0

- description: "name provided for an index definition"
operations:
- name: createSearchIndexes
object: *collection0
arguments:
models: [ { definition: &definition { mappings: { dynamic: true } } , name: 'test index' } ]
models: [ { definition: &definition { mappings: { dynamic: true } } , name: 'test index' , type: 'search' } ]
expectError:
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
# that the driver constructs and sends the correct command.
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
isError: true
errorContains: Atlas
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
createSearchIndexes: *collection0
indexes: [ { definition: *definition, name: 'test index', type: 'search' } ]
$db: *database0

- description: "create a vector search index"
operations:
- name: createSearchIndexes
object: *collection0
arguments:
models: [ { definition: &definition { fields: [ {"type": "vector", "path": "plot_embedding", "numDimensions": 1536, "similarity": "euclidean"} ] },
name: 'test index' , type: 'vectorSearch' } ]
expectError:
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
# that the driver constructs and sends the correct command.
Expand All @@ -82,5 +110,5 @@ tests:
- commandStartedEvent:
command:
createSearchIndexes: *collection0
indexes: [ { definition: *definition, name: 'test index' } ]
indexes: [ { definition: *definition, name: 'test index', type: 'vectorSearch' } ]
$db: *database0
15 changes: 9 additions & 6 deletions spec/spec_tests/data/index_management/listSearchIndexes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ createEntities:
database: *database0
collectionName: *collection0

initialData:
- collectionName: *collection0
databaseName: *database0
documents:
- x: 1

runOnRequirements:
- minServerVersion: "7.0.0"
topologies: [ replicaset, load-balanced, sharded ]
serverless: forbid

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

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

- description: aggregation cursor options are supported
skipReason: https://jira.mongodb.org/browse/DRIVERS-2794
operations:
- name: listSearchIndexes
object: *collection0
arguments:
arguments:
name: &indexName "test index"
aggregationOptions:
aggregationOptions:
batchSize: 10
expectError:
# This test always errors in a non-Atlas environment. The test functions as a unit test by asserting
Expand Down
Loading

0 comments on commit 5d39706

Please sign in to comment.