Skip to content

Commit b25c22f

Browse files
pthirunclaude
andcommitted
Restructure ULE test cases: restore Case 2, add Cases 3-5 for ULE variants
Restore Case 2 to its original form (topic does not exist, no ULE assertion). Add Case 3 (ULE=false), Case 4 (ULE=true), Case 5 (ULE unset/empty) as separate cases in the same test method. Remove the standalone testCreateOrUpdateRealTimeTopicWithUncleanLeaderElectionUnset method. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5d3b514 commit b25c22f

1 file changed

Lines changed: 34 additions & 22 deletions

File tree

services/venice-controller/src/test/java/com/linkedin/venice/controller/TestVeniceHelixAdmin.java

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,27 @@ public void testCreateOrUpdateRealTimeTopic() {
305305
anyBoolean(),
306306
any(Optional.class));
307307

308-
// Case 2: Real-time topic does not exist, unclean leader election config is set to false
308+
// Case 2: Real-time topic does not exist
309309
VeniceControllerClusterConfig clusterConfig = mock(VeniceControllerClusterConfig.class);
310-
when(clusterConfig.getUncleanLeaderElectionEnableRealTimeTopics()).thenReturn(Optional.of(false));
311310
when(veniceHelixAdmin.getControllerConfig(clusterName)).thenReturn(clusterConfig);
312311
when(topicManager.containsTopic(pubSubTopic)).thenReturn(false);
313312
veniceHelixAdmin.createOrUpdateRealTimeTopic(clusterName, store, version, pubSubTopic);
313+
verify(topicManager, times(1)).createTopic(
314+
eq(pubSubTopic),
315+
eq(partitionCount),
316+
anyInt(),
317+
anyLong(),
318+
anyBoolean(),
319+
any(Optional.class),
320+
anyBoolean(),
321+
anyBoolean(),
322+
any(Optional.class));
323+
324+
// Case 3: Unclean leader election config is set to false
325+
reset(topicManager);
326+
when(clusterConfig.getUncleanLeaderElectionEnableRealTimeTopics()).thenReturn(Optional.of(false));
327+
when(topicManager.containsTopic(pubSubTopic)).thenReturn(false);
328+
veniceHelixAdmin.createOrUpdateRealTimeTopic(clusterName, store, version, pubSubTopic);
314329
verify(topicManager, times(1)).createTopic(
315330
eq(pubSubTopic),
316331
eq(partitionCount),
@@ -321,29 +336,26 @@ public void testCreateOrUpdateRealTimeTopic() {
321336
anyBoolean(),
322337
anyBoolean(),
323338
eq(Optional.of(false)));
324-
}
325339

326-
@Test
327-
public void testCreateOrUpdateRealTimeTopicWithUncleanLeaderElectionUnset() {
328-
int partitionCount = 10;
329-
Store store = mock(Store.class, RETURNS_DEEP_STUBS);
330-
when(store.getName()).thenReturn(storeName);
331-
Version version = mock(Version.class);
332-
when(version.getStoreName()).thenReturn(storeName);
333-
when(version.getPartitionCount()).thenReturn(partitionCount);
334-
PubSubTopicRepository pubSubTopicRepository = new PubSubTopicRepository();
335-
PubSubTopic pubSubTopic = pubSubTopicRepository.getTopic(storeName + "_rt");
336-
TopicManager topicManager = mock(TopicManager.class);
337-
VeniceHelixAdmin veniceHelixAdmin = mock(VeniceHelixAdmin.class);
338-
when(veniceHelixAdmin.getTopicManager()).thenReturn(topicManager);
339-
doCallRealMethod().when(veniceHelixAdmin)
340-
.createOrUpdateRealTimeTopic(eq(clusterName), eq(store), eq(version), any(PubSubTopic.class));
341-
when(veniceHelixAdmin.getPubSubTopicRepository()).thenReturn(pubSubTopicRepository);
340+
// Case 4: Unclean leader election config is set to true
341+
reset(topicManager);
342+
when(clusterConfig.getUncleanLeaderElectionEnableRealTimeTopics()).thenReturn(Optional.of(true));
343+
when(topicManager.containsTopic(pubSubTopic)).thenReturn(false);
344+
veniceHelixAdmin.createOrUpdateRealTimeTopic(clusterName, store, version, pubSubTopic);
345+
verify(topicManager, times(1)).createTopic(
346+
eq(pubSubTopic),
347+
eq(partitionCount),
348+
anyInt(),
349+
anyLong(),
350+
anyBoolean(),
351+
any(Optional.class),
352+
anyBoolean(),
353+
anyBoolean(),
354+
eq(Optional.of(true)));
342355

343-
// When unclean leader election config is not set, Optional.empty() should be passed
344-
VeniceControllerClusterConfig clusterConfig = mock(VeniceControllerClusterConfig.class);
356+
// Case 5: Unclean leader election config is not set (empty)
357+
reset(topicManager);
345358
when(clusterConfig.getUncleanLeaderElectionEnableRealTimeTopics()).thenReturn(Optional.empty());
346-
when(veniceHelixAdmin.getControllerConfig(clusterName)).thenReturn(clusterConfig);
347359
when(topicManager.containsTopic(pubSubTopic)).thenReturn(false);
348360
veniceHelixAdmin.createOrUpdateRealTimeTopic(clusterName, store, version, pubSubTopic);
349361
verify(topicManager, times(1)).createTopic(

0 commit comments

Comments
 (0)