- * This test does the things including: - * 1. UTs for list trash. - * 2. UTs for recover trash. - * 3. UTs for empty trash. - *
- */
-public class TestTrashService {
-
- @TempDir
- private Path tempFolder;
-
- private KeyManager keyManager;
- private OzoneManagerProtocol writeClient;
- private OzoneManager om;
- private String volumeName;
- private String bucketName;
-
- @BeforeEach
- void setup() throws Exception {
- ExitUtils.disableSystemExit();
- OzoneConfiguration configuration = new OzoneConfiguration();
-
- File folder = tempFolder.toFile();
- if (!folder.exists()) {
- assertTrue(folder.mkdirs());
- }
- System.setProperty(DBConfigFromFile.CONFIG_DIR, "/");
- ServerUtils.setOzoneMetaDirPath(configuration, folder.toString());
-
- OmTestManagers omTestManagers
- = new OmTestManagers(configuration);
- keyManager = omTestManagers.getKeyManager();
- writeClient = omTestManagers.getWriteClient();
- om = omTestManagers.getOzoneManager();
- volumeName = "volume";
- bucketName = "bucket";
- }
-
- @AfterEach
- public void cleanup() throws Exception {
- om.stop();
- }
-
- @Test
- public void testRecoverTrash() throws IOException {
- String keyName = "testKey";
- String destinationBucket = "destBucket";
- createAndDeleteKey(keyName);
-
- boolean recoverOperation = keyManager.getMetadataManager()
- .recoverTrash(volumeName, bucketName, keyName, destinationBucket);
- assertTrue(recoverOperation);
- }
-
- private void createAndDeleteKey(String keyName) throws IOException {
-
- OMRequestTestUtils.addVolumeToOM(keyManager.getMetadataManager(),
- OmVolumeArgs.newBuilder()
- .setOwnerName("owner")
- .setAdminName("admin")
- .setVolume(volumeName)
- .build());
-
- OMRequestTestUtils.addBucketToOM(keyManager.getMetadataManager(),
- OmBucketInfo.newBuilder()
- .setVolumeName(volumeName)
- .setBucketName(bucketName)
- .build());
-
- OmKeyArgs keyArgs = new OmKeyArgs.Builder()
- .setVolumeName(volumeName)
- .setBucketName(bucketName)
- .setKeyName(keyName)
- .setAcls(Collections.emptyList())
- .setLocationInfoList(new ArrayList<>())
- .setReplicationConfig(StandaloneReplicationConfig
- .getInstance(HddsProtos.ReplicationFactor.ONE))
- .setOwnerName(UserGroupInformation.getCurrentUser().getShortUserName())
- .build();
-
- /* Create and delete key in the Key Manager. */
- OpenKeySession session = writeClient.openKey(keyArgs);
- writeClient.commitKey(keyArgs, session.getId());
- writeClient.deleteKey(keyArgs);
- }
-
-}
diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java
index 41876c6e245..e3e3537b1c3 100644
--- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java
+++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/ClientProtocolStub.java
@@ -43,7 +43,6 @@
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus;
import org.apache.hadoop.ozone.om.helpers.OzoneFileStatusLight;
-import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.S3SecretValue;
import org.apache.hadoop.ozone.om.helpers.S3VolumeContext;
import org.apache.hadoop.ozone.om.helpers.TenantStateList;
@@ -301,21 +300,6 @@ public List