Skip to content

Improve test coverage for batch operations plus a NPE fix for empty JDBC batch operations#19037

Merged
trask merged 2 commits into
open-telemetry:mainfrom
trask:improve-batch-operation-test-coverage
Jun 19, 2026
Merged

Improve test coverage for batch operations plus a NPE fix for empty JDBC batch operations#19037
trask merged 2 commits into
open-telemetry:mainfrom
trask:improve-batch-operation-test-coverage

Conversation

@trask

@trask trask commented Jun 18, 2026

Copy link
Copy Markdown
Member

Broaden current-behavior batch operation coverage for JDBC, R2DBC, and Vert.x SQL while preserving the DB batch semantics currently on main. The tests pin empty-batch span naming, single-operation batch behavior, and existing stable-semconv batch-size expectations before the core DB batch semantic changes land (open-telemetry/semantic-conventions#3811); the PR also includes the JDBC javaagent empty executeBatch() NPE fix needed for that coverage.

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

This PR adds broader batch operation test coverage across JDBC, R2DBC, Vert.x SQL, and Lettuce instrumentation modules, while preserving current shared DB batch semantics. It also includes a narrow JDBC javaagent fix for a potential NPE when executeBatch() is called with an empty batch (no addBatch() calls).

Changes:

  • Refactored batch tests across JDBC, R2DBC, and Vert.x SQL into parameterized tests using BatchScenario builder classes, covering empty, single-statement, multi-statement-same-operation, and multi-statement-different-operation batch cases under both old and stable database semconv.
  • Fixed a JDBC javaagent NPE in JdbcAdviceScope.createBatchRequest() when executeBatch() is called with no prior addBatch() calls — now creates a DbRequest with an empty query text list and batchSize = 0L instead of passing null query text.
  • Added Lettuce deferred-flush (pipeline) batch tests and changed testCancelCommandBeforeItFinishes to use hasSpansSatisfyingExactlyInAnyOrder to handle non-deterministic span ordering.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcAdviceScope.java NPE fix: empty executeBatch() now creates a valid DbRequest with emptyList() and batchSize=0L
instrumentation/jdbc/testing/src/main/java/.../AbstractJdbcInstrumentationTest.java Replaces testBatch/testMultiBatch/testSingleItemBatch with parameterized testStatementBatch using BatchScenario
instrumentation/r2dbc-1.0/testing/src/main/java/.../AbstractR2dbcStatementTest.java Replaces testBatchQueries with parameterized batchQueries covering 4 batch scenarios under both semconv modes
instrumentation/r2dbc-1.0/library/src/test/java/.../DbExecutionTest.java Adds ExecutionType.BATCH to mock setup and adds dbExecutionWithEmptyBatch unit test
instrumentation/r2dbc-1.0/library/src/test/java/.../R2dbcSqlAttributesGetterTest.java Adds ExecutionType.BATCH to batch mock setup
instrumentation/vertx/.../v4_0/VertxSqlClientTest.java Parameterized testBatch with BatchScenario covering empty, single, and multi-statement batches
instrumentation/vertx/.../v5_0/VertxSqlClientTest.java Same parameterized testBatch pattern for Vert.x 5.0 (different error type for empty batch)
instrumentation/lettuce/.../v4_0/LettuceAsyncClientTest.java Adds deferred-flush batch tests; changes cancel test to InAnyOrder assertions
instrumentation/lettuce/.../v5_0/LettuceAsyncClientTest.java Same deferred-flush batch tests and cancel test ordering fix for Lettuce 5.0

@trask trask force-pushed the improve-batch-operation-test-coverage branch 2 times, most recently from b2f5828 to 60f4444 Compare June 19, 2026 16:23
@trask trask force-pushed the improve-batch-operation-test-coverage branch from 60f4444 to dff0496 Compare June 19, 2026 16:35
@trask trask requested a review from Copilot June 19, 2026 17:08
@trask trask changed the title Improve test coverage for batch operations Improve test coverage for batch operations plus a NPE fix for empty JDBC batch operations Jun 19, 2026

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

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

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@trask trask marked this pull request as ready for review June 19, 2026 18:32
@trask trask requested a review from a team as a code owner June 19, 2026 18:32
@trask trask merged commit 47d7374 into open-telemetry:main Jun 19, 2026
95 checks passed
@trask trask deleted the improve-batch-operation-test-coverage branch June 19, 2026 19:08
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