Skip to content

Commit

Permalink
GODRIVER-3359 Sync with master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvasquez committed Nov 8, 2024
1 parent 9245e42 commit 10577eb
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 41 deletions.
88 changes: 81 additions & 7 deletions testdata/index-management/createSearchIndex.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@
],
"runOnRequirements": [
{
"minServerVersion": "7.0.0",
"minServerVersion": "7.0.5",
"maxServerVersion": "7.0.99",
"topologies": [
"replicaset",
"load-balanced",
"sharded"
],
"serverless": "forbid"
},
{
"minServerVersion": "7.2.0",
"topologies": [
"replicaset",
"load-balanced",
Expand All @@ -50,12 +60,13 @@
"mappings": {
"dynamic": true
}
}
},
"type": "search"
}
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
"errorContains": "Atlas"
}
}
],
Expand All @@ -73,7 +84,8 @@
"mappings": {
"dynamic": true
}
}
},
"type": "search"
}
],
"$db": "database0"
Expand All @@ -97,12 +109,13 @@
"dynamic": true
}
},
"name": "test index"
"name": "test index",
"type": "search"
}
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
"errorContains": "Atlas"
}
}
],
Expand All @@ -121,7 +134,68 @@
"dynamic": true
}
},
"name": "test index"
"name": "test index",
"type": "search"
}
],
"$db": "database0"
}
}
}
]
}
]
},
{
"description": "create a vector search index",
"operations": [
{
"name": "createSearchIndex",
"object": "collection0",
"arguments": {
"model": {
"definition": {
"fields": [
{
"type": "vector",
"path": "plot_embedding",
"numDimensions": 1536,
"similarity": "euclidean"
}
]
},
"name": "test index",
"type": "vectorSearch"
}
},
"expectError": {
"isError": true,
"errorContains": "Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"createSearchIndexes": "collection0",
"indexes": [
{
"definition": {
"fields": [
{
"type": "vector",
"path": "plot_embedding",
"numDimensions": 1536,
"similarity": "euclidean"
}
]
},
"name": "test index",
"type": "vectorSearch"
}
],
"$db": "database0"
Expand Down
44 changes: 37 additions & 7 deletions testdata/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,37 +32,61 @@ 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.
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
isError: true
errorContains: Search index commands are only supported with Atlas
errorContains: Atlas
expectEvents:
- client: *client0
events:
- 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.
# The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages.
isError: true
errorContains: Search index commands are only supported with Atlas
errorContains: Atlas
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
createSearchIndexes: *collection0
indexes: [ { definition: *definition, name: 'test index' } ]
indexes: [ { definition: *definition, name: 'test index', type: 'vectorSearch' } ]
$db: *database0
92 changes: 84 additions & 8 deletions testdata/index-management/createSearchIndexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@
],
"runOnRequirements": [
{
"minServerVersion": "7.0.0",
"minServerVersion": "7.0.5",
"maxServerVersion": "7.0.99",
"topologies": [
"replicaset",
"load-balanced",
"sharded"
],
"serverless": "forbid"
},
{
"minServerVersion": "7.2.0",
"topologies": [
"replicaset",
"load-balanced",
Expand All @@ -49,7 +59,7 @@
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
"errorContains": "Atlas"
}
}
],
Expand Down Expand Up @@ -83,13 +93,14 @@
"mappings": {
"dynamic": true
}
}
},
"type": "search"
}
]
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
"errorContains": "Atlas"
}
}
],
Expand All @@ -107,7 +118,8 @@
"mappings": {
"dynamic": true
}
}
},
"type": "search"
}
],
"$db": "database0"
Expand All @@ -132,13 +144,14 @@
"dynamic": true
}
},
"name": "test index"
"name": "test index",
"type": "search"
}
]
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
"errorContains": "Atlas"
}
}
],
Expand All @@ -157,7 +170,70 @@
"dynamic": true
}
},
"name": "test index"
"name": "test index",
"type": "search"
}
],
"$db": "database0"
}
}
}
]
}
]
},
{
"description": "create a vector search index",
"operations": [
{
"name": "createSearchIndexes",
"object": "collection0",
"arguments": {
"models": [
{
"definition": {
"fields": [
{
"type": "vector",
"path": "plot_embedding",
"numDimensions": 1536,
"similarity": "euclidean"
}
]
},
"name": "test index",
"type": "vectorSearch"
}
]
},
"expectError": {
"isError": true,
"errorContains": "Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"createSearchIndexes": "collection0",
"indexes": [
{
"definition": {
"fields": [
{
"type": "vector",
"path": "plot_embedding",
"numDimensions": 1536,
"similarity": "euclidean"
}
]
},
"name": "test index",
"type": "vectorSearch"
}
],
"$db": "database0"
Expand Down
Loading

0 comments on commit 10577eb

Please sign in to comment.