Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Feb 16, 2024
1 parent bf1d085 commit 6c6b4cc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ evg-test-load-balancers:

.PHONY: evg-test-search-index
evg-test-search-index:
go test ./mongo/integration -run TestSearchIndexProse -v -timeout $(TEST_TIMEOUT)s >> test.suite
go test ./mongo/integration -run TestSearchIndexProse -v -timeout $(TEST_TIMEOUT)s

.PHONY: evg-test-ocsp
evg-test-ocsp:
Expand Down
54 changes: 25 additions & 29 deletions mongo/integration/search_index_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,19 @@ func TestSearchIndexProse(t *testing.T) {

var doc bson.Raw
for doc == nil {
for {
cursor, err := view.List(ctx, opts)
require.NoError(mt, err, "failed to list")
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()
if name == searchName && queryable {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
if !cursor.Next(ctx) {
break
}
name := cursor.Current.Lookup("name").StringValue()
queryable := cursor.Current.Lookup("queryable").Boolean()
if name == searchName && queryable {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
require.NotNil(mt, doc, "got empty document")
Expand All @@ -234,22 +232,20 @@ func TestSearchIndexProse(t *testing.T) {
err = view.UpdateOne(ctx, searchName, definition)
require.NoError(mt, err, "failed to update index")
for doc == nil {
for {
cursor, err := view.List(ctx, opts)
require.NoError(mt, err, "failed to list")
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()
status := cursor.Current.Lookup("status").StringValue()
if name == searchName && queryable && status == "READY" {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
if !cursor.Next(ctx) {
break
}
name := cursor.Current.Lookup("name").StringValue()
queryable := cursor.Current.Lookup("queryable").Boolean()
status := cursor.Current.Lookup("status").StringValue()
if name == searchName && queryable && status == "READY" {
doc = cursor.Current
} else {
t.Logf("cursor: %s, sleep 5 seconds...", cursor.Current.String())
time.Sleep(5 * time.Second)
}
}
require.NotNil(mt, doc, "got empty document")
Expand Down
31 changes: 3 additions & 28 deletions mongo/search_index_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/writeconcern"
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
"go.mongodb.org/mongo-driver/x/mongo/driver"
"go.mongodb.org/mongo-driver/x/mongo/driver/operation"
Expand Down Expand Up @@ -134,18 +133,10 @@ func (siv SearchIndexView) CreateMany(
return nil, err
}

wc := siv.coll.writeConcern
if sess.TransactionRunning() {
wc = nil
}
if !writeconcern.AckWrite(wc) {
sess = nil
}

selector := makePinnedSelector(sess, siv.coll.writeSelector)

op := operation.NewCreateSearchIndexes(indexes).
Session(sess).WriteConcern(wc).ClusterClock(siv.coll.client.clock).
Session(sess).ClusterClock(siv.coll.client.clock).
Database(siv.coll.db.name).Collection(siv.coll.name).CommandMonitor(siv.coll.client.monitor).
Deployment(siv.coll.client.deployment).ServerSelector(selector).ServerAPI(siv.coll.client.serverAPI).
Timeout(siv.coll.client.timeout)
Expand Down Expand Up @@ -196,18 +187,10 @@ func (siv SearchIndexView) DropOne(
return err
}

wc := siv.coll.writeConcern
if sess.TransactionRunning() {
wc = nil
}
if !writeconcern.AckWrite(wc) {
sess = nil
}

selector := makePinnedSelector(sess, siv.coll.writeSelector)

op := operation.NewDropSearchIndex(name).
Session(sess).WriteConcern(wc).CommandMonitor(siv.coll.client.monitor).
Session(sess).CommandMonitor(siv.coll.client.monitor).
ServerSelector(selector).ClusterClock(siv.coll.client.clock).
Database(siv.coll.db.name).Collection(siv.coll.name).
Deployment(siv.coll.client.deployment).ServerAPI(siv.coll.client.serverAPI).
Expand Down Expand Up @@ -258,18 +241,10 @@ func (siv SearchIndexView) UpdateOne(
return err
}

wc := siv.coll.writeConcern
if sess.TransactionRunning() {
wc = nil
}
if !writeconcern.AckWrite(wc) {
sess = nil
}

selector := makePinnedSelector(sess, siv.coll.writeSelector)

op := operation.NewUpdateSearchIndex(name, indexDefinition).
Session(sess).WriteConcern(wc).CommandMonitor(siv.coll.client.monitor).
Session(sess).CommandMonitor(siv.coll.client.monitor).
ServerSelector(selector).ClusterClock(siv.coll.client.clock).
Database(siv.coll.db.name).Collection(siv.coll.name).
Deployment(siv.coll.client.deployment).ServerAPI(siv.coll.client.serverAPI).
Expand Down

0 comments on commit 6c6b4cc

Please sign in to comment.