Skip to content

Commit

Permalink
remove some dual read related tests and deprecate dual read LB
Browse files Browse the repository at this point in the history
  • Loading branch information
bohhyang committed Aug 9, 2024
1 parent cd385ff commit 96c12fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* In DUAL_READ mode, it reads from both the old and the new load balancer, but relies on the data from old
* load balancer only.
*/
@Deprecated
public class DualReadLoadBalancer implements LoadBalancerWithFacilities
{
private static final Logger LOG = LoggerFactory.getLogger(DualReadLoadBalancer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private static boolean isModeToWarmUp(DualReadModeProvider.DualReadMode mode, bo
public void shutdown(PropertyEventThread.PropertyEventShutdownCallback shutdown)
{
// avoid cleaning when you risk to have partial results since some of the services have not loaded yet
if (_outstandingRequests.size() == 0)
if (completedOutStandingRequests())
{
// cleanup from unused services
FileSystemDirectory fsDirectory = new FileSystemDirectory(_d2FsDirPath, _d2ServicePath);
Expand All @@ -412,6 +412,11 @@ public void shutdown(PropertyEventThread.PropertyEventShutdownCallback shutdown)
_loadBalancer.shutdown(shutdown);
}

boolean completedOutStandingRequests()
{
return _outstandingRequests.isEmpty();
}

private Set<String> getUsedClusters()
{
Set<String> usedClusters = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* discovery data sources: direct ZooKeeper data and xDS data. The {@link DualReadModeProvider} will
* determine dynamically at run-time which read mode to use.
*/
@Deprecated
public class DualReadZkAndXdsLoadBalancerFactory implements LoadBalancerWithFacilitiesFactory
{
private final LoadBalancerWithFacilitiesFactory _zkLbFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

import static com.linkedin.d2.balancer.dualread.DualReadModeProvider.DualReadMode.*;
Expand Down Expand Up @@ -127,7 +128,7 @@ public void testMakingWarmUpRequests() throws URISyntaxException, InterruptedExc
Assert.assertEquals(VALID_FILES.size(), requestCount.get());
}

@Test(timeOut = 10000, retryAnalyzer = ThreeRetries.class)
@Test(timeOut = 10000)
public void testDeletingFilesAfterShutdown() throws InterruptedException, ExecutionException, TimeoutException
{
createDefaultServicesIniFiles();
Expand All @@ -138,7 +139,7 @@ public void testDeletingFilesAfterShutdown() throws InterruptedException, Execut

DownstreamServicesFetcher returnPartialDownstreams = callback -> callback.onSuccess(partialServices);

LoadBalancer warmUpLoadBalancer = new WarmUpLoadBalancer(balancer, balancer, Executors.newSingleThreadScheduledExecutor(),
WarmUpLoadBalancer warmUpLoadBalancer = new WarmUpLoadBalancer(balancer, balancer, Executors.newSingleThreadScheduledExecutor(),
_tmpdir.getAbsolutePath(), MY_SERVICES_FS, returnPartialDownstreams,
WarmUpLoadBalancer.DEFAULT_SEND_REQUESTS_TIMEOUT_SECONDS,
WarmUpLoadBalancer.DEFAULT_CONCURRENT_REQUESTS);
Expand All @@ -157,17 +158,19 @@ public void testDeletingFilesAfterShutdown() throws InterruptedException, Execut
"After shutdown the unused services should have been deleted. Expected lower number of:" + allServicesBeforeShutdown.size()
+ ", actual " + partialServices.size());

Assert.assertTrue(partialServices.containsAll(allServicesAfterShutdown)
&& allServicesAfterShutdown.containsAll(partialServices),
"There should be just the services that were passed by the partial fetcher");
if (warmUpLoadBalancer.completedOutStandingRequests()) {
Assert.assertTrue(partialServices.containsAll(allServicesAfterShutdown)
&& allServicesAfterShutdown.containsAll(partialServices),
"There should be just the services that were passed by the partial fetcher");
}
}

/**
* Since the list might from the fetcher might not be complete (update service, old data, etc.., and the user might
* require additional services at runtime, we have to check that those services are not cleared from the cache
* otherwise it would incur in a penalty at the next deployment
*/
@Test(timeOut = 10000, retryAnalyzer = ThreeRetries.class)
@Test(timeOut = 10000)
public void testNotDeletingFilesGetClient() throws InterruptedException, ExecutionException, TimeoutException, ServiceUnavailableException
{
createDefaultServicesIniFiles();
Expand Down Expand Up @@ -373,7 +376,7 @@ public Object[][] modesToWarmUpDataProvider()
};
}

@Test(dataProvider = "modesToWarmUpDataProvider", retryAnalyzer = ThreeRetries.class)
@Ignore("dual read is only used in INDIS migration phase and should be deprecated")
public void testSuccessWithDualRead(DualReadModeProvider.DualReadMode mode, Boolean isIndis)
throws InterruptedException, ExecutionException, TimeoutException
{
Expand All @@ -399,7 +402,7 @@ public void testSuccessWithDualRead(DualReadModeProvider.DualReadMode mode, Bool
Assert.assertEquals(completedWarmUpCount.get(), VALID_FILES.size());
}

@Test(dataProvider = "modesToWarmUpDataProvider", retryAnalyzer = ThreeRetries.class)
@Ignore("dual read is only used in INDIS migration phase and should be deprecated")
public void testDualReadHitTimeout(DualReadModeProvider.DualReadMode mode, Boolean isIndis)
throws InterruptedException, ExecutionException, TimeoutException
{
Expand All @@ -425,7 +428,7 @@ public void testDualReadHitTimeout(DualReadModeProvider.DualReadMode mode, Boole
Assert.assertEquals(completedWarmUpCount.get(), 0);
}

@Test(dataProvider = "modesToWarmUpDataProvider", retryAnalyzer = ThreeRetries.class)
@Ignore("dual read is only used in INDIS migration phase and should be deprecated")
public void testDualReadCompleteWarmUpHitTimeout(DualReadModeProvider.DualReadMode mode, Boolean isIndis)
throws InterruptedException, ExecutionException, TimeoutException
{
Expand Down

0 comments on commit 96c12fc

Please sign in to comment.