Skip to content

[test][common] Harden primitive collection correctness with oracle-backed tests#26022

Open
void-ptr974 wants to merge 1 commit into
apache:masterfrom
void-ptr974:test/collections-correctness-tests-pr
Open

[test][common] Harden primitive collection correctness with oracle-backed tests#26022
void-ptr974 wants to merge 1 commit into
apache:masterfrom
void-ptr974:test/collections-correctness-tests-pr

Conversation

@void-ptr974

@void-ptr974 void-ptr974 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Motivation

Pulsar has several custom primitive collection implementations where correctness depends on open-addressing probe chains, collision handling, and stable ordering. The existing tests covered basic API behavior, but they did not consistently compare long operation sequences against a trusted oracle.

Modifications

  • Add randomized model tests against JDK HashMap, HashSet, and PriorityQueue oracles.
  • Add directed collision-cluster tests for primitive open-addressing maps and sets.
  • Cover probe-chain preservation after removals, explicit zero values, null computeIfAbsent, and reference-equality conditional removal.
  • Exercise forEach, values, iterator, and queue head ordering as observable state checks.
  • Print each randomized test seed and include the seed in assertion failure messages. A failing run can be reproduced with -Dpulsar.collections.randomSeed=<seed>.

Verification

  • ./gradlew :pulsar-common:test --tests org.apache.pulsar.common.util.collections.Long2IntOpenHashMapTest --tests org.apache.pulsar.common.util.collections.Long2ObjectOpenHashMapTest --tests org.apache.pulsar.common.util.collections.Int2ObjectOpenHashMapTest --tests org.apache.pulsar.common.util.collections.HashSetTest -PtestRetryCount=0
  • ./gradlew :pulsar-common:checkstyleTest
  • ./gradlew :pulsar-common:test --tests 'org.apache.pulsar.common.util.collections.*' -PtestRetryCount=0
  • ./gradlew :pulsar-common:test --rerun-tasks --tests org.apache.pulsar.common.util.collections.Long2IntOpenHashMapTest --tests org.apache.pulsar.common.util.collections.Long2ObjectOpenHashMapTest --tests org.apache.pulsar.common.util.collections.Int2ObjectOpenHashMapTest --tests org.apache.pulsar.common.util.collections.HashSetTest --tests org.apache.pulsar.common.util.collections.TripleLongPriorityQueueTest -PtestRetryCount=0 -Dpulsar.collections.randomSeed=123456789

@void-ptr974 void-ptr974 changed the title [test][common] Add collection correctness tests [test][common] Harden primitive collection correctness with oracle-backed tests Jun 13, 2026
@void-ptr974 void-ptr974 force-pushed the test/collections-correctness-tests-pr branch from 8573556 to 7eba30c Compare June 13, 2026 12:52
@void-ptr974 void-ptr974 marked this pull request as ready for review June 13, 2026 12:54
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.

1 participant