adoroszlai commented on code in PR #8209:
URL: https://github.com/apache/ozone/pull/8209#discussion_r2129339081


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneDebugReplicasVerify.java:
##########
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.shell;
+
+import static org.apache.hadoop.ozone.TestDataUtil.createKeys;
+import static 
org.apache.hadoop.ozone.container.ContainerTestHelper.corruptFile;
+import static 
org.apache.hadoop.ozone.container.ContainerTestHelper.truncateFile;
+import static org.apache.ozone.test.GenericTestUtils.setLogLevel;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Stream;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.XceiverClientGrpc;
+import org.apache.hadoop.ozone.HddsDatanodeService;
+import org.apache.hadoop.ozone.client.ObjectStore;
+import org.apache.hadoop.ozone.client.OzoneBucket;
+import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneKey;
+import org.apache.hadoop.ozone.client.OzoneVolume;
+import org.apache.hadoop.ozone.container.common.interfaces.Container;
+import org.apache.hadoop.ozone.debug.OzoneDebug;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
+import org.apache.ozone.test.GenericTestUtils;
+import org.apache.ozone.test.NonHATests;
+import org.apache.ratis.util.JvmPauseMonitor;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.event.Level;
+
+/**
+ * Test Ozone Debug Replicas Verify commands.
+ */
+public abstract class TestOzoneDebugReplicasVerify implements 
NonHATests.TestCase {
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestOzoneDebugReplicasVerify.class);
+  private static final String CHUNKS_DIR_NAME = "chunks";
+  private static final String BLOCK_FILE_EXTENSION = ".block";
+
+  @TempDir
+  private File tempDir;
+  private OzoneDebug ozoneDebugShell;
+  private String ozoneAddress;
+  private GenericTestUtils.PrintStreamCapturer out;
+  private GenericTestUtils.PrintStreamCapturer err;
+  private Map<String, OmKeyInfo> keyInfoMap;
+
+  @BeforeEach
+  void init() {
+    setLogLevel(XceiverClientGrpc.class, Level.DEBUG);
+    setLogLevel(JvmPauseMonitor.class, Level.ERROR);
+    out = GenericTestUtils.captureOut();
+    err = GenericTestUtils.captureErr();
+    ozoneDebugShell = new OzoneDebug();
+  }
+
+  @BeforeEach
+  void setupKeys() throws Exception {
+    keyInfoMap = createKeys(cluster(), 10);
+    ozoneAddress = "/" + 
keyInfoMap.get(keyInfoMap.keySet().stream().findAny().get()).getVolumeName();
+  }
+
+  @AfterEach
+  void cleanupKeys() throws IOException {
+    if (!out.toString().isEmpty()) {
+      LOG.info(out.toString());
+    }
+
+    if (!err.toString().isEmpty()) {
+      LOG.error(err.toString());
+    }
+
+    try (OzoneClient client = cluster().newClient()) {
+      ObjectStore store = client.getObjectStore();
+      for (Iterator<? extends OzoneVolume> volumeIterator
+           = store.listVolumes(null); volumeIterator.hasNext();) {
+        OzoneVolume ozoneVolume = volumeIterator.next();
+        for (Iterator<? extends OzoneBucket> bucketIterator
+             = store.getVolume(ozoneVolume.getName()).listBuckets(null); 
bucketIterator.hasNext();) {
+          OzoneBucket ozoneBucket = bucketIterator.next();
+          for (Iterator<? extends OzoneKey> keyIterator
+               = ozoneBucket.listKeys(null); keyIterator.hasNext();) {
+            OzoneKey ozoneKey = keyIterator.next();
+            ozoneBucket.deleteDirectory(ozoneKey.getName(), true);
+          }
+          ozoneVolume.deleteBucket(ozoneBucket.getName());
+        }
+        store.deleteVolume(ozoneVolume.getName());
+      }
+    }

Review Comment:
   This deletes all volumes, including `/s3v`, causing subsequent test failure:
   
   ```
   VOLUME_NOT_FOUND org.apache.hadoop.ozone.om.exceptions.OMException: Volume 
s3v is not found
        at 
org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.handleError(OzoneManagerProtocolClientSideTranslatorPB.java:761)
        at 
org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.getVolumeInfo(OzoneManagerProtocolClientSideTranslatorPB.java:460)
        at 
org.apache.hadoop.ozone.client.rpc.RpcClient.getVolumeDetails(RpcClient.java:499)
        at 
org.apache.hadoop.ozone.client.ObjectStore.getVolume(ObjectStore.java:185)
        at 
org.apache.hadoop.ozone.client.rpc.TestOzoneClientMultipartUploadWithFSO.testGetAllPartsWhenZeroPartNumber(TestOzoneClientMultipartUploadWithFSO.java:930)
   ```
   
   
https://github.com/ptlrs/ozone/actions/runs/15119784564/job/42499737600#step:13:5351
   
   Only the volume created in `setupKeys()` should be deleted.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to