Skip to content

[improve][test] Add HBase sink integration test#104

Merged
david-streamlio merged 2 commits into
apache:masterfrom
david-streamlio:test/hbase-integration
Jul 10, 2026
Merged

[improve][test] Add HBase sink integration test#104
david-streamlio merged 2 commits into
apache:masterfrom
david-streamlio:test/hbase-integration

Conversation

@david-streamlio

Copy link
Copy Markdown
Contributor

Fixes #51

Motivation

The HBase sink had only a mock-based unit test (HbaseGenericRecordSinkTest); nothing exercised it against a real HBase server. This adds the first integration test, verified green on a Linux x86-64 host.

Modifications

  • Add HbaseGenericRecordSinkIntegrationTest: starts an all-in-one HBase container (harisekhon/hbase:2.1) via Testcontainers, creates the table, writes a record through HbaseGenericRecordSink, polls until the background flush lands, and reads the row back with the HBase client. A never-written row is asserted absent as a non-vacuous guard.
  • Add testImplementation(libs.testcontainers) to hbase/build.gradle.kts.

The test uses host networking, which works on Linux only: HBase's RegionServer advertises its own host/port through ZooKeeper and the client dials it directly, so the advertised address must be reachable from the test JVM. The all-in-one HBase images are also amd64-only. Depends on the opentelemetry-semconv pin from #102 (already merged); without it the sink throws NoClassDefFoundError on its first HBase call.

Verifying this change

Run on Linux x86-64 (Ubuntu 24.04, Docker 29.1.3, OpenJDK 21):

$ ./gradlew :hbase:test --tests "*HbaseGenericRecordSinkIntegrationTest" --rerun-tasks

Gradle suite > Gradle test > org.apache.pulsar.io.hbase.sink.HbaseGenericRecordSinkIntegrationTest > testWriteRecordIsPersistedToHbase PASSED

BUILD SUCCESSFUL in 36s

Mutation check (test is not vacuous): with the read-back assertion deliberately broken, the test fails against the value actually stored in HBase, then passes again after reverting:

Gradle suite > Gradle test > org.apache.pulsar.io.hbase.sink.HbaseGenericRecordSinkIntegrationTest > testWriteRecordIsPersistedToHbase FAILED
    java.lang.AssertionError: expected [WRONG_value_mutation_check] but found [name_value]

Documentation

  • doc-not-needed (test-only change)

Fixes apache#51

Add the first integration test for the HBase sink,
HbaseGenericRecordSinkIntegrationTest. It starts an all-in-one HBase
container (harisekhon/hbase:2.1) via Testcontainers, creates the table,
writes a record through HbaseGenericRecordSink, polls until the flush
lands, and reads the row back with the HBase client. A never-written row
is asserted absent as a non-vacuous guard.

The test uses host networking, which works on Linux only: HBase's
RegionServer advertises its own host/port through ZooKeeper and the
client dials it directly, so the advertised address must be reachable
from the test JVM. The all-in-one images are also amd64-only.

Depends on the opentelemetry-semconv pin from apache#102 (already merged);
without it the sink throws NoClassDefFoundError on the first HBase
call.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds the first real integration coverage for the HBase sink connector by exercising HbaseGenericRecordSink against a Testcontainers-managed HBase instance, validating that written records are actually persisted and readable via the HBase client.

Changes:

  • Added HbaseGenericRecordSinkIntegrationTest that boots an HBase container, creates the target table, writes a record via the sink, and reads it back to assert persisted values.
  • Added a non-vacuous guard assertion ensuring an unwritten row is absent.
  • Added testImplementation(libs.testcontainers) to the hbase module.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hbase/src/test/java/org/apache/pulsar/io/hbase/sink/HbaseGenericRecordSinkIntegrationTest.java New Testcontainers-backed integration test that writes through the sink and reads back via HBase client.
hbase/build.gradle.kts Adds the Testcontainers dependency required by the new integration test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +99 to +106
public void setUp() throws Exception {
// Host networking (Linux only): binds HBase's ports on localhost so the RegionServer address
// advertised through ZooKeeper is reachable from this JVM.
hbase = new GenericContainer<>(HBASE_IMAGE)
.withNetworkMode("host")
.waitingFor(Wait.forLogMessage(".*Master has completed initialization.*", 1))
.withStartupTimeout(Duration.ofMinutes(4));
hbase.start();
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@david-streamlio david-streamlio merged commit 23a8961 into apache:master Jul 10, 2026
4 checks passed
@david-streamlio david-streamlio deleted the test/hbase-integration branch July 10, 2026 23:28
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.

[improve][test] Add integration tests for the HBase sink connector

2 participants