Skip to content

Commit 5b8e7cc

Browse files
committed
update prose test
1 parent 1373cf2 commit 5b8e7cc

File tree

3 files changed

+50
-73
lines changed

3 files changed

+50
-73
lines changed

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ tasks:
160160

161161
evg-test-search-index:
162162
# Use the long timeout to wait for the responses from the server.
163-
- go test ./internal/integration -run TestSearchIndex -v -timeout {{.LONG_TEST_TIMEOUT}}s >> test.suite
163+
- go test ./internal/integration -run ^TestSearchIndexProse$ -v -timeout {{.LONG_TEST_TIMEOUT}}s >> test.suite
164164

165165
evg-test-ocsp:
166166
- go test -v ./mongo -run TestOCSP ${OCSP_TLS_SHOULD_SUCCEED} >> test.suite

internal/integration/search_index_prose_test.go

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestSearchIndexProse(t *testing.T) {
7070
if name == searchName && queryable {
7171
doc = cursor.Current
7272
} else {
73-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
73+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
7474
time.Sleep(5 * time.Second)
7575
}
7676
}
@@ -127,7 +127,7 @@ func TestSearchIndexProse(t *testing.T) {
127127
if name == *args.Name && queryable {
128128
return cursor.Current
129129
}
130-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
130+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
131131
time.Sleep(5 * time.Second)
132132
}
133133
}
@@ -186,7 +186,7 @@ func TestSearchIndexProse(t *testing.T) {
186186
if name == searchName && queryable {
187187
doc = cursor.Current
188188
} else {
189-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
189+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
190190
time.Sleep(5 * time.Second)
191191
}
192192
}
@@ -201,7 +201,7 @@ func TestSearchIndexProse(t *testing.T) {
201201
if !cursor.Next(ctx) {
202202
break
203203
}
204-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
204+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
205205
time.Sleep(5 * time.Second)
206206
}
207207
})
@@ -237,7 +237,7 @@ func TestSearchIndexProse(t *testing.T) {
237237
if name == searchName && queryable {
238238
doc = cursor.Current
239239
} else {
240-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
240+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
241241
time.Sleep(5 * time.Second)
242242
}
243243
}
@@ -262,7 +262,7 @@ func TestSearchIndexProse(t *testing.T) {
262262
if name == searchName && queryable && status == "READY" && bytes.Equal(latestDefinition, expected) {
263263
doc = cursor.Current
264264
} else {
265-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
265+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
266266
time.Sleep(5 * time.Second)
267267
}
268268
}
@@ -315,7 +315,7 @@ func TestSearchIndexProse(t *testing.T) {
315315
if name == searchName && queryable {
316316
doc = cursor.Current
317317
} else {
318-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
318+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
319319
time.Sleep(5 * time.Second)
320320
}
321321
}
@@ -363,7 +363,7 @@ func TestSearchIndexProse(t *testing.T) {
363363
doc = cursor.Current
364364
assert.Equal(mt, indexType, "search")
365365
} else {
366-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
366+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
367367
time.Sleep(5 * time.Second)
368368
}
369369
}
@@ -391,7 +391,7 @@ func TestSearchIndexProse(t *testing.T) {
391391
doc = cursor.Current
392392
assert.Equal(mt, indexType, "search")
393393
} else {
394-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
394+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
395395
time.Sleep(5 * time.Second)
396396
}
397397
}
@@ -432,7 +432,7 @@ func TestSearchIndexProse(t *testing.T) {
432432
doc = cursor.Current
433433
assert.Equal(mt, indexType, "vectorSearch")
434434
} else {
435-
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
435+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
436436
time.Sleep(5 * time.Second)
437437
}
438438
}
@@ -472,4 +472,43 @@ func TestSearchIndexProse(t *testing.T) {
472472
})
473473
assert.ErrorContains(mt, err, "Attribute mappings missing")
474474
})
475+
476+
mt.Run("case 9: Drivers use server default for unspecified name (`default`) and type (`search`)", func(mt *mtest.T) {
477+
ctx := context.Background()
478+
479+
view := mt.Coll.SearchIndexes()
480+
definition := bson.D{
481+
{"mappings", bson.D{
482+
{"dynamic", true},
483+
}},
484+
}
485+
opts := options.SearchIndexes()
486+
487+
indexName, err := view.CreateOne(ctx, mongo.SearchIndexModel{
488+
Definition: definition,
489+
Options: opts,
490+
})
491+
require.NoError(mt, err, "failed to create index")
492+
require.Equal(mt, "default", indexName)
493+
494+
var doc bson.Raw
495+
for doc == nil {
496+
cursor, err := view.List(ctx, opts)
497+
require.NoError(mt, err, "failed to list")
498+
499+
if !cursor.Next(ctx) {
500+
break
501+
}
502+
name := cursor.Current.Lookup("name").StringValue()
503+
queryable := cursor.Current.Lookup("queryable").Boolean()
504+
indexType := cursor.Current.Lookup("type").StringValue()
505+
if name == indexName && queryable {
506+
doc = cursor.Current
507+
require.Equal(mt, indexType, "search")
508+
} else {
509+
mt.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
510+
time.Sleep(5 * time.Second)
511+
}
512+
}
513+
})
475514
}

internal/integration/search_index_test.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)