@@ -44,7 +44,7 @@ public class KafkaRebalanceAssemblyOperatorProgressTest extends AbstractKafkaReb
44
44
@ Test
45
45
public void testProgressFieldsDuringRebalanceLifecycle (VertxTestContext context ) throws IOException , URISyntaxException {
46
46
cruiseControlServer .setupCCRebalanceResponse (1 , CruiseControlEndpoints .REBALANCE , "true" );
47
- cruiseControlServer .setupCCStateResponse (0 , 1 );
47
+ cruiseControlServer .setupCCStateResponse (0 , 1 , null , 0 );
48
48
cruiseControlServer .setupCCUserTasksResponseNoGoals (0 , 0 );
49
49
50
50
KafkaRebalance kr = createKafkaRebalance (namespace , CLUSTER_NAME , RESOURCE_NAME , EMPTY_KAFKA_REBALANCE_SPEC , true );
@@ -60,8 +60,8 @@ public void testProgressFieldsDuringRebalanceLifecycle(VertxTestContext context)
60
60
// Check resource is in Pending state.
61
61
assertState (context , client , namespace , RESOURCE_NAME , KafkaRebalanceState .PendingProposal );
62
62
configMapOperator .getAsync (namespace , RESOURCE_NAME )
63
- .onComplete (config -> {
64
- assertThat (config , nullValue ());
63
+ .onComplete (configMap -> {
64
+ assertThat (configMap , nullValue ());
65
65
});
66
66
}))
67
67
.compose (v -> krao .reconcile (new Reconciliation ("test-trigger" , KafkaRebalance .RESOURCE_KIND , namespace , kr .getMetadata ().getName ())))
@@ -119,7 +119,7 @@ public void testProgressFieldsDuringRebalanceLifecycle(VertxTestContext context)
119
119
public void testWarningConditionPropagation (VertxTestContext context ) throws IOException , URISyntaxException {
120
120
cruiseControlServer .setupCCRebalanceResponse (0 , CruiseControlEndpoints .REBALANCE , "true" );
121
121
cruiseControlServer .setupCCUserTasksResponseNoGoals (0 , 1 );
122
- cruiseControlServer .setupCCStateResponse (3 , 0 );
122
+ cruiseControlServer .setupCCStateResponse (0 , 0 , 1 , 2 );
123
123
124
124
KafkaRebalance kr = createKafkaRebalance (namespace , CLUSTER_NAME , RESOURCE_NAME , EMPTY_KAFKA_REBALANCE_SPEC , true );
125
125
Crds .kafkaRebalanceOperation (client ).inNamespace (namespace ).resource (kr ).create ();
@@ -179,6 +179,65 @@ public void testWarningConditionPropagation(VertxTestContext context) throws IOE
179
179
}));
180
180
}
181
181
182
- // TODO: Add test to check progress fields after rebalance failure.
182
+ /**
183
+ * Test to check progress fields after rebalance failure.
184
+ */
185
+ @ Test
186
+ public void testProgressFieldsOnRebalanceFailure (VertxTestContext context ) throws IOException , URISyntaxException {
187
+ cruiseControlServer .setupCCRebalanceResponse (0 , CruiseControlEndpoints .REBALANCE , "true" );
188
+ cruiseControlServer .setupCCUserTasksResponseNoGoals (0 , 0 , 1 );
189
+ cruiseControlServer .setupCCStateResponse (0 , 1 , null , 0 );
190
+
191
+ KafkaRebalance kr = createKafkaRebalance (namespace , CLUSTER_NAME , RESOURCE_NAME , EMPTY_KAFKA_REBALANCE_SPEC , true );
192
+ Crds .kafkaRebalanceOperation (client ).inNamespace (namespace ).resource (kr ).create ();
193
+ crdCreateKafka ();
194
+ crdCreateCruiseControlSecrets ();
195
+
196
+ ConfigMapOperator configMapOperator = this .supplier .configMapOperations ;
197
+
198
+ Checkpoint checkpoint = context .checkpoint ();
199
+ krao .reconcile (new Reconciliation ("test-trigger" , KafkaRebalance .RESOURCE_KIND , namespace , kr .getMetadata ().getName ()))
200
+ .onComplete (context .succeeding (v -> {
201
+ // Check resource moved from New to ProposalReady state.
202
+ assertState (context , client , namespace , RESOURCE_NAME , KafkaRebalanceState .ProposalReady );
203
+ }))
204
+ .compose (v -> krao .reconcile (new Reconciliation ("test-trigger" , KafkaRebalance .RESOURCE_KIND , namespace , RESOURCE_NAME )))
205
+ .onComplete (context .succeeding (v -> {
206
+ // Check resource moved from ProposalReady to Rebalancing state.
207
+ assertState (context , client , namespace , RESOURCE_NAME , KafkaRebalanceState .Rebalancing );
208
+
209
+ KafkaRebalance kafkaRebalance = Crds .kafkaRebalanceOperation (client ).inNamespace (namespace ).withName (RESOURCE_NAME ).get ();
210
+ KafkaRebalanceStatus status = kafkaRebalance .getStatus ();
211
+ assertThat (status .getProgress ().containsKey (REBALANCE_PROGRESS_CONFIG_MAP_KEY ), is (Boolean .TRUE ));
212
+
213
+ configMapOperator .getAsync (namespace , RESOURCE_NAME )
214
+ .onSuccess (configMap -> {
215
+ Map <String , String > fields = configMap .getData ();
216
+ assertThat (fields .containsKey (ESTIMATED_TIME_TO_COMPLETION_KEY ), is (Boolean .TRUE ));
217
+ assertThat (fields .containsKey (COMPLETED_BYTE_MOVEMENT_KEY ), is (Boolean .TRUE ));
218
+ assertThat (fields .containsKey (EXECUTOR_STATE_KEY ), is (Boolean .TRUE ));
219
+ assertThat (fields .containsKey (BROKER_LOAD_KEY ), is (Boolean .TRUE ));
220
+ });
221
+
222
+ }))
223
+ .compose (v -> krao .reconcile (new Reconciliation ("test-trigger" , KafkaRebalance .RESOURCE_KIND , namespace , RESOURCE_NAME )))
224
+ .onComplete (context .succeeding (v -> {
225
+ // Check resource moved from Rebalancing to NotReady state.
226
+ assertState (context , client , namespace , RESOURCE_NAME , KafkaRebalanceState .NotReady );
227
+
228
+ configMapOperator .getAsync (namespace , RESOURCE_NAME )
229
+ .onSuccess (configMap -> {
230
+ Map <String , String > fields = configMap .getData ();
231
+ System .out .println (fields );
232
+ assertThat (fields .containsKey (ESTIMATED_TIME_TO_COMPLETION_KEY ), is (Boolean .FALSE ));
233
+ assertThat (fields .containsKey (COMPLETED_BYTE_MOVEMENT_KEY ), is (Boolean .TRUE ));
234
+ assertThat (fields .containsKey (EXECUTOR_STATE_KEY ), is (Boolean .TRUE ));
235
+ assertThat (fields .containsKey (BROKER_LOAD_KEY ), is (Boolean .TRUE ));
236
+ });
237
+
238
+ checkpoint .flag ();
239
+ }));
240
+ }
241
+
183
242
// TODO: Add test for when CC provides malformed executor state data
184
243
}
0 commit comments