Skip to content

RUBY-3392 Add QE range auto-encryption unified spec tests - #3095

Merged
comandeo-mongo merged 3 commits into
mongodb:masterfrom
comandeo-mongo:qe-rangev2-fixtures
Jul 29, 2026
Merged

RUBY-3392 Add QE range auto-encryption unified spec tests#3095
comandeo-mongo merged 3 commits into
mongodb:masterfrom
comandeo-mongo:qe-rangev2-fixtures

Conversation

@comandeo-mongo

Copy link
Copy Markdown
Contributor

What

Adds the 46 fle2v2-Rangev2-* unified fixtures, giving QE range auto encryption
spec-driven coverage for the first time.

RUBY-3392 (#2894) removed the old fle2v2-Range-* (rangePreview) fixtures but never
added the Rangev2 replacements, so range auto encryption has had no unified coverage
since Aug 2024. Range GA shipped under RUBY-3457 on top of that gap.

Runner corrections

The fixtures do not pass without three unified-runner fixes the test format mandates:

  • Parse fixtures in :bson mode so $numberLong/$date keep their types. The server
    rejects a range field whose min/max type differs from the field type.
  • Match errorContains case-insensitively.
  • Compare numbers by value across BSON integer widths, so BSON::Int64(3) equals 3.

Parsing in :bson mode means the autoEncryptOpts maps arrive already converted, so
Utils.convert_client_options takes a parsed: flag to skip re-parsing them. Without
this, _apply_encrypted_fields_map parsed them a second time and raised
Unknown value type: BSON::Int64 in fle2v2-InsertFind-keyAltName.yml. The legacy crud
and transactions runners still pass raw extended JSON and are unchanged.

Dependency on #3088

The first commit (drop enxcol_ metadata collections in unified initialData setup) is
cherry-picked patch-identical from #3088, where it is also needed. Without it these
fixtures fail on exact __safeContent__ byte assertions, because value counts
accumulate in the enxcol_.<coll>.esc/.ecoc metadata collections across runs. Rebasing
after #3088 merges will drop the duplicate automatically.

Testing

Local 9.0.0-rc0 replica set, crypt_shared 8.2.6, libmongocrypt-helper 1.20.1:

Suite master baseline this branch
CSFLE unified 128 examples / 76 failures 524 / 76 (same 4 cloud-KMS fixture files)
Rangev2 subset n/a 396 / 0
18 non-CSFLE unified suites 996 / 0
legacy CSFLE + transactions + crud 3109 / 588 / 1423 pending identical

The pre-existing 76 and 588 failures are cloud-KMS credential env gaps, unaffected here.
RuboCop clean.

The unified test runner must drop enxcol_.<coll>.esc/.ecoc alongside the data
collection so QE __safeContent__ tag counts are reproducible for exact matching,
as required by the unified test format spec. Without this the QE-Text matching
query fixtures fail on __safeContent__ comparison.
RUBY-3392 removed the old fle2v2-Range-* (rangePreview) fixtures but never
added the fle2v2-Rangev2-* replacements, so QE range auto encryption has had
no spec-driven coverage since. Import all 46 fixtures.

Running them required three unified runner corrections the format mandates:

- Parse fixtures in :bson mode so $numberLong/$date keep their types. The
  server rejects a range field whose min/max type differs from the field type.
- Match errorContains case-insensitively.
- Compare numbers by value across BSON integer widths, so BSON::Int64(3)
  equals 3.

Parsing in :bson mode means autoEncryptOpts maps arrive already converted, so
convert_client_options takes a parsed flag to skip re-parsing them; the legacy
crud and transactions runners still pass raw extended JSON and are unchanged.
@comandeo-mongo
comandeo-mongo marked this pull request as ready for review July 29, 2026 10:12
@comandeo-mongo
comandeo-mongo requested a review from a team as a code owner July 29, 2026 10:12
@comandeo-mongo
comandeo-mongo requested review from Copilot and jamis July 29, 2026 10:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds unified spec coverage for Queryable Encryption (FLE2v2) Rangev2 auto-encryption by introducing the missing fle2v2-Rangev2-* fixtures and updating the unified spec runner to meet the unified test format requirements (BSON-mode parsing, errorContains matching, numeric comparisons, and initialData cleanup for QE metadata collections).

Changes:

  • Add the Rangev2 unified YAML fixtures for QE range auto-encryption coverage.
  • Update unified runner to parse fixtures in BSON mode, drop QE metadata collections during initialData setup, and match errorContains case-insensitively.
  • Normalize BSON integer wrappers in unified assertions so int32/int64 compare by numeric value.

Reviewed changes

Copilot reviewed 49 out of 49 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/support/utils.rb Add parsed: flag to avoid re-parsing already-BSON-typed autoEncryptOpts maps.
spec/runners/unified/test.rb Unified runner fixes: drop QE metadata collections in initialData, pass parsed: true for autoEncryptOpts, and case-insensitive errorContains.
spec/runners/unified/test_group.rb Parse unified fixtures in mode: :bson to preserve BSON numeric/date types.
spec/runners/unified/assertions.rb Compare BSON int32/int64 wrappers by numeric value during result matching.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Compact.yml Rangev2 compactStructuredEncryptionData unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Defaults.yml Rangev2 defaults unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-WrongType.yml Rangev2 wrong-type error-path unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Aggregate.yml Rangev2 int aggregate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Correctness.yml Rangev2 int correctness unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Delete.yml Rangev2 int delete unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-FindOneAndUpdate.yml Rangev2 int findOneAndUpdate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-InsertFind.yml Rangev2 int insert/find unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Int-Update.yml Rangev2 int update unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Aggregate.yml Rangev2 long aggregate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Correctness.yml Rangev2 long correctness unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Delete.yml Rangev2 long delete unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-FindOneAndUpdate.yml Rangev2 long findOneAndUpdate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-InsertFind.yml Rangev2 long insert/find unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Long-Update.yml Rangev2 long update unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Aggregate.yml Rangev2 date aggregate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Correctness.yml Rangev2 date correctness unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Delete.yml Rangev2 date delete unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-FindOneAndUpdate.yml Rangev2 date findOneAndUpdate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-InsertFind.yml Rangev2 date insert/find unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Date-Update.yml Rangev2 date update unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Aggregate.yml Rangev2 double aggregate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Correctness.yml Rangev2 double correctness unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Delete.yml Rangev2 double delete unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-FindOneAndUpdate.yml Rangev2 double findOneAndUpdate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-InsertFind.yml Rangev2 double insert/find unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Double-Update.yml Rangev2 double update unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Aggregate.yml Rangev2 double-with-precision aggregate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Correctness.yml Rangev2 double-with-precision correctness unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Delete.yml Rangev2 double-with-precision delete unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-FindOneAndUpdate.yml Rangev2 double-with-precision findOneAndUpdate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-InsertFind.yml Rangev2 double-with-precision insert/find unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DoublePrecision-Update.yml Rangev2 double-with-precision update unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Aggregate.yml Rangev2 decimal aggregate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Correctness.yml Rangev2 decimal correctness unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Delete.yml Rangev2 decimal delete unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-FindOneAndUpdate.yml Rangev2 decimal findOneAndUpdate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-InsertFind.yml Rangev2 decimal insert/find unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-Decimal-Update.yml Rangev2 decimal update unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Aggregate.yml Rangev2 decimal-with-precision aggregate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Correctness.yml Rangev2 decimal-with-precision correctness unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Delete.yml Rangev2 decimal-with-precision delete unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-FindOneAndUpdate.yml Rangev2 decimal-with-precision findOneAndUpdate unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-InsertFind.yml Rangev2 decimal-with-precision insert/find unified fixture.
spec/spec_tests/data/client_side_encryption/unified/fle2v2-Rangev2-DecimalPrecision-Update.yml Rangev2 decimal-with-precision update unified fixture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@comandeo-mongo
comandeo-mongo merged commit 2499e17 into mongodb:master Jul 29, 2026
220 checks passed
@comandeo-mongo
comandeo-mongo deleted the qe-rangev2-fixtures branch July 29, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants