merlimat opened a new pull request, #25311:
URL: https://github.com/apache/pulsar/pull/25311

   ## 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
   
   ### `NullValueTest` converted as proof-of-concept
   - Switched from `BrokerTestBase` (full service per class) to 
`SharedPulsarBaseTest`
   - Replaced hardcoded topic names with `newTopicName()`
   - Fixed raw types (`Producer` → `Producer<byte[]>`, etc.)
   - Fixed `assertEquals` argument order (expected vs actual)
   
   ## Test Timing
   
   | | Before | After |
   |---|---|---|
   | `NullValueTest` | ~31s | ~4s |
   
   The ~3s singleton initialization cost is amortized across all test classes 
that extend `SharedPulsarBaseTest`, meaning additional converted tests add 
near-zero overhead.
   
   ## Verifying this change
   
   `NullValueTest` — all 8 test invocations pass (4 methods × 2 partition 
configs).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to