Add collation tests#225
Conversation
Signed-off-by: Daniel Frankcom <[email protected]>
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage, test-framework); effort from diff stats (14234+21 LOC, 62 files); LLM: Adds new collation behavior tests across multiple commands/features, touching test coverage and some framework changes across multiple files. If a label is wrong, remove it manually and ping |
| @@ -0,0 +1,356 @@ | |||
| """Tests for collation effects on $top, $bottom, $topN, $bottomN, $minN, $maxN accumulators.""" | |||
There was a problem hiding this comment.
To better demonstrate what each test does and ensure test coverage, can we consider a high level folder structure change?
For example:
collation/
├── utils/
│ ├── __init__.py
│ └── collation_view_mismatch.py
│
├── options/
│ ├── test_collation_locale.py
│ ├── ...e.g. strength, caseLevel, caseFirst, numericOrdering, alternate, maxVariable, backwards, normalization
│ └── test_collation_error_cases.py # invalid collation docs: missing locale, bad types, unknown fields
│ # NOTE: each option test uses $match or find to verify behavior
│
├── command_level/
│ │ # 1-2 tests per operation/stage proving command-level collation works
│ │ # operations
│ ├── test_collation_find.py
│ ├── test_collation_find_and_modify.py
│ ├── test_collation_count.py
│ ...
│ │ # stages
│ ├── test_collation_aggregate_match.py
│ ├── test_collation_aggregate_sort.py
│ ...
│ └── test_collation_aggregate_graphlookup.py
│
├── collection_level/
│ ├── test_collation_collection_default.py
│ ├── test_collation_views.py
│ ...
│ # Note: Collation on view should not impact the underlying collection
│ └── test_collation_view_from_view.py
│
├── index_level/
│ ├── test_collation_index.py # create index with collation, query uses it when collation matches
│ ...
│ └── test_collation_index_not_used.py # query with different collation → COLLSCAN
│
└── resolution/
└── test_collation_resolution.py # three-way precedence:command-vs-collection-vs-index level collation precedence
# NOTE: each test uses one operation as example should be good
There was a problem hiding this comment.
Discussed offline, have pushed a change with suggested structure based on this.
Signed-off-by: Daniel Frankcom <[email protected]>
Signed-off-by: Daniel Frankcom <[email protected]>
Signed-off-by: Daniel Frankcom <[email protected]>
| # created with a collation other than simple; creating one on a collection | ||
| # with a non-simple default collation requires specifying | ||
| # collation {locale: "simple"} on the index. | ||
| COLLATION_TEXT_INDEX_TESTS: list[CommandTestCase] = [ |
There was a problem hiding this comment.
This should be moved to /index_level/
| # Property [Capped Collection Collation]: a capped collection can be created | ||
| # with a default collation, and collation affects filter matching and sort | ||
| # ordering on capped collections the same as regular collections. | ||
| COLLATION_CAPPED_TESTS: list[CommandTestCase] = [ |
There was a problem hiding this comment.
Move to /collection_level
| @@ -0,0 +1,542 @@ | |||
| """Tests for collation behavior with indexes.""" | |||
There was a problem hiding this comment.
Missing 2dsphere and 2d index.
| @@ -0,0 +1,332 @@ | |||
| """Tests for collation constraints on views and cross-view stage behavior.""" | |||
|
|
|||
There was a problem hiding this comment.
Timeseries, Clustered not covered.
| @@ -0,0 +1,113 @@ | |||
| """Tests for collation effects on positional $ and $elemMatch projection.""" | |||
There was a problem hiding this comment.
why not put under operations/test_operations_projection_ops.py.
| from documentdb_tests.framework.parametrize import pytest_params | ||
|
|
||
| # Property [Dotted Path Filter Matching]: collation affects equality and | ||
| # comparison operators on dotted field paths in find and aggregate $match, |
There was a problem hiding this comment.
I think we don't need this file, collation affects on every string comparison. deep field path is implied. One is enough.
| @@ -0,0 +1,166 @@ | |||
| """Tests for collation interaction with command-level let variables.""" | |||
There was a problem hiding this comment.
$let is expression operator, test_stages_expression.py, and use in update is not needed. We just test one level down: $let + collation. If we test both find and update, we are testing $let + collation + command.
This change adds tests for collation across commands/features. The intent is to cover semantic behavior of collation in general, so these tests cover a number of different features that could potentially be affected by collation.
While working on this change I found some gaps in the collation testing for the
aggregatecommand, so will add them in #221. The split is the command tests aim to test the syntax and accepted options for the collation configuration, whereas the dedicatedcollationtests focus on the behavior.There is some overlap here with #191 as some of the framework changes are needed by both. I've included them here so they should merge cleanly.