Source:
public void testUnsuccessfulPutDataChunkDelete() throws Exception { maxPutChunkSize = PUT_CONTENT_SIZE / 4; Properties props = getNonBlockingRouterProperties("DC1"); VerifiableProperties verifiableProperties = new VerifiableProperties((props)); MockClusterMap mockClusterMap = new MockClusterMap(); MockTime mockTime = new MockTime(); MockServerLayout mockServerLayout = new MockServerLayout(mockClusterMap); final AtomicInteger completedDeletesCount = new AtomicInteger(0); LoggingNotificationSystem deleteTrackingNotificationSystem = new LoggingNotificationSystem() { @Override public void onBlobDeleted(String blobId) { completedDeletesCount.incrementAndGet(); } }; router = new NonBlockingRouter(new RouterConfig(verifiableProperties), new NonBlockingRouterMetrics(mockClusterMap), new MockNetworkClientFactory(verifiableProperties, mockSelectorState, MAX_PORTS_PLAIN_TEXT, MAX_PORTS_SSL, CHECKOUT_TIMEOUT_MS, mockServerLayout, mockTime), deleteTrackingNotificationSystem, mockClusterMap, mockTime); setOperationParams(); List<DataNodeId> dataNodeIds = mockClusterMap.getDataNodeIds(); List<ServerErrorCode> serverErrorList = new ArrayList<>(); serverErrorList.add(ServerErrorCode.No_Error); serverErrorList.add(ServerErrorCode.No_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); for (DataNodeId dataNodeId : dataNodeIds) { MockServer server = mockServerLayout.getMockServer(dataNodeId.getHostname(), dataNodeId.getPort()); server.setServerErrors(serverErrorList); } try { router.putBlob(putBlobProperties, putUserMetadata, putChannel).get(); } catch (ExecutionException e) { Assert.assertEquals(RouterErrorCode.AmbryUnavailable, ((RouterException) e.getCause()).getErrorCode()); } while (completedDeletesCount.get() < 2) { Thread.yield(); } router.close(); assertClosed(); Assert.assertEquals("All operations should have completed", 0, router.getOperationsCount()); }

Target:
public void testUnsuccessfulPutDataChunkDelete() throws Exception { maxPutChunkSize = PUT_CONTENT_SIZE / 4; Properties props = getNonBlockingRouterProperties("DC1"); VerifiableProperties verifiableProperties = new VerifiableProperties((props)); MockClusterMap mockClusterMap = new MockClusterMap(); MockTime mockTime = new MockTime(); MockServerLayout mockServerLayout = new MockServerLayout(mockClusterMap); final CountDownLatch deletesDoneLatch = new CountDownLatch(2); LoggingNotificationSystem deleteTrackingNotificationSystem = new LoggingNotificationSystem() { @Override public void onBlobDeleted(String blobId) { deletesDoneLatch.countDown(); } }; router = new NonBlockingRouter(new RouterConfig(verifiableProperties), new NonBlockingRouterMetrics(mockClusterMap), new MockNetworkClientFactory(verifiableProperties, mockSelectorState, MAX_PORTS_PLAIN_TEXT, MAX_PORTS_SSL, CHECKOUT_TIMEOUT_MS, mockServerLayout, mockTime), deleteTrackingNotificationSystem, mockClusterMap, mockTime); setOperationParams(); List<DataNodeId> dataNodeIds = mockClusterMap.getDataNodeIds(); List<ServerErrorCode> serverErrorList = new ArrayList<>(); serverErrorList.add(ServerErrorCode.No_Error); serverErrorList.add(ServerErrorCode.No_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); serverErrorList.add(ServerErrorCode.Unknown_Error); for (DataNodeId dataNodeId : dataNodeIds) { MockServer server = mockServerLayout.getMockServer(dataNodeId.getHostname(), dataNodeId.getPort()); server.setServerErrors(serverErrorList); } try { router.putBlob(putBlobProperties, putUserMetadata, putChannel).get(); } catch (ExecutionException e) { Assert.assertEquals(RouterErrorCode.AmbryUnavailable, ((RouterException) e.getCause()).getErrorCode()); } Assert.assertTrue("Deletes should not take longer than " + AWAIT_TIMEOUT_MS, deletesDoneLatch.await(AWAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS)); router.close(); assertClosed(); Assert.assertEquals("All operations should have completed", 0, router.getOperationsCount()); }