Search in sources :

Example 11 with OzoneClientStub

use of org.apache.hadoop.ozone.client.OzoneClientStub in project ozone by apache.

the class TestPartUpload method setUp.

@BeforeClass
public static void setUp() throws Exception {
    OzoneClient client = new OzoneClientStub();
    client.getObjectStore().createS3Bucket(OzoneConsts.S3_BUCKET);
    HttpHeaders headers = Mockito.mock(HttpHeaders.class);
    when(headers.getHeaderString(STORAGE_CLASS_HEADER)).thenReturn("STANDARD");
    REST.setHeaders(headers);
    REST.setClient(client);
    REST.setOzoneConfiguration(new OzoneConfiguration());
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OzoneClientStub(org.apache.hadoop.ozone.client.OzoneClientStub) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) BeforeClass(org.junit.BeforeClass)

Example 12 with OzoneClientStub

use of org.apache.hadoop.ozone.client.OzoneClientStub in project ozone by apache.

the class TestRootList method setup.

@Before
public void setup() throws Exception {
    // Create client stub and object store stub.
    clientStub = new OzoneClientStub();
    // Create HeadBucket and setClient to OzoneClientStub
    rootEndpoint = new RootEndpoint();
    rootEndpoint.setClient(clientStub);
}
Also used : OzoneClientStub(org.apache.hadoop.ozone.client.OzoneClientStub) Before(org.junit.Before)

Example 13 with OzoneClientStub

use of org.apache.hadoop.ozone.client.OzoneClientStub in project ozone by apache.

the class TestS3GatewayMetrics method setup.

@Before
public void setup() throws Exception {
    clientStub = new OzoneClientStub();
    clientStub.getObjectStore().createS3Bucket(bucketName);
    bucket = clientStub.getObjectStore().getS3Bucket(bucketName);
    bucketEndpoint = new BucketEndpoint();
    bucketEndpoint.setClient(clientStub);
    rootEndpoint = new RootEndpoint();
    rootEndpoint.setClient(clientStub);
    keyEndpoint = new ObjectEndpoint();
    keyEndpoint.setClient(clientStub);
    keyEndpoint.setOzoneConfiguration(new OzoneConfiguration());
    headers = Mockito.mock(HttpHeaders.class);
    when(headers.getHeaderString(STORAGE_CLASS_HEADER)).thenReturn("STANDARD");
    keyEndpoint.setHeaders(headers);
    metrics = bucketEndpoint.getMetrics();
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) BucketEndpoint(org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint) ObjectEndpoint(org.apache.hadoop.ozone.s3.endpoint.ObjectEndpoint) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OzoneClientStub(org.apache.hadoop.ozone.client.OzoneClientStub) RootEndpoint(org.apache.hadoop.ozone.s3.endpoint.RootEndpoint) Before(org.junit.Before)

Example 14 with OzoneClientStub

use of org.apache.hadoop.ozone.client.OzoneClientStub in project ozone by apache.

the class TestS3GatewayAuditLog method setup.

@Before
public void setup() throws Exception {
    parametersMap.clear();
    clientStub = new OzoneClientStub();
    clientStub.getObjectStore().createS3Bucket(bucketName);
    bucket = clientStub.getObjectStore().getS3Bucket(bucketName);
    bucketEndpoint = new BucketEndpoint() {

        @Override
        protected Map<String, String> getAuditParameters() {
            return parametersMap;
        }
    };
    bucketEndpoint.setClient(clientStub);
    rootEndpoint = new RootEndpoint();
    rootEndpoint.setClient(clientStub);
    keyEndpoint = new ObjectEndpoint() {

        @Override
        protected Map<String, String> getAuditParameters() {
            return parametersMap;
        }
    };
    keyEndpoint.setClient(clientStub);
    keyEndpoint.setOzoneConfiguration(new OzoneConfiguration());
}
Also used : BucketEndpoint(org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint) ObjectEndpoint(org.apache.hadoop.ozone.s3.endpoint.ObjectEndpoint) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OzoneClientStub(org.apache.hadoop.ozone.client.OzoneClientStub) RootEndpoint(org.apache.hadoop.ozone.s3.endpoint.RootEndpoint) HashMap(java.util.HashMap) Map(java.util.Map) Before(org.junit.Before)

Example 15 with OzoneClientStub

use of org.apache.hadoop.ozone.client.OzoneClientStub in project ozone by apache.

the class TestAbortMultipartUpload method testAbortMultipartUpload.

@Test
public void testAbortMultipartUpload() throws Exception {
    String bucket = OzoneConsts.S3_BUCKET;
    String key = OzoneConsts.KEY;
    OzoneClient client = new OzoneClientStub();
    client.getObjectStore().createS3Bucket(bucket);
    HttpHeaders headers = Mockito.mock(HttpHeaders.class);
    when(headers.getHeaderString(STORAGE_CLASS_HEADER)).thenReturn("STANDARD");
    ObjectEndpoint rest = new ObjectEndpoint();
    rest.setHeaders(headers);
    rest.setClient(client);
    rest.setOzoneConfiguration(new OzoneConfiguration());
    Response response = rest.initializeMultipartUpload(bucket, key);
    assertEquals(200, response.getStatus());
    MultipartUploadInitiateResponse multipartUploadInitiateResponse = (MultipartUploadInitiateResponse) response.getEntity();
    assertNotNull(multipartUploadInitiateResponse.getUploadID());
    String uploadID = multipartUploadInitiateResponse.getUploadID();
    // Abort multipart upload
    response = rest.delete(bucket, key, uploadID);
    assertEquals(204, response.getStatus());
    // test with unknown upload Id.
    try {
        rest.delete(bucket, key, "random");
    } catch (OS3Exception ex) {
        assertEquals(S3ErrorTable.NO_SUCH_UPLOAD.getCode(), ex.getCode());
        assertEquals(S3ErrorTable.NO_SUCH_UPLOAD.getErrorMessage(), ex.getErrorMessage());
    }
}
Also used : Response(javax.ws.rs.core.Response) HttpHeaders(javax.ws.rs.core.HttpHeaders) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OzoneClientStub(org.apache.hadoop.ozone.client.OzoneClientStub) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) OS3Exception(org.apache.hadoop.ozone.s3.exception.OS3Exception) Test(org.junit.Test)

Aggregations

OzoneClientStub (org.apache.hadoop.ozone.client.OzoneClientStub)19 OzoneClient (org.apache.hadoop.ozone.client.OzoneClient)11 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)9 Before (org.junit.Before)9 HttpHeaders (javax.ws.rs.core.HttpHeaders)8 Test (org.junit.Test)7 Response (javax.ws.rs.core.Response)5 OzoneBucket (org.apache.hadoop.ozone.client.OzoneBucket)5 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Map (java.util.Map)2 BucketEndpoint (org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint)2 DeleteObject (org.apache.hadoop.ozone.s3.endpoint.MultiDeleteRequest.DeleteObject)2 ObjectEndpoint (org.apache.hadoop.ozone.s3.endpoint.ObjectEndpoint)2 RootEndpoint (org.apache.hadoop.ozone.s3.endpoint.RootEndpoint)2 BeforeClass (org.junit.BeforeClass)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ECReplicationConfig (org.apache.hadoop.hdds.client.ECReplicationConfig)1 OzoneInputStream (org.apache.hadoop.ozone.client.io.OzoneInputStream)1