From 408550bd03a7427c4972db3170449d1d53c2e688 Mon Sep 17 00:00:00 2001 From: Priyesh Karatha Date: Tue, 2 Jun 2026 23:31:31 +0530 Subject: [PATCH] HDDS-15265. Speed up TestStorageDistributionEndpoint testcases --- .../common/helpers/BlockDeletingServiceMetrics.java | 4 ++-- .../recon/AbstractTestStorageDistributionEndpoint.java | 3 ++- .../ozone/recon/TestStorageDistributionEndpointEC.java | 6 +++--- .../ozone/recon/TestStorageDistributionEndpointRatis.java | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/BlockDeletingServiceMetrics.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/BlockDeletingServiceMetrics.java index 91bb8fbc59ac..0151bfaea0fe 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/BlockDeletingServiceMetrics.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/BlockDeletingServiceMetrics.java @@ -87,7 +87,7 @@ public final class BlockDeletingServiceMetrics { private BlockDeletingServiceMetrics() { } - public static BlockDeletingServiceMetrics create() { + public static synchronized BlockDeletingServiceMetrics create() { if (instance == null) { MetricsSystem ms = DefaultMetricsSystem.instance(); instance = ms.register(SOURCE_NAME, "BlockDeletingService", @@ -100,7 +100,7 @@ public static BlockDeletingServiceMetrics create() { /** * Unregister the metrics instance. */ - public static void unRegister() { + public static synchronized void unRegister() { instance = null; MetricsSystem ms = DefaultMetricsSystem.instance(); ms.unregisterSource(SOURCE_NAME); diff --git a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/AbstractTestStorageDistributionEndpoint.java b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/AbstractTestStorageDistributionEndpoint.java index 70aaa01a6663..8345c51b6908 100644 --- a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/AbstractTestStorageDistributionEndpoint.java +++ b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/AbstractTestStorageDistributionEndpoint.java @@ -156,7 +156,7 @@ protected static void initializeCluster(int numDatanodes) throws Exception { conf.set(HDDS_SCM_WAIT_TIME_AFTER_SAFE_MODE_EXIT, "0s"); DatanodeConfiguration dnConf = conf.getObject(DatanodeConfiguration.class); - dnConf.setBlockDeletionInterval(Duration.ofMillis(30000)); + dnConf.setBlockDeletionInterval(Duration.ofMillis(5000)); conf.setFromObject(dnConf); recon = new ReconService(conf); @@ -212,6 +212,7 @@ protected void createOpenKeysAndMultipartKeys(String volumeName, protected boolean verifyStorageDistributionAfterKeyCreation() { try { + syncDataFromOM(); StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append(getReconWebAddress(conf)).append(STORAGE_DIST_ENDPOINT); String response = TestReconEndpointUtil.makeHttpCall(conf, urlBuilder); diff --git a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointEC.java b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointEC.java index c09dbb04129a..21a741d4f4fb 100644 --- a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointEC.java +++ b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointEC.java @@ -83,11 +83,11 @@ public void testStorageDistributionEndpoint() throws Exception { closeAllContainers(); getFs().delete(dir1, true); GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionOm, 1000, 30000); - GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionScm, 2000, 30000); + GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionScm, 1000, 30000); + GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionDn, 1000, 60000); GenericTestUtils.waitFor(() -> Objects.requireNonNull( getScm().getClientProtocolServer().getDeletedBlockSummary()).getTotalBlockCount() == 0, 1000, 30000); - GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionDn, 2000, 60000); - GenericTestUtils.waitFor(this::verifyPendingDeletionClearsAtDn, 2000, 60000); + GenericTestUtils.waitFor(this::verifyPendingDeletionClearsAtDn, 1000, 60000); } } diff --git a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointRatis.java b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointRatis.java index 4562879058bb..df0e3401ffca 100644 --- a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointRatis.java +++ b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestStorageDistributionEndpointRatis.java @@ -88,13 +88,13 @@ public void testStorageDistributionEndpoint() throws Exception { closeAllContainers(); getFs().delete(dir1, true); GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionOm, 1000, 30000); - GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionScm, 2000, 30000); + GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionScm, 1000, 30000); + GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionDn, 1000, 60000); GenericTestUtils.waitFor(() -> Objects.requireNonNull( getScm().getClientProtocolServer().getDeletedBlockSummary()).getTotalBlockCount() == 0, 1000, 30000); - GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionDn, 2000, 60000); - GenericTestUtils.waitFor(this::verifyPendingDeletionClearsAtDn, 2000, 60000); + GenericTestUtils.waitFor(this::verifyPendingDeletionClearsAtDn, 1000, 60000); getCluster().getHddsDatanodes().get(0).stop(); - GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionOnDnFailure, 2000, 60000); + GenericTestUtils.waitFor(this::verifyPendingDeletionAfterKeyDeletionOnDnFailure, 1000, 60000); } }