Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-3043 Use default write/read concerns in the index search commands. #1563

Merged
merged 4 commits into from
Apr 19, 2024

Conversation

qingyang-hu
Copy link
Collaborator

@qingyang-hu qingyang-hu commented Feb 13, 2024

GODRIVER-3043
GODRIVER-3122

Summary

  • Clone a new session and remove the read/write concerns before using it in the search index commands.
  • Add the prose test to verify that write/read concerns are not appended to Atlas Search Index commands.
  • Fix the failed test case in the GODRIVER-3122.

Background & Motivation

The unified tests for GODRIVER-3043 have been added in GODRIVER-3074.

Copy link
Contributor

mongodb-drivers-pr-bot bot commented Feb 13, 2024

API Change Report

./x/mongo/driver/operation

incompatible changes

(*CreateSearchIndexes).WriteConcern: removed
(*DropSearchIndex).WriteConcern: removed
(*UpdateSearchIndex).WriteConcern: removed

@qingyang-hu qingyang-hu force-pushed the godriver3122 branch 8 times, most recently from 4319b32 to 23575bd Compare February 16, 2024 18:16
@qingyang-hu qingyang-hu changed the title GODRIVER-3122 Update prose tests for index management. GODRIVER-3043 Update prose tests for index management. Feb 16, 2024
@qingyang-hu qingyang-hu changed the title GODRIVER-3043 Update prose tests for index management. GODRIVER-3043 Use default write/read concerns in the index search commands. Feb 16, 2024
@qingyang-hu qingyang-hu marked this pull request as ready for review February 16, 2024 20:33
@qingyang-hu qingyang-hu requested a review from a team as a code owner February 16, 2024 20:33
@qingyang-hu qingyang-hu requested review from matthewdale and removed request for a team February 16, 2024 20:33
@qingyang-hu qingyang-hu added the priority-3-low Low Priority PR for Review label Feb 29, 2024
Makefile Outdated
@@ -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 3600s >> test.suite
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment explaining why we have to hardcode a timeout. Also, we could avoid a magic string using shell inline:

evg-test-search-index:
	go test ./mongo/integration -run TestSearchIndexProse -v -timeout $(shell echo "$$(( $(TEST_TIMEOUT) * 2))")s >> test.suite

view := mt.Coll.SearchIndexes()

definition := bson.D{{"mappings", bson.D{{"dynamic", false}}}}
searchName := "test-search-index6"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
searchName := "test-search-index6"
const searchName = "test-search-index-case6'"

Suggest constantizing and using the name specified in the prose test: "test-search-index-case6'"

Database: csi.database,
Deployment: csi.deployment,
Selector: csi.selector,
ServerAPI: csi.serverAPI,
Timeout: csi.timeout,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's peculiar all this data was missing from the operation. Was it just missed in the original implementation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it will be better to align with the implementation in "create_indexes.go".

Copy link
Collaborator

@matthewdale matthewdale Apr 19, 2024

Choose a reason for hiding this comment

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

IIUC, the search index management server commands actually manage resources on an Apache Lucene cluster (and maybe some database configuration), so it's possible some of the previously omitted info was unnecessary. However, it's not clear what the impact of adding or removing those fields is.

I generally agree that passing the same info as CreateIndexes seems like a good idea, but should we test for that? Or if the info was truly unnecessary, should we continue to omit it?

Edit: To clarify, we shouldn't block merging the PR, but we should try to figure out whether we're missing test coverage for this type of behavior change that could be hiding other omissions.

require.Equal(mt, searchName, index, "unmatched name")
var doc bson.Raw
for doc == nil {
cursor, err := view.List(ctx, opts)
Copy link
Collaborator

@prestonvasquez prestonvasquez Mar 8, 2024

Choose a reason for hiding this comment

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

Why not exhaust the cursor?

var doc bson.Raw
for cursor.Next(ctx) {
	name := cursor.Current.Lookup("name").StringValue()
	queryable := cursor.Current.Lookup("queryable").Boolean()
	if name == searchName && queryable {
		doc = cursor.Current
		break
	}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I break on negative cursor.Next to reduce the deep nesting block and simplify the exiting of the recurring List calls.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mention doing this because this is what CXX does: https://github.com/kevinAlbs/mongo-cxx-driver/blob/fff7c2c71438f9f62c6b1a6ca5dee20f1c1749ac/src/mongocxx/test/search_index_view.cpp#L19

I think the current implementation is fine, though. IIUC in case 6 there would only ever be one doc on the cursor for view.List. Is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct.

Copy link
Collaborator

@prestonvasquez prestonvasquez left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@qingyang-hu qingyang-hu merged commit b1cd906 into mongodb:v1 Apr 19, 2024
28 of 34 checks passed
blink1073 pushed a commit to blink1073/mongo-go-driver that referenced this pull request Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low Low Priority PR for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants