Skip to content

test_utils/container_ostream: delegate to fmt::print#30426

Open
travisdowns wants to merge 1 commit intoredpanda-data:devfrom
travisdowns:td-container-ostream-fmt-print
Open

test_utils/container_ostream: delegate to fmt::print#30426
travisdowns wants to merge 1 commit intoredpanda-data:devfrom
travisdowns:td-container-ostream-fmt-print

Conversation

@travisdowns
Copy link
Copy Markdown
Member

@travisdowns travisdowns commented May 8, 2026

Follow-up to #30415 addressing review feedback.

Replace the hand-rolled element iteration in the std::vector and
std::unordered_map operator<< overloads in test_utils/container_ostream.h
with fmt::print, which already knows how to format ranges. This requires
elements to be fmt-formattable, so the two test-local types that
previously had only operator<< — test_struct in field_parser_test and
serialization_format in httpd — are converted to the format_to
convention; they pick up the auto-generated fmt::formatter from
base/format_to.h, and the existing operator<< call sites still work via
the blanket overload there.

This changes the logging format because fmt does things differently but this is test-only so I think it's OK.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v25.3.x
  • v25.2.x
  • v25.1.x

Release notes

  • none

Replace the hand-rolled element iteration in the std::vector and
std::unordered_map operator<< overloads with fmt::print, which already
knows how to format ranges.  This requires elements to be
fmt-formattable, so the two test-local types that previously had only
operator<< — test_struct in field_parser_test and serialization_format
in httpd — are converted to the format_to convention; they pick up the
auto-generated fmt::formatter from base/format_to.h and the existing
operator<< call sites still work via Stephan's blanket overload.
Copilot AI review requested due to automatic review settings May 8, 2026 20:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates the test-only container streaming utilities to use {fmt}’s built-in range formatting instead of manually iterating container elements, and adjusts a couple of test-local types to be {fmt}-formattable so existing assertion streaming continues to work.

Changes:

  • Switch std::vector and std::unordered_map operator<< overloads in test_utils/container_ostream.h to delegate to fmt::print.
  • Update expected strings in container_ostream_test.cc to match {fmt}’s default range/map formatting (e.g., [] for vectors, quoted strings in ranges).
  • Convert two test-local types (Kafka test_struct, Pandaproxy serialization_format) from operator<< to format_to so they participate in base/format_to.h’s auto fmt::formatter / operator<< bridging.

Reviewed changes

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

Show a summary per file
File Description
src/v/test_utils/tests/container_ostream_test.cc Updates golden outputs to match {fmt} range/map formatting and removes the “stream-only element” test case.
src/v/test_utils/container_ostream.h Implements test-only operator<< for std::vector/std::unordered_map via fmt::print and adds required {fmt} includes.
src/v/test_utils/BUILD Adds @fmt dependency for the container_ostream test library.
src/v/pandaproxy/parsing/test/httpd.cc Replaces operator<< for serialization_format with an ADL format_to free function.
src/v/pandaproxy/parsing/test/BUILD Adds dependencies needed for the new format_to usage (//src/v/base, @fmt).
src/v/kafka/protocol/tests/field_parser_test.cc Replaces operator<< for test_struct with a format_to member method.
src/v/kafka/protocol/tests/BUILD Adds dependencies needed for the new format_to usage (//src/v/base, @fmt).

@vbotbuildovich
Copy link
Copy Markdown
Collaborator

CI test results

test results on build#84239
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FLAKY(PASS) ClusterQuotaPartitionMutationTest test_partition_throttle_mechanism null integration https://buildkite.com/redpanda/redpanda/builds/84239#019e094b-a391-4ec1-879e-edf595fab858 19/21 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0043, p0=0.0824, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3917, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=ClusterQuotaPartitionMutationTest&test_method=test_partition_throttle_mechanism

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants