Skip to content

Added index type tests for single#253

Open
vic-tsang wants to merge 1 commit into
documentdb:mainfrom
vic-tsang:indexes/type/single/tests
Open

Added index type tests for single#253
vic-tsang wants to merge 1 commit into
documentdb:mainfrom
vic-tsang:indexes/type/single/tests

Conversation

@vic-tsang
Copy link
Copy Markdown
Collaborator

This PR contains:

  • indexes type tests for single

Note: I realized a lot of tests already exists in createIndexes. It might seem like we are missing some tests but they could be covered already in createIndexes. Rather than having duplicated tests I have omitted them.

Ref:

Signed-off-by: Victor [C] Tsang <vitsangp@amazon.com>
@vic-tsang vic-tsang requested a review from a team as a code owner May 29, 2026 20:50
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels May 29, 2026
@documentdb-triage-tool
Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort L · Status Needs Review
Confidence: 0.85 (mixed)

Reasoning

component from path globs (test-coverage); effort from diff stats (506+0 LOC, 6 files); LLM: Adds new index type test cases for single indexes under the compatibility test suite, referencing issue #27.

If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

default_error_code=CANNOT_CREATE_INDEX_ERROR,
valid_inputs={
BsonType.DOUBLE: 1.0,
BsonType.INT: 1,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why is INT(1) would fail

assertSuccessPartial(result, index_created_response(), test.msg)


def test_single_creation_on_nonexistent_collection(collection):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is the same as above

)
collection.insert_many(list(test.doc))
result = execute_command(collection, {"find": collection.name, "filter": test.filter})
assertSuccess(result, test.expected, msg=test.msg)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does it assert index usage?

collection,
{"find": collection.name, "filter": {"a": 10}, "projection": {"_id": 0, "a": 1}},
)
assertSuccess(result, [{"a": 10}], msg="Should return only indexed field")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

non of the assert actually assert index usage.

result,
INDEX_KEY_SPECS_CONFLICT_ERROR,
msg="Same key+name with different options should fail",
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

where are partial index , sparse and hidden properties tested for index creation success and failure.

collection,
{"find": collection.name, "filter": {"a": 10}, "projection": {"_id": 0, "a": 1, "b": 1}},
)
assertSuccess(result, [{"a": 10, "b": "x"}], msg="Should return indexed and non-indexed fields")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing: $in and $ne queries - these also are used as index filter condition.
Missing: hint usage

]


@pytest.mark.parametrize("test", pytest_params(CREATION_ERROR_TESTS))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing: empty key {}.

result,
{"ok": 1.0, "numIndexesBefore": 2, "numIndexesAfter": 3},
msg="Different sort order should create separate index",
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing: dropIndexes after creation.

indexes=({"key": {"a.b": 1}, "name": "a.b_1"},),
msg="Dot notation field succeeds",
),
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing: multiple fields in a single createIndexes call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants