Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.common.collect.Lists;
import com.spectralogic.ds3client.Ds3Client;
import com.spectralogic.ds3client.Ds3ClientImpl;
import com.spectralogic.ds3client.commands.DeleteObjectRequest;
import com.spectralogic.ds3client.commands.GetObjectRequest;
import com.spectralogic.ds3client.commands.GetObjectResponse;
import com.spectralogic.ds3client.commands.PutObjectRequest;
Expand All @@ -32,6 +33,7 @@
import com.spectralogic.ds3client.integration.test.helpers.TempStorageIds;
import com.spectralogic.ds3client.integration.test.helpers.TempStorageUtil;
import com.spectralogic.ds3client.models.ChecksumType;
import com.spectralogic.ds3client.models.Contents;
import com.spectralogic.ds3client.models.Priority;
import com.spectralogic.ds3client.models.bulk.Ds3Object;
import com.spectralogic.ds3client.models.bulk.PartialDs3Object;
Expand Down Expand Up @@ -178,6 +180,7 @@ public void createReadJobWithBigFile() throws IOException, URISyntaxException, N

} finally {
FileUtils.deleteDirectory(tempDirectory.toFile());
deleteBigFile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will delete the file from BUCKET_NAME, but wasn't the file placed in DIR_NAME in this test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm

}
}

Expand Down Expand Up @@ -208,6 +211,16 @@ private void putBigFile() throws IOException, URISyntaxException {
writeJob.transfer(new FileObjectPutter(dirPath));
}

private void deleteBigFile() throws IOException {
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);

final Iterable<Contents> objects = helpers.listObjects(BUCKET_NAME);
for (final Contents contents : objects) {
if (contents.getKey().equals("lesmis-copies.txt")) {
client.deleteObject(new DeleteObjectRequest(BUCKET_NAME, contents.getKey()));
}
}
}

@Test
public void createReadJobWithPriorityOption() throws IOException,
Expand Down Expand Up @@ -293,6 +306,7 @@ public void testPartialRetriesWithInjectedFailures() throws NoSuchMethodExceptio
}
} finally {
FileUtils.deleteDirectory(tempDirectory.toFile());
deleteBigFile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -931,24 +931,30 @@ public SeekableByteChannel buildChannel(final String key) throws IOException {

@Test
public void partialGetWithBookOverChunkBoundry() throws IOException, URISyntaxException {
final String DIR_NAME = "largeFiles/";
final String FILE_NAME = "lesmis-copies.txt";

final Path objPath = ResourceUtils.loadFileResource(DIR_NAME + FILE_NAME);
final long bookSize = Files.size(objPath);

final String bucketName = "partialGetOnBook";
final Path filePath = Files.createTempFile("ds3", "lesmis-copies.txt");
final Path filePath = Files.createTempFile("ds3", FILE_NAME);
LOG.info("TempFile for partial get of book: " + filePath.toAbsolutePath().toString());

try {

HELPERS.ensureBucketExists(bucketName, envDataPolicyId);

final List<Ds3Object> putObjects = Lists.newArrayList(new Ds3Object("lesmis-copies.txt", 13290604));
final List<Ds3Object> putObjects = Lists.newArrayList(new Ds3Object(FILE_NAME, bookSize));

final Ds3ClientHelpers.Job putJob = HELPERS
.startWriteJob(bucketName, putObjects, WriteJobOptions.create()
.withMaxUploadSize(PutBulkJobSpectraS3Request.MIN_UPLOAD_SIZE_IN_BYTES));

putJob.transfer(new ResourceObjectPutter("largeFiles/"));
putJob.transfer(new ResourceObjectPutter(DIR_NAME));

final List<Ds3Object> getObjects = Lists.newArrayList();
getObjects.add(new PartialDs3Object("lesmis-copies.txt", Range.byLength(1048476, 200)));
getObjects.add(new PartialDs3Object(FILE_NAME, Range.byLength(1048476, 200)));

final Ds3ClientHelpers.Job getJob = HELPERS.startReadJob(bucketName, getObjects);

Expand All @@ -964,7 +970,7 @@ public SeekableByteChannel buildChannel(final String key) throws IOException {
assertThat(Files.size(filePath), is(200L));
final String partialFile = new String(Files.readAllBytes(filePath), Charset.forName("UTF-8"));
final String expectedResult = new String(Files.readAllBytes(expectedResultPath), Charset.forName("UTF-8"));
assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length() - 1))); // need the trim to remove a newline that is added by the os
assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length())));
} finally {
deleteAllContents(client, bucketName);
Files.delete(filePath);
Expand Down
11 changes: 6 additions & 5 deletions ds3-sdk-integration/src/test/resources/largeFiles/output
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
antern, on the dark side of the street. One of the three entered the
alley leading to the commissary's house. The one who marched at their
head struck him as decidedly suspicious.

"Come, child,"
lantern-post of the
blind alley Genrot.

At that epoch there were no gas-jets in the streets of Paris. At
nightfall lanterns placed at regular distances were lighted; they were
ascended and descended