Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
import org.apache.ozone.test.GenericTestUtils;

/**
* Test Recon Utility methods.
* Utility methods for Recon OM metadata manager integration tests.
*/
public class TestReconOmMetaManagerUtils {
final class ReconOmMetaManagerTestUtils {

private ReconOmMetaManagerTestUtils() {
}

/**
* Wait for all currently buffered events to be processed asynchronously.
Expand All @@ -36,7 +39,7 @@ public class TestReconOmMetaManagerUtils {
*
* @return CompletableFuture that completes when buffer is empty
*/
public CompletableFuture<Void> waitForEventBufferEmpty(OMUpdateEventBuffer eventBuffer) {
static CompletableFuture<Void> waitForEventBufferEmpty(OMUpdateEventBuffer eventBuffer) {
return CompletableFuture.runAsync(() -> {
try {
GenericTestUtils.waitFor(() -> eventBuffer.getQueueSize() == 0, 100, 30000);
Expand All @@ -60,7 +63,7 @@ public CompletableFuture<Void> waitForEventBufferEmpty(OMUpdateEventBuffer event
* @param minimumCountPerContainer map of container ID to minimum inclusive key count
* @throws Exception if the condition is not met within the timeout or on interrupt
*/
public static void waitUntilReconKeyCounts(ReconContainerMetadataManager mgr,
static void waitUntilReconKeyCounts(ReconContainerMetadataManager mgr,
Map<Long, Integer> minimumCountPerContainer) throws Exception {
GenericTestUtils.waitFor(() -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.hadoop.ozone.recon;

import static org.apache.hadoop.ozone.recon.ReconOmMetaManagerTestUtils.waitForEventBufferEmpty;
import static org.apache.hadoop.ozone.recon.ReconOmMetaManagerTestUtils.waitUntilReconKeyCounts;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

Expand Down Expand Up @@ -63,7 +65,6 @@ public class TestReconContainerEndpoint {
private OzoneClient client;
private ObjectStore store;
private ReconService recon;
private TestReconOmMetaManagerUtils omMetaManagerUtils = new TestReconOmMetaManagerUtils();

@BeforeEach
public void init() throws Exception {
Expand Down Expand Up @@ -121,7 +122,7 @@ public void testContainerEndpointForFSOLayout() throws Exception {
ReconTaskControllerImpl reconTaskController =
(ReconTaskControllerImpl) recon.getReconServer().getReconTaskController();
CompletableFuture<Void> completableFuture =
omMetaManagerUtils.waitForEventBufferEmpty(reconTaskController.getEventBuffer());
waitForEventBufferEmpty(reconTaskController.getEventBuffer());
GenericTestUtils.waitFor(completableFuture::isDone, 100, 30000);
completableFuture.join();
waitUntilReconIndexesKeysForPaths(volName, bucketName,
Expand Down Expand Up @@ -192,7 +193,7 @@ public void testContainerEndpointForOBSBucket() throws Exception {
ReconTaskControllerImpl reconTaskController =
(ReconTaskControllerImpl) recon.getReconServer().getReconTaskController();
CompletableFuture<Void> completableFuture =
omMetaManagerUtils.waitForEventBufferEmpty(reconTaskController.getEventBuffer());
waitForEventBufferEmpty(reconTaskController.getEventBuffer());
GenericTestUtils.waitFor(completableFuture::isDone, 100, 30000);
completableFuture.join();
waitUntilReconIndexesKeysForPaths(volumeName, obsBucketName, obsSingleFileKey);
Expand Down Expand Up @@ -252,7 +253,7 @@ private void waitUntilReconIndexesKeysForPaths(String volumeName,
}
ReconContainerMetadataManager mgr =
recon.getReconServer().getReconContainerMetadataManager();
TestReconOmMetaManagerUtils.waitUntilReconKeyCounts(mgr, requiredCountByContainer);
waitUntilReconKeyCounts(mgr, requiredCountByContainer);
}

private long getContainerIdForKey(String volumeName, String bucketName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_DB_CHECKPOINT_HTTP_ENDPOINT;
import static org.apache.hadoop.ozone.recon.ReconOmMetaManagerTestUtils.waitForEventBufferEmpty;
import static org.apache.hadoop.ozone.recon.ReconOmMetaManagerTestUtils.waitUntilReconKeyCounts;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -66,7 +68,6 @@ public class TestReconWithOzoneManagerHA {
private static final String VOL_NAME = "testrecon";
private OzoneClient client;
private ReconService recon;
private TestReconOmMetaManagerUtils omMetaManagerUtils = new TestReconOmMetaManagerUtils();

@BeforeEach
public void setup() throws Exception {
Expand Down Expand Up @@ -144,15 +145,15 @@ public void testReconGetsSnapshotFromLeader() throws Exception {
ReconTaskControllerImpl reconTaskController =
(ReconTaskControllerImpl) recon.getReconServer().getReconTaskController();
CompletableFuture<Void> completableFuture =
omMetaManagerUtils.waitForEventBufferEmpty(reconTaskController.getEventBuffer());
waitForEventBufferEmpty(reconTaskController.getEventBuffer());
GenericTestUtils.waitFor(completableFuture::isDone, 100, 30000);

final ReconContainerMetadataManagerImpl reconContainerMetadataManager =
(ReconContainerMetadataManagerImpl) recon.getReconServer().getReconContainerMetadataManager();
long containerId = getContainerIdForKey(ozoneManager.get(), VOL_NAME, VOL_NAME, keyPrefix);
Map<Long, Integer> requiredKeyCountByContainer =
Collections.singletonMap(containerId, 1);
TestReconOmMetaManagerUtils.waitUntilReconKeyCounts(reconContainerMetadataManager,
waitUntilReconKeyCounts(reconContainerMetadataManager,
requiredKeyCountByContainer);
try (Table.KeyValueIterator<ContainerKeyPrefix, Integer> iterator
= reconContainerMetadataManager.getContainerKeyTableForTesting().iterator()) {
Expand Down
Loading