hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject [13/50] [abbrv] hadoop git commit: HDDS-743. S3 multi delete request should return XML header in quiet mode. Contributed by Elek Marton.
Date Fri, 02 Nov 2018 09:29:21 GMT
HDDS-743. S3 multi delete request should return XML header in quiet mode. Contributed by Elek
Marton.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3655e573
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3655e573
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3655e573

Branch: refs/heads/HDFS-13891
Commit: 3655e573e28eea79e46936d348a852158b2fc48a
Parents: a58048e
Author: Bharat Viswanadham <bharat@apache.org>
Authored: Mon Oct 29 12:59:41 2018 -0700
Committer: Bharat Viswanadham <bharat@apache.org>
Committed: Mon Oct 29 12:59:41 2018 -0700

----------------------------------------------------------------------
 .../ozone/s3/endpoint/BucketEndpoint.java       |  9 +--
 .../s3/endpoint/TestObjectMultiDelete.java      | 61 +++++++++++++++-----
 2 files changed, 48 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/3655e573/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
index fca251d..8f554ed 100644
--- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
+++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
@@ -223,7 +223,7 @@ public class BucketEndpoint extends EndpointBase {
    */
   @POST
   @Produces(MediaType.APPLICATION_XML)
-  public Response multiDelete(@PathParam("bucket") String bucketName,
+  public MultiDeleteResponse multiDelete(@PathParam("bucket") String bucketName,
       @QueryParam("delete") String delete,
       MultiDeleteRequest request) throws OS3Exception, IOException {
     OzoneBucket bucket = getBucket(bucketName);
@@ -251,11 +251,6 @@ public class BucketEndpoint extends EndpointBase {
         }
       }
     }
-    ResponseBuilder response = Response.ok();
-    if (!request.isQuiet() || result.getErrors().size() > 0) {
-      response = response.entity(result);
-    }
-    return response.build();
-
+    return result;
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3655e573/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectMultiDelete.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectMultiDelete.java
b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectMultiDelete.java
index 12a14a0..dabbd22 100644
--- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectMultiDelete.java
+++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectMultiDelete.java
@@ -46,16 +46,7 @@ public class TestObjectMultiDelete {
   public void delete() throws IOException, OS3Exception, JAXBException {
     //GIVEN
     OzoneClient client = new OzoneClientStub();
-    client.getObjectStore().createS3Bucket("bilbo", "b1");
-
-    String volumeName = client.getObjectStore().getOzoneVolumeName("b1");
-
-    OzoneBucket bucket =
-        client.getObjectStore().getVolume(volumeName).getBucket("b1");
-
-    bucket.createKey("key1", 0).close();
-    bucket.createKey("key2", 0).close();
-    bucket.createKey("key3", 0).close();
+    OzoneBucket bucket = initTestData(client);
 
     BucketEndpoint rest = new BucketEndpoint();
     rest.setClient(client);
@@ -66,11 +57,9 @@ public class TestObjectMultiDelete {
     mdr.getObjects().add(new DeleteObject("key4"));
 
     //WHEN
-    Response response = rest.multiDelete("b1", "", mdr);
+    MultiDeleteResponse response = rest.multiDelete("b1", "", mdr);
 
     //THEN
-    MultiDeleteResponse mdresponse = (MultiDeleteResponse) response.getEntity();
-
     Set<String> keysAtTheEnd = Sets.newHashSet(bucket.listKeys("")).stream()
         .map(OzoneKey::getName)
         .collect(Collectors.toSet());
@@ -80,7 +69,49 @@ public class TestObjectMultiDelete {
 
     //THEN
     Assert.assertEquals(expectedResult, keysAtTheEnd);
-    Assert.assertEquals(3, mdresponse.getDeletedObjects().size());
-    Assert.assertEquals(0, mdresponse.getErrors().size());
+    Assert.assertEquals(3, response.getDeletedObjects().size());
+    Assert.assertEquals(0, response.getErrors().size());
+  }
+
+  @Test
+  public void deleteQuiet() throws IOException, OS3Exception, JAXBException {
+    //GIVEN
+    OzoneClient client = new OzoneClientStub();
+    OzoneBucket bucket = initTestData(client);
+
+    BucketEndpoint rest = new BucketEndpoint();
+    rest.setClient(client);
+
+    MultiDeleteRequest mdr = new MultiDeleteRequest();
+    mdr.setQuiet(true);
+    mdr.getObjects().add(new DeleteObject("key1"));
+    mdr.getObjects().add(new DeleteObject("key2"));
+    mdr.getObjects().add(new DeleteObject("key4"));
+
+    //WHEN
+    MultiDeleteResponse response = rest.multiDelete("b1", "", mdr);
+
+    //THEN
+    Set<String> keysAtTheEnd = Sets.newHashSet(bucket.listKeys("")).stream()
+        .map(OzoneKey::getName)
+        .collect(Collectors.toSet());
+
+    //THEN
+    Assert.assertEquals(0, response.getDeletedObjects().size());
+    Assert.assertEquals(0, response.getErrors().size());
+  }
+
+  private OzoneBucket initTestData(OzoneClient client) throws IOException {
+    client.getObjectStore().createS3Bucket("bilbo", "b1");
+
+    String volumeName = client.getObjectStore().getOzoneVolumeName("b1");
+
+    OzoneBucket bucket =
+        client.getObjectStore().getVolume(volumeName).getBucket("b1");
+
+    bucket.createKey("key1", 0).close();
+    bucket.createKey("key2", 0).close();
+    bucket.createKey("key3", 0).close();
+    return bucket;
   }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message