@@ -153,13 +153,35 @@ public void testGenerateAssignmentWithBootstrapServer() throws Exception {
153
153
produceMessages (foo0 .topic (), foo0 .partition (), 100 );
154
154
155
155
try (Admin admin = Admin .create (Map .of (CommonClientConfigs .BOOTSTRAP_SERVERS_CONFIG , clusterInstance .bootstrapServers ()))) {
156
- String assignment = "{\" version\" :1,\" partitions\" :" +
157
- "[{\" topic\" :\" foo\" ,\" partition\" :0,\" replicas\" :[3,1,2],\" log_dirs\" :[\" any\" ,\" any\" ,\" any\" ]}" +
158
- "]}" ;
159
- generateAssignment (admin , assignment , "1,2,3" , false );
156
+ String topicsToMoveJson = """
157
+ {
158
+ "topics": [
159
+ { "topic": "foo" }
160
+ ],
161
+ "version": 1
162
+ }
163
+ """ ;
164
+ var assignment = generateAssignment (admin , topicsToMoveJson , "1,2,3" , false );
165
+ Map <TopicPartition , List <Integer >> proposedAssignments = assignment .getKey ();
166
+ String assignmentJson = String .format ("""
167
+ {
168
+ "version": 1,
169
+ "partitions": [
170
+ {
171
+ "topic": "foo",
172
+ "partition": 0,
173
+ "replicas": %s,
174
+ "log_dirs": ["any", "any", "any"]
175
+ }
176
+ ]
177
+ }
178
+ """ , proposedAssignments .get (foo0 ));
179
+
180
+ runExecuteAssignment (false , assignmentJson , -1L , -1L );
181
+
160
182
Map <TopicPartition , PartitionReassignmentState > finalAssignment = Map .of (foo0 ,
161
- new PartitionReassignmentState (List . of ( 0 , 1 , 2 ), List . of ( 3 , 1 , 2 ), true ));
162
- waitForVerifyAssignment (admin , assignment , false ,
183
+ new PartitionReassignmentState (proposedAssignments . get ( foo0 ), proposedAssignments . get ( foo0 ), true ));
184
+ waitForVerifyAssignment (admin , assignmentJson , false ,
163
185
new VerifyAssignmentResult (finalAssignment ));
164
186
}
165
187
}
@@ -237,15 +259,15 @@ public void testThrottledReassignment() throws Exception {
237
259
// Check the reassignment status.
238
260
VerifyAssignmentResult result = runVerifyAssignment (admin , assignment , true );
239
261
240
- if (!result .partsOngoing ) {
262
+ if (!result .partsOngoing () ) {
241
263
return true ;
242
264
} else {
243
265
assertFalse (
244
- result .partStates .values ().stream ().allMatch (state -> state . done ),
266
+ result .partStates () .values ().stream ().allMatch (PartitionReassignmentState :: done ),
245
267
"Expected at least one partition reassignment to be ongoing when result = " + result
246
268
);
247
- assertEquals (List .of (0 , 3 , 2 ), result .partStates .get (new TopicPartition ("foo" , 0 )).targetReplicas );
248
- assertEquals (List .of (3 , 2 , 1 ), result .partStates .get (new TopicPartition ("baz" , 2 )).targetReplicas );
269
+ assertEquals (List .of (0 , 3 , 2 ), result .partStates () .get (new TopicPartition ("foo" , 0 )).targetReplicas () );
270
+ assertEquals (List .of (3 , 2 , 1 ), result .partStates () .get (new TopicPartition ("baz" , 2 )).targetReplicas () );
249
271
waitForInterBrokerThrottle (admin , List .of (0 , 1 , 2 , 3 ), interBrokerThrottle );
250
272
return false ;
251
273
}
@@ -540,7 +562,7 @@ private void executeAndVerifyReassignment() throws InterruptedException {
540
562
finalAssignment .put (bar0 , new PartitionReassignmentState (List .of (3 , 2 , 0 ), List .of (3 , 2 , 0 ), true ));
541
563
542
564
VerifyAssignmentResult verifyAssignmentResult = runVerifyAssignment (admin , assignment , false );
543
- assertFalse (verifyAssignmentResult .movesOngoing );
565
+ assertFalse (verifyAssignmentResult .movesOngoing () );
544
566
545
567
// Wait for the assignment to complete
546
568
waitForVerifyAssignment (admin , assignment , false ,
@@ -786,7 +808,7 @@ private void testCancellationAction(boolean useBootstrapServer) throws Interrupt
786
808
// This time, the broker throttles were removed.
787
809
waitForBrokerLevelThrottles (admin , unthrottledBrokerConfigs );
788
810
// Verify that there are no ongoing reassignments.
789
- assertFalse (runVerifyAssignment (admin , assignment , false ).partsOngoing );
811
+ assertFalse (runVerifyAssignment (admin , assignment , false ).partsOngoing () );
790
812
}
791
813
// Verify that the partition is removed from cancelled replicas
792
814
verifyReplicaDeleted (new TopicPartitionReplica (foo0 .topic (), foo0 .partition (), 3 ));
0 commit comments