Skip to content

Conversation

@analogrelay
Copy link
Member

Summary

Adds baseline tests validating MurmurHash3 V1/V2 partition key hashing against known-good values.

Test coverage (58 tests)

  • Singletons: undefined, null, true, false
  • Numbers: zero, negative zero, epsilon, NaN, infinity, int64 extremes, MaxSafeInteger
  • Strings: empty through 2KB (exercises V1 truncation at 100 chars)
  • Lists: 1/2/3-path hierarchical partition keys (multi-hash)

Design

  • Uses the production code path (PartitionKey._write_for_hashing / _write_for_hashing_v2) including string suffix bytes, so tests validate the actual SDK behavior end-to-end.
  • Baseline XML files can be regenerated via UPDATE_BASELINE=1 pytest tests/test_partition_key_hash_baseline.py.
  • Input test cases originated from the .NET SDK's PartitionKeyHashBaselineTest, with expected hash values regenerated from the Python SDK's production serialization path.

Validates MurmurHash3 V1/V2 partition key hashing against baseline XML
data covering singletons (undefined, null, true, false), numbers (zero,
negative zero, epsilon, NaN, infinity, int64 extremes), strings (empty
through 2KB), and hierarchical partition key lists.

Uses the production code path (PartitionKey._write_for_hashing /
_write_for_hashing_v2) including string suffix bytes. Baselines can be
regenerated with UPDATE_BASELINE=1.
@analogrelay
Copy link
Member Author

I built this as part of developing Azure/azure-sdk-for-go#26007 and thought it would be really good if our various SDKs had one set of common tests for computing EPKs. The .NET SDK has baseline tests like this, and this is a slight iteration on those (which I plan to roll in to other SDKs too).

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

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant