GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [improve][test] Introduce shared Pulsar cluster for faster integration tests by merlimat · Pull Request #25311 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Mar 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Motivation

Many broker integration tests start a full Pulsar service (broker + bookie + metadata store) per test class — or even per test method. This is extremely slow and resource-intensive. For example, NullValueTest previously took ~31 seconds, with almost all of that time spent on service startup and shutdown rather than the actual test logic.

Modifications

Introduces two new test infrastructure classes:

SharedPulsarCluster

A JVM-wide singleton that manages a lightweight Pulsar cluster:

  • Single bookie with DbLedgerStorage, no journal sync/writes, minimal RocksDB cache, and UnpooledHeap allocator for low memory footprint
  • Single broker with in-memory metadata store (no ZooKeeper dependency)
  • JVM shutdown hook that closes everything and deletes all temporary bookie data directories
  • Default test-cluster and test-tenant pre-created at startup

SharedPulsarBaseTest

Base class for tests that use the shared cluster:

  • @BeforeClass initializes admin and pulsarClient from the singleton (once per class)
  • @BeforeMethod creates a unique namespace per test method for full isolation
  • @AfterMethod force-deletes the namespace (cascading to all topics)
  • newTopicName() helper generates unique topic names within the test namespace

Converted test

  • NullValueTest — first proof-of-concept conversion, replacing BrokerTestBase with SharedPulsarBaseTest

Test Timing

With the shared cluster, NullValueTest runs in ~4 seconds (including ~3s singleton init on first use), compared to ~31 seconds when it started its own service.

Verifying this change

All 8 test invocations pass (4 test methods × 2 data provider params):

mvn test -pl pulsar-broker -Dtest=NullValueSharedTest -DfailIfNoTests=false
  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
[improve][test] Introduce shared Pulsar cluster singleton for faster …
7ca8614
…integration tests

Many broker integration tests start a full Pulsar service (broker + bookie +
metadata store) per test class or even per test method. This is extremely
slow and resource-intensive — for example, NullValueTest previously took
~31 seconds, with almost all of that time spent on service startup/shutdown.

This change introduces SharedPulsarCluster, a JVM-wide singleton that
starts a single lightweight Pulsar cluster (one bookie, one broker, in-memory
metadata store) and reuses it across all tests that extend SharedPulsarBaseTest.
Each test method gets its own namespace (created in @BeforeMethod, force-deleted
in @AfterMethod) for full isolation without the startup overhead.

Key design decisions:
- In-memory metadata store (no ZooKeeper dependency)
- Single bookie with DbLedgerStorage, no journal sync/writes, minimal
  RocksDB cache, and UnpooledHeap allocator for low memory footprint
- JVM shutdown hook deletes all temporary bookie data directories
- Per-test namespace isolation with force-delete cleanup
- PulsarAdmin and PulsarClient initialized once per test class

NullValueTest is converted as the first proof-of-concept:
- Before: ~31s (full service start/stop per class)
- After: ~4s (~3s for singleton init on first use, amortized across classes)
@merlimat
merlimat requested review from codelipenghui, congbobo184, lhotari and poorbarcode March 11, 2026 16:11
@merlimat merlimat added the ready-to-test label Mar 11, 2026
@merlimat merlimat self-assigned this Mar 11, 2026
@merlimat merlimat added the area/test label Mar 11, 2026
@github-actions github-actions Bot added the doc-label-missing label Mar 11, 2026
@apache apache deleted a comment from github-actions Bot Mar 11, 2026
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Mar 11, 2026
@merlimat
merlimat force-pushed the claude/trusting-stonebraker branch from af7d783 to 7ca8614 Compare March 11, 2026 16:41
@codecov-commenter

codecov-commenter commented Mar 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.66%. Comparing base (6c357f6) to head (7ca8614).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #25311      +/-   ##
============================================
+ Coverage     72.54%   72.66%   +0.12%     
+ Complexity    34627    34242     -385     
============================================
  Files          1967     1967              
  Lines        156326   156326              
  Branches      17812    17812              
============================================
+ Hits         113409   113598     +189     
+ Misses        33814    33652     -162     
+ Partials       9103     9076      -27     
Flag Coverage Δ
inttests 25.59% <ø> (?)
systests 22.26% <ø> (-0.09%) ⬇️
unittests 73.63% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 89 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lhotari
lhotari approved these changes Mar 12, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. Just added a comment of later reuse in Junit Jupiter tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SharedPulsarBaseTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SharedPulsarBaseTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

merlimat added 4 commits March 12, 2026 14:32
@merlimat
Lower all number of threads
dfb86ea
@merlimat
Merge remote-tracking branch 'apache/master' into claude/trusting-sto…
4494918
…nebraker
@merlimat
Add helper methods to SharedPulsarBaseTest and tune SharedPulsarCluster
f08b0cb
Add convenience methods to SharedPulsarBaseTest for accessing broker internals
(getConfig, getBrokerServiceUrl, getWebServiceUrl, newPulsarClient, getSchemaStorage,
getTopicReference, getTopic, getTopicIfExists) needed by converted test classes.

Tune SharedPulsarCluster: increase BK cache/write-buffer sizes to avoid
flaky failures under load and disable inactive topic deletion.
@merlimat
Import order
c31cbc0
@merlimat
merlimat merged commit ce5bc13 into apache:master Mar 13, 2026
101 of 103 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@merlimat
merlimat deleted the claude/trusting-stonebraker branch March 13, 2026 04:54
@merlimat merlimat mentioned this pull request Mar 13, 2026
[cleanup] Convert 15 test classes to SharedPulsarBaseTest #25318
Merged
1 of 6 tasks
@lhotari lhotari added this to the 4.2.0 milestone Mar 24, 2026
@dao-jun dao-jun mentioned this pull request Oct 5, 2026
[feat][ml] Port batch read and managed-ledger cache improvements (PIP-430) on BK 4.17.4.1 ascentstream/pulsar#105
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari approved these changes
@codelipenghui codelipenghui Awaiting requested review from codelipenghui
@poorbarcode poorbarcode Awaiting requested review from poorbarcode
@congbobo184 congbobo184 Awaiting requested review from congbobo184

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@merlimat merlimat

Labels

area/test doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Milestone

4.2.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@merlimat @codecov-commenter @lhotari
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.