Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arjun4084346 committed Dec 19, 2024
1 parent e127ce7 commit 705f1ac
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 540 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,18 @@ public static String composeRealTimeTopic(String storeName) {
return storeName + Version.REAL_TIME_TOPIC_SUFFIX;
}

public static String getRealTimeTopicNameFromStoreConfig(Store store) {
HybridStoreConfig hybridStoreConfig = store.getHybridStoreConfig();
String storeName = store.getName();

if (hybridStoreConfig != null) {
String realTimeTopicName = hybridStoreConfig.getRealTimeTopicName();
return getRealTimeTopicNameIfEmpty(realTimeTopicName, storeName);
} else {
return composeRealTimeTopic(storeName);
}
}

/**
* It follows the following order to search for real time topic name,
* i) current store-version config, ii) store config, iii) other store-version configs, iv) default name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.linkedin.venice.utils;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertThrows;
Expand Down Expand Up @@ -349,6 +350,59 @@ void testGetRealTimeTopicNameWithNonHybridVersion() {
assertEquals("TestStore" + Version.REAL_TIME_TOPIC_SUFFIX, result);
}

@Test
void testRealTimeTopicNameWithHybridConfig() {
// Mock the Store and HybridStoreConfig
Store store = mock(Store.class);
HybridStoreConfig hybridStoreConfig = mock(HybridStoreConfig.class);

// Define behavior
when(store.getHybridStoreConfig()).thenReturn(hybridStoreConfig);
when(store.getName()).thenReturn("test-store");
when(hybridStoreConfig.getRealTimeTopicName()).thenReturn("real-time-topic");

// Test
String result = Utils.getRealTimeTopicNameFromStoreConfig(store);

// Validate
assertEquals("real-time-topic", result);

// Verify calls
verify(store).getHybridStoreConfig();
verify(store).getName();
verify(hybridStoreConfig).getRealTimeTopicName();
}

@Test
void testRealTimeTopicNameEmptyWithHybridConfig() {
// Mock the Store and HybridStoreConfig
Store store = mock(Store.class);
HybridStoreConfig hybridStoreConfig = mock(HybridStoreConfig.class);

// Define behavior
when(store.getHybridStoreConfig()).thenReturn(hybridStoreConfig);
when(store.getName()).thenReturn("test-store");
when(hybridStoreConfig.getRealTimeTopicName()).thenReturn("");

String result = Utils.getRealTimeTopicNameFromStoreConfig(store);

assertEquals("test-store_rt", result);
}

@Test
void testRealTimeTopicNameWithoutHybridConfig() {
// Mock the Store
Store store = mock(Store.class);

// Define behavior
when(store.getHybridStoreConfig()).thenReturn(null);
when(store.getName()).thenReturn("test-store");

String result = Utils.getRealTimeTopicNameFromStoreConfig(store);

assertEquals("test-store_rt", result);
}

@Test
public void testParseDateTimeToEpoch() throws Exception {
// Case 1: Valid Input
Expand Down
Loading

0 comments on commit 705f1ac

Please sign in to comment.