This is an automated email from the ASF dual-hosted git repository.
devmadhuu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 1b4ca34668b HDDS-15221. Fix flaky testReconGetsSnapshotFromLeader in
TestReconWithOzoneManagerHA (#10270)
1b4ca34668b is described below
commit 1b4ca34668b3b14dd688cbda988fc083de4a91b5
Author: Arun Sarin <[email protected]>
AuthorDate: Thu Jun 4 14:45:30 2026 +0530
HDDS-15221. Fix flaky testReconGetsSnapshotFromLeader in
TestReconWithOzoneManagerHA (#10270)
---
.../ozone/recon/TestReconWithOzoneManagerHA.java | 39 ++++++++++++++++++----
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git
a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconWithOzoneManagerHA.java
b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconWithOzoneManagerHA.java
index d1325b955dc..98332da8260 100644
---
a/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconWithOzoneManagerHA.java
+++
b/hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconWithOzoneManagerHA.java
@@ -23,7 +23,10 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.io.IOException;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.hdds.client.ReplicationFactor;
@@ -41,20 +44,20 @@
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
import org.apache.hadoop.ozone.recon.api.types.ContainerKeyPrefix;
import org.apache.hadoop.ozone.recon.spi.impl.OzoneManagerServiceProviderImpl;
import
org.apache.hadoop.ozone.recon.spi.impl.ReconContainerMetadataManagerImpl;
import org.apache.hadoop.ozone.recon.tasks.ReconTaskControllerImpl;
import org.apache.ozone.test.GenericTestUtils;
-import org.apache.ozone.test.tag.Flaky;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
- * This class sets up a MiniOzoneOMHACluster to test with Recon.
+ * Integration tests for Recon when Ozone Manager runs in HA mode on a mini
cluster.
*/
-@Flaky("HDDS-15221")
public class TestReconWithOzoneManagerHA {
private MiniOzoneHAClusterImpl cluster;
@@ -109,9 +112,9 @@ public void testReconGetsSnapshotFromLeader() throws
Exception {
ozoneManager.set(om);
return om != null;
}, 100, 120000);
- assertNotNull(ozoneManager, "Timed out waiting OM leader election to
finish: "
- + "no leader or more than one leader.");
- assertTrue(ozoneManager.get().isLeaderReady(), "Should have gotten the
leader!");
+ assertNotNull(ozoneManager.get(),
+ "Expected an elected OM leader after the cluster became ready.");
+ assertTrue(ozoneManager.get().isLeaderReady(), "OM leader should be ready
to serve.");
OzoneManagerServiceProviderImpl impl = (OzoneManagerServiceProviderImpl)
recon.getReconServer().getOzoneManagerServiceProvider();
@@ -146,6 +149,11 @@ public void testReconGetsSnapshotFromLeader() throws
Exception {
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,
+ requiredKeyCountByContainer);
try (Table.KeyValueIterator<ContainerKeyPrefix, Integer> iterator
=
reconContainerMetadataManager.getContainerKeyTableForTesting().iterator()) {
String reconKeyPrefix = null;
@@ -157,4 +165,23 @@ public void testReconGetsSnapshotFromLeader() throws
Exception {
reconKeyPrefix);
}
}
+
+ /**
+ * Looks up the object key on the given OM instance and returns the
container id for its first block.
+ * In HA tests, pass the current leader so the read goes to the right node.
+ */
+ private static long getContainerIdForKey(OzoneManager omLeader, String
volumeName,
+ String bucketName, String keyName) throws IOException {
+ OmKeyArgs keyArgs = new OmKeyArgs.Builder()
+ .setVolumeName(volumeName)
+ .setBucketName(bucketName)
+ .setKeyName(keyName)
+ .build();
+ OmKeyLocationInfo location = omLeader.lookupKey(keyArgs)
+ .getKeyLocationVersions()
+ .get(0)
+ .getBlocksLatestVersionOnly()
+ .get(0);
+ return location.getContainerID();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]