-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-19592: testGenerateAssignmentWithBootstrapServer uses wrong JSON format #20336
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
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
233b2c2
init commit
TaiJuWu 8709a26
fix PartitionReassignmentState.toString
TaiJuWu 6e181b6
make record
TaiJuWu 240ce9c
revert
TaiJuWu 18116c5
remove public identify
TaiJuWu 727efd9
address comments
TaiJuWu afe5c66
address comments
TaiJuWu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,13 +153,18 @@ public void testGenerateAssignmentWithBootstrapServer() throws Exception { | |
| produceMessages(foo0.topic(), foo0.partition(), 100); | ||
|
|
||
| try (Admin admin = Admin.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, clusterInstance.bootstrapServers()))) { | ||
| String assignment = "{\"version\":1,\"partitions\":" + | ||
| "[{\"topic\":\"foo\",\"partition\":0,\"replicas\":[3,1,2],\"log_dirs\":[\"any\",\"any\",\"any\"]}" + | ||
| "]}"; | ||
| generateAssignment(admin, assignment, "1,2,3", false); | ||
| String topicsToMoveJson = "{\"topics\":\n\t[{\"topic\": \"foo\"}],\n\"version\":1\n}"; | ||
| var assignment = generateAssignment(admin, topicsToMoveJson, "1,2,3", false); | ||
| Map<TopicPartition, List<Integer>> proposedAssignments = assignment.getKey(); | ||
| String assignmentJson = String.format("{\"version\":1,\"partitions\":" + | ||
| "[{\"topic\":\"foo\",\"partition\":0,\"replicas\":%s,\"log_dirs\":[\"any\",\"any\",\"any\"]}" + | ||
| "]}", proposedAssignments.get(foo0)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not easy to read. Can we use the text block feature from Java 17? For example: String assignmentJson = String.format("""
{"version":1,"partitions":\
[{"topic":"foo","partition":0,"replicas":%s,"log_dirs":["any","any","any"]}\
]}""", proposedAssignments.get(foo0)); |
||
|
|
||
| runExecuteAssignment(false, assignmentJson, -1L, -1L); | ||
|
|
||
| Map<TopicPartition, PartitionReassignmentState> finalAssignment = Map.of(foo0, | ||
| new PartitionReassignmentState(List.of(0, 1, 2), List.of(3, 1, 2), true)); | ||
| waitForVerifyAssignment(admin, assignment, false, | ||
| new PartitionReassignmentState(proposedAssignments.get(foo0), proposedAssignments.get(foo0), true)); | ||
| waitForVerifyAssignment(admin, assignmentJson, false, | ||
| new VerifyAssignmentResult(finalAssignment)); | ||
| } | ||
| } | ||
|
|
@@ -237,15 +242,15 @@ public void testThrottledReassignment() throws Exception { | |
| // Check the reassignment status. | ||
| VerifyAssignmentResult result = runVerifyAssignment(admin, assignment, true); | ||
|
|
||
| if (!result.partsOngoing) { | ||
| if (!result.partsOngoing()) { | ||
| return true; | ||
| } else { | ||
| assertFalse( | ||
| result.partStates.values().stream().allMatch(state -> state.done), | ||
| result.partStates().values().stream().allMatch(PartitionReassignmentState::done), | ||
| "Expected at least one partition reassignment to be ongoing when result = " + result | ||
| ); | ||
| assertEquals(List.of(0, 3, 2), result.partStates.get(new TopicPartition("foo", 0)).targetReplicas); | ||
| assertEquals(List.of(3, 2, 1), result.partStates.get(new TopicPartition("baz", 2)).targetReplicas); | ||
| assertEquals(List.of(0, 3, 2), result.partStates().get(new TopicPartition("foo", 0)).targetReplicas()); | ||
| assertEquals(List.of(3, 2, 1), result.partStates().get(new TopicPartition("baz", 2)).targetReplicas()); | ||
| waitForInterBrokerThrottle(admin, List.of(0, 1, 2, 3), interBrokerThrottle); | ||
| return false; | ||
| } | ||
|
|
@@ -540,7 +545,7 @@ private void executeAndVerifyReassignment() throws InterruptedException { | |
| finalAssignment.put(bar0, new PartitionReassignmentState(List.of(3, 2, 0), List.of(3, 2, 0), true)); | ||
|
|
||
| VerifyAssignmentResult verifyAssignmentResult = runVerifyAssignment(admin, assignment, false); | ||
| assertFalse(verifyAssignmentResult.movesOngoing); | ||
| assertFalse(verifyAssignmentResult.movesOngoing()); | ||
|
|
||
| // Wait for the assignment to complete | ||
| waitForVerifyAssignment(admin, assignment, false, | ||
|
|
@@ -786,7 +791,7 @@ private void testCancellationAction(boolean useBootstrapServer) throws Interrupt | |
| // This time, the broker throttles were removed. | ||
| waitForBrokerLevelThrottles(admin, unthrottledBrokerConfigs); | ||
| // Verify that there are no ongoing reassignments. | ||
| assertFalse(runVerifyAssignment(admin, assignment, false).partsOngoing); | ||
| assertFalse(runVerifyAssignment(admin, assignment, false).partsOngoing()); | ||
| } | ||
| // Verify that the partition is removed from cancelled replicas | ||
| verifyReplicaDeleted(new TopicPartitionReplica(foo0.topic(), foo0.partition(), 3)); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.