Skip to content

MINOR: Change LogCompactionTester topics parameter to Set<String> #20372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 22, 2025

Conversation

yunchipang
Copy link
Contributor

@yunchipang yunchipang commented Aug 18, 2025

issue: #19905 (comment)

What: Change String[] topics to Set<String> topics throughout
LogCompactionTester. Why: Set<String> is more modern and reduces the
need for array-to-collection conversions.

Reviewers: Ken Huang s7133700@gmail.com, TengYao Chi
kitingiao@gmail.com, Jhen-Yung Hsu jhenyunghsu@gmail.com, Lan Ding
isDing_L@163.com, Kuan-Po Tseng brandboat@gmail.com, Chia-Ping
Tsai chia7712@gmail.com

@github-actions github-actions bot added triage PRs from the community tools small Small PRs labels Aug 18, 2025
@yunchipang
Copy link
Contributor Author

test log

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/kafka-dev/core/build/dependant-testlibs/log4j-slf4j-impl-2.24.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/kafka-dev/tools/build/dependant-libs-2.13.16/log4j-slf4j-impl-2.24.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Producing 1000000 messages..to topics log-cleaner-test--5661911372922944212-0
Logging produce requests to /tmp/kafka-log-cleaner-produced-13037492074713603521.txt
Sleeping for 20seconds...
Consuming messages...
Logging consumed messages to /tmp/kafka-log-cleaner-consumed-6843967367886408887.txt
1000000 rows of data produced, 120183 rows of data consumed (88.0% reduction).
De-duplicating and validating output files...
Validated 89943 values, 0 mismatches.
Data verification is completed

Copy link
Collaborator

@Yunyung Yunyung left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Some comments left

Comment on lines +251 to +253
Set<String> topics = IntStream.range(0, topicCount)
.mapToObj(i -> "log-cleaner-test-" + testId + "-" + i)
.toArray(String[]::new);
.collect(toCollection(LinkedHashSet::new));
Copy link
Collaborator

@m1a2st m1a2st Aug 19, 2025

Choose a reason for hiding this comment

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

Why don’t we use a List? I think a List is more convenient than a Set when we need to retrieve elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@m1a2st thanks for the review! I totally agree with List would be more convenient for indexed access, but Set is preferred here because

  1. semantic clarity: topics represents a collection of unique topic names
  2. duplicate prevention: Set protects against duplicate topics by accident

Copy link
Member

@brandboat brandboat left a comment

Choose a reason for hiding this comment

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

LGTM, e2e test result seems good.

[INFO:2025-08-18 18:18:23,475]: starting test run with session id 2025-08-18--002...
[INFO:2025-08-18 18:18:23,475]: running 1 tests...
[INFO:2025-08-18 18:18:23,475]: Triggering test 1 of 1...
[INFO:2025-08-18 18:18:23,480]: RunnerClient: Loading test {'directory': '/opt/kafka-dev/tests/kafkatest/tests/tools', 'file_name': 'log_compaction_test.py', 'cls_name': 'LogCompactionTest', 'method_name': 'test_log_compaction', 'injected_args': {'metadata_quorum': 'ISOLATED_KRAFT'}}
[INFO:2025-08-18 18:18:23,481]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: on run 1/1
[INFO:2025-08-18 18:18:23,482]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: Setting up...
[INFO:2025-08-18 18:18:23,482]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: Running...
[INFO:2025-08-18 18:19:13,711]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: Tearing down...
[INFO:2025-08-18 18:19:18,607]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: PASS
[WARNING - 2025-08-18 18:19:18,607 - runner_client - log - lineno:459]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: Test requested 4 nodes, used only 3
[WARNING:2025-08-18 18:19:18,607]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: Test requested 4 nodes, used only 3
[INFO:2025-08-18 18:19:18,608]: RunnerClient: kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT: Data: None
================================================================================
SESSION REPORT (ALL TESTS)
ducktape version: 0.12.0
session_id:       2025-08-18--002
run time:         55.240 seconds
tests run:        1
passed:           1
flaky:            0
failed:           0
ignored:          0
================================================================================
test_id:    kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT
status:     PASS
run time:   55.126 seconds
--------------------------------------------------------------------------------

@github-actions github-actions bot removed the triage PRs from the community label Aug 19, 2025
Copy link
Contributor

@DL1231 DL1231 left a comment

Choose a reason for hiding this comment

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

Thanks for the patch, LGTM.

Copy link
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@chia7712 chia7712 merged commit 511818e into apache:trunk Aug 22, 2025
28 checks passed
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.

7 participants