Skip to content

test(spanner): unflake BuiltInMetricsCustomOpenTelemetryTest and BuiltInMetricsBothSinksTest - #14282

Merged
sakthivelmanii merged 1 commit into
mainfrom
unflake-builtin-metrics-custom-opentelemetry-test
Sep 7, 2026
Merged

sakthivelmanii merged 1 commit into
mainfrom
unflake-builtin-metrics-custom-opentelemetry-test

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

In executeSelect1(), resultSet.next() was called only once for SELECT 1. Closing the ResultSet before consuming the stream to EOF invokes iterator.close(), which sends call.cancel("ResultSet closed", null) to the underlying gRPC stream.

If client cancellation races ahead of the mock server's onCompleted(), the stream terminates with Status.CANCELLED. As a result, SpannerTracer.operationSucceeded() is never invoked, omitting Spanner.ExecuteStreamingSql (status OK) from
spanner.googleapis.com/internal/client/operation_count and causing the test assertion to fail.

Consume the ResultSet to EOF (assertFalse(resultSet.next())) in both BuiltInMetricsCustomOpenTelemetryTest and BuiltInMetricsBothSinksTest to guarantee that the stream finishes normally before closing.

…tInMetricsBothSinksTest

In `executeSelect1()`, `resultSet.next()` was called only once for `SELECT 1`.
Closing the `ResultSet` before consuming the stream to EOF invokes
`iterator.close()`, which sends `call.cancel("ResultSet closed", null)` to
the underlying gRPC stream.

If client cancellation races ahead of the mock server's `onCompleted()`, the
stream terminates with `Status.CANCELLED`. As a result,
`SpannerTracer.operationSucceeded()` is never invoked, omitting
`Spanner.ExecuteStreamingSql` (status `OK`) from
`spanner.googleapis.com/internal/client/operation_count` and causing the
test assertion to fail.

Consume the `ResultSet` to EOF (`assertFalse(resultSet.next())`) in both
`BuiltInMetricsCustomOpenTelemetryTest` and `BuiltInMetricsBothSinksTest`
to guarantee that the stream finishes normally before closing.
@sakthivelmanii
sakthivelmanii requested review from a team as code owners September 7, 2026 11:04

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds assertions to verify that the result set has no more elements after reading the first row in Spanner test files. The feedback suggests using Google Truth assertions instead of JUnit assertions in BuiltInMetricsCustomOpenTelemetryTest to maintain consistency with the rest of the codebase.

Comment on lines 81 to +83
assertTrue(resultSet.next());
assertThat(resultSet.getLong(0)).isEqualTo(1L);
assertFalse(resultSet.next());

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.

medium

To maintain consistency with the rest of the assertions in this codebase and avoid mixing different assertion frameworks within the same block, please use Google Truth assertions (assertThat(...).isTrue() and assertThat(...).isFalse()) instead of JUnit's assertTrue and assertFalse. If you apply this change, you can also remove the unused import of org.junit.Assert.assertFalse at line 20.

Suggested change
assertTrue(resultSet.next());
assertThat(resultSet.getLong(0)).isEqualTo(1L);
assertFalse(resultSet.next());
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getLong(0)).isEqualTo(1L);
assertThat(resultSet.next()).isFalse();

@sakthivelmanii
sakthivelmanii enabled auto-merge (squash) September 7, 2026 11:06
@sakthivelmanii
sakthivelmanii merged commit d086ba7 into main Sep 7, 2026
204 checks passed
@sakthivelmanii
sakthivelmanii deleted the unflake-builtin-metrics-custom-opentelemetry-test branch September 7, 2026 11:34
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.

2 participants