Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ timeout:
args: [ls, -la]

functions:
assume-test-secrets-ec2-role:
- command: ec2.assume_role
params:
role_arn: ${aws_test_secrets_role}

Comment on lines -29 to -33
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of L175

setup-system:
# Executes clone and applies the submitted patch, if any
- command: git.get_project
Expand Down Expand Up @@ -439,7 +434,7 @@ functions:
params:
binary: "bash"
env:
TEST_SEARCH_INDEX: "${MONGODB_URI}"
SEARCH_INDEX_URI: "${SEARCH_INDEX_URI}"
args: [*task-runner, evg-test-search-index]

add-aws-auth-variables-to-file:
Expand Down Expand Up @@ -2063,7 +2058,7 @@ task_groups:
params:
working_dir: src/go.mongodb.org/mongo-driver
binary: bash
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN]
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, MONGODB_URI]
env:
MONGODB_VERSION: ${VERSION}
LAMBDA_STACK_NAME: dbx-go-lambda
Expand All @@ -2072,6 +2067,15 @@ task_groups:
- command: expansions.update
params:
file: src/go.mongodb.org/mongo-driver/atlas-expansion.yml
- command: shell.exec
params:
working_dir: src/go.mongodb.org/mongo-driver
shell: bash
script: |-
echo "SEARCH_INDEX_URI: ${MONGODB_URI}" > atlas-expansion.yml
Copy link
Member

@prestonvasquez prestonvasquez Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] The EG changes seem to be trying to avoid using TEST_SEARCH_INDEX: "${MONGODB_URI}". If that's the case, we should keep the existing behavior for simplicity and roll TestSearchIndex into TestSearchIndexProse.

- command: expansions.update
params:
file: src/go.mongodb.org/mongo-driver/atlas-expansion.yml
teardown_group:
- command: subprocess.exec
params:
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ tasks:

evg-test-search-index:
# Use the long timeout to wait for the responses from the server.
- go test ./internal/integration -run TestSearchIndexProse -v -timeout {{.LONG_TEST_TIMEOUT}}s >> test.suite
Copy link
Member

@prestonvasquez prestonvasquez Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] We should define TestSearchIndexProse explicitly rather than relying on regex. Also note that the prose tests are being skipped since TEST_SEARCH_INDEX no longer is set.

- go test ./internal/integration -run ^TestSearchIndexProse$ -v -timeout {{.LONG_TEST_TIMEOUT}}s >> test.suite

evg-test-ocsp:
- go test -v ./mongo -run TestOCSP ${OCSP_TLS_SHOULD_SUCCEED} >> test.suite
Expand Down
61 changes: 50 additions & 11 deletions internal/integration/search_index_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestSearchIndexProse(t *testing.T) {

const timeout = 5 * time.Minute

uri := os.Getenv("TEST_INDEX_URI")
uri := os.Getenv("SEARCH_INDEX_URI")
if uri == "" {
t.Skip("skipping")
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestSearchIndexProse(t *testing.T) {
if name == searchName && queryable {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestSearchIndexProse(t *testing.T) {
if name == *args.Name && queryable {
return cursor.Current
}
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestSearchIndexProse(t *testing.T) {
if name == searchName && queryable {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand All @@ -201,7 +201,7 @@ func TestSearchIndexProse(t *testing.T) {
if !cursor.Next(ctx) {
break
}
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
})
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestSearchIndexProse(t *testing.T) {
if name == searchName && queryable {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand All @@ -262,7 +262,7 @@ func TestSearchIndexProse(t *testing.T) {
if name == searchName && queryable && status == "READY" && bytes.Equal(latestDefinition, expected) {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func TestSearchIndexProse(t *testing.T) {
if name == searchName && queryable {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand Down Expand Up @@ -363,7 +363,7 @@ func TestSearchIndexProse(t *testing.T) {
doc = cursor.Current
assert.Equal(mt, indexType, "search")
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand Down Expand Up @@ -391,7 +391,7 @@ func TestSearchIndexProse(t *testing.T) {
doc = cursor.Current
assert.Equal(mt, indexType, "search")
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand Down Expand Up @@ -432,7 +432,7 @@ func TestSearchIndexProse(t *testing.T) {
doc = cursor.Current
assert.Equal(mt, indexType, "vectorSearch")
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
Expand Down Expand Up @@ -472,4 +472,43 @@ func TestSearchIndexProse(t *testing.T) {
})
assert.ErrorContains(mt, err, "Attribute mappings missing")
})

mt.Run("case 9: Drivers use server default for unspecified name (`default`) and type (`search`)", func(mt *mtest.T) {
ctx := context.Background()

view := mt.Coll.SearchIndexes()
definition := bson.D{
{"mappings", bson.D{
{"dynamic", true},
}},
}
opts := options.SearchIndexes()

indexName, err := view.CreateOne(ctx, mongo.SearchIndexModel{
Definition: definition,
Options: opts,
})
require.NoError(mt, err, "failed to create index")
require.Equal(mt, "default", indexName)

var doc bson.Raw
for doc == nil {
cursor, err := view.List(ctx, opts)
require.NoError(mt, err, "failed to list")

if !cursor.Next(ctx) {
break
}
name := cursor.Current.Lookup("name").StringValue()
queryable := cursor.Current.Lookup("queryable").Boolean()
indexType := cursor.Current.Lookup("type").StringValue()
if name == indexName && queryable {
doc = cursor.Current
require.Equal(mt, indexType, "search")
} else {
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
})
}
2 changes: 1 addition & 1 deletion mongo/search_index_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ func (siv SearchIndexView) CreateMany(
}

var iidx int32
iidx, indexes = bsoncore.AppendDocumentElementStart(indexes, strconv.Itoa(i))
if model.Options != nil {
searchIndexArgs, err := mongoutil.NewOptions[options.SearchIndexesOptions](model.Options)
if err != nil {
return nil, fmt.Errorf("failed to construct options from builder: %w", err)
}

iidx, indexes = bsoncore.AppendDocumentElementStart(indexes, strconv.Itoa(i))
if searchIndexArgs.Name != nil {
indexes = bsoncore.AppendStringElement(indexes, "name", *searchIndexArgs.Name)
}
Expand Down
Loading