Skip to content

Commit 206addf

Browse files
committed
[dvc] Config flag for subscribing on disk partitions automatically. Updated with integration test and unit test.
1 parent 388d2af commit 206addf

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Diff for: clients/da-vinci-client/src/main/java/com/linkedin/davinci/DaVinciBackend.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ private Function<String, Boolean> functionToCheckWhetherStorageEngineShouldBeKep
399399
};
400400
}
401401

402-
final synchronized void bootstrap() {
402+
private synchronized void bootstrap() {
403403
List<AbstractStorageEngine> storageEngines =
404404
storageService.getStorageEngineRepository().getAllLocalStorageEngines();
405405
LOGGER.info("Starting bootstrap, storageEngines: {}", storageEngines);

Diff for: clients/da-vinci-client/src/test/java/com/linkedin/davinci/DaVinciBackendTest.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import static org.mockito.ArgumentMatchers.anyInt;
1010
import static org.mockito.ArgumentMatchers.anyString;
1111
import static org.mockito.Mockito.doAnswer;
12-
import static org.mockito.Mockito.doCallRealMethod;
1312
import static org.mockito.Mockito.doNothing;
1413
import static org.mockito.Mockito.mock;
1514
import static org.mockito.Mockito.times;
@@ -38,6 +37,8 @@
3837
import com.linkedin.venice.utils.ComplementSet;
3938
import com.linkedin.venice.utils.VeniceProperties;
4039
import java.lang.reflect.Field;
40+
import java.lang.reflect.InvocationTargetException;
41+
import java.lang.reflect.Method;
4142
import java.util.ArrayList;
4243
import java.util.HashSet;
4344
import java.util.List;
@@ -168,7 +169,8 @@ public void testBootstrappingAwareCompletableFuture()
168169
}
169170

170171
@Test
171-
public void testBootstrappingSubscription() throws NoSuchFieldException, IllegalAccessException {
172+
public void testBootstrappingSubscription()
173+
throws IllegalAccessException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException {
172174
DaVinciBackend backend = mock(DaVinciBackend.class);
173175
StorageService mockStorageService = mock(StorageService.class);
174176

@@ -254,18 +256,20 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
254256
ingestionServiceField.set(backend, storeIngestionService);
255257
doNothing().when(ingestionBackend).addIngestionNotifier(any());
256258

259+
Method bootstrapMethod = DaVinciBackend.class.getDeclaredMethod("bootstrap");
260+
bootstrapMethod.setAccessible(true);
261+
257262
// DA_VINCI_SUBSCRIBE_ON_DISK_PARTITIONS_AUTOMATICALLY == false
258263
when(mockCombinedProperties.getBoolean(anyString(), anyBoolean())).thenReturn(false);
259-
doCallRealMethod().when(backend).bootstrap();
260-
backend.bootstrap();
264+
bootstrapMethod.invoke(backend);
261265

262266
ComplementSet<Integer> subscription = mockStoreBackend.getSubscription();
263267
assertTrue(subscription.contains(0));
264268
assertTrue(subscription.contains(1));
265269
assertFalse(subscription.contains(2));
266270

267271
when(mockCombinedProperties.getBoolean(anyString(), anyBoolean())).thenReturn(true);
268-
backend.bootstrap();
272+
bootstrapMethod.invoke(backend);
269273

270274
// DA_VINCI_SUBSCRIBE_ON_DISK_PARTITIONS_AUTOMATICALLY == true
271275
subscription = mockStoreBackend.getSubscription();

0 commit comments

Comments
 (0)