Skip to content

[improve][test] Add randomized TripleLongPriorityQueue correctness test#26022

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

[improve][test] Add randomized TripleLongPriorityQueue correctness test#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

TripleLongPriorityQueue relies on heap ordering across three long fields. The existing tests cover basic ordering cases, and this adds broader randomized coverage with a reproducible seed for interleaved add/pop sequences.

Modifications

  • Add a randomized interleaved add/pop test against a JDK PriorityQueue oracle.
  • Include edge-case tuple values such as Long.MIN_VALUE and Long.MAX_VALUE.
  • Print the randomized test seed and support reproducing failures with -Dpulsar.collections.randomSeed=<seed>.

Verification

  • ./gradlew :pulsar-common:test --tests org.apache.pulsar.common.util.collections.TripleLongPriorityQueueTest -PtestRetryCount=0 -Dpulsar.collections.randomSeed=123456789
  • ./gradlew :pulsar-common:checkstyleTest

@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
@void-ptr974 void-ptr974 changed the title [test][common] Harden primitive collection correctness with oracle-backed tests [improve][test] Harden primitive collection correctness with oracle-backed tests Jun 15, 2026

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Related to #26028 (review), once we restore fastutil, we can rely on that implementation which has been battle tested over the years.

@lhotari

lhotari commented Jun 15, 2026

Copy link
Copy Markdown
Member

PR to restore fastutil is #26032

@lhotari

lhotari commented Jun 16, 2026

Copy link
Copy Markdown
Member

@void-ptr974 #26032 has been merged. Please rebase. I guess tests for removed classes are now unnecessary, but this PR does contain tests for classes that remain so it will be useful.

@void-ptr974 void-ptr974 force-pushed the test/collections-correctness-tests-pr branch from 7eba30c to 071b358 Compare June 17, 2026 00:43
@void-ptr974 void-ptr974 changed the title [improve][test] Harden primitive collection correctness with oracle-backed tests [improve][test] Add randomized TripleLongPriorityQueue correctness test Jun 17, 2026
@void-ptr974

Copy link
Copy Markdown
Contributor Author

Thanks for the heads-up.

I removed the tests for the classes that no longer exist, so this PR now just adds the randomized coverage for TripleLongPriorityQueue.

long seed = configuredSeed != null ? Long.parseLong(configuredSeed) : ThreadLocalRandom.current().nextLong();
String message = TripleLongPriorityQueueTest.class.getSimpleName() + "." + testName + " seed=" + seed;
Reporter.log(message, true);
System.err.println(message);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove logging to System.err

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed the System.err logging.

@void-ptr974 void-ptr974 force-pushed the test/collections-correctness-tests-pr branch from 071b358 to bebd0eb Compare June 17, 2026 14:17
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