Skip to content

Commit fc08e58

Browse files
authored
Merge pull request #357 from GraciesPadre/fix_integration_tests
Fix integration tests
2 parents cf58378 + 6976138 commit fc08e58

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/GetJobManagement_Test.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.google.common.collect.Lists;
1919
import com.spectralogic.ds3client.Ds3Client;
2020
import com.spectralogic.ds3client.Ds3ClientImpl;
21+
import com.spectralogic.ds3client.commands.DeleteObjectRequest;
2122
import com.spectralogic.ds3client.commands.GetObjectRequest;
2223
import com.spectralogic.ds3client.commands.GetObjectResponse;
2324
import com.spectralogic.ds3client.commands.PutObjectRequest;
@@ -32,6 +33,7 @@
3233
import com.spectralogic.ds3client.integration.test.helpers.TempStorageIds;
3334
import com.spectralogic.ds3client.integration.test.helpers.TempStorageUtil;
3435
import com.spectralogic.ds3client.models.ChecksumType;
36+
import com.spectralogic.ds3client.models.Contents;
3537
import com.spectralogic.ds3client.models.Priority;
3638
import com.spectralogic.ds3client.models.bulk.Ds3Object;
3739
import com.spectralogic.ds3client.models.bulk.PartialDs3Object;
@@ -178,6 +180,7 @@ public void createReadJobWithBigFile() throws IOException, URISyntaxException, N
178180

179181
} finally {
180182
FileUtils.deleteDirectory(tempDirectory.toFile());
183+
deleteBigFile();
181184
}
182185
}
183186

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

214+
private void deleteBigFile() throws IOException {
215+
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
216+
217+
final Iterable<Contents> objects = helpers.listObjects(BUCKET_NAME);
218+
for (final Contents contents : objects) {
219+
if (contents.getKey().equals("lesmis-copies.txt")) {
220+
client.deleteObject(new DeleteObjectRequest(BUCKET_NAME, contents.getKey()));
221+
}
222+
}
223+
}
211224

212225
@Test
213226
public void createReadJobWithPriorityOption() throws IOException,
@@ -293,6 +306,7 @@ public void testPartialRetriesWithInjectedFailures() throws NoSuchMethodExceptio
293306
}
294307
} finally {
295308
FileUtils.deleteDirectory(tempDirectory.toFile());
309+
deleteBigFile();
296310
}
297311
}
298312
}

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/Smoke_Test.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,24 +931,30 @@ public SeekableByteChannel buildChannel(final String key) throws IOException {
931931

932932
@Test
933933
public void partialGetWithBookOverChunkBoundry() throws IOException, URISyntaxException {
934+
final String DIR_NAME = "largeFiles/";
935+
final String FILE_NAME = "lesmis-copies.txt";
936+
937+
final Path objPath = ResourceUtils.loadFileResource(DIR_NAME + FILE_NAME);
938+
final long bookSize = Files.size(objPath);
939+
934940
final String bucketName = "partialGetOnBook";
935-
final Path filePath = Files.createTempFile("ds3", "lesmis-copies.txt");
941+
final Path filePath = Files.createTempFile("ds3", FILE_NAME);
936942
LOG.info("TempFile for partial get of book: " + filePath.toAbsolutePath().toString());
937943

938944
try {
939945

940946
HELPERS.ensureBucketExists(bucketName, envDataPolicyId);
941947

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

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

948-
putJob.transfer(new ResourceObjectPutter("largeFiles/"));
954+
putJob.transfer(new ResourceObjectPutter(DIR_NAME));
949955

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

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

@@ -964,7 +970,7 @@ public SeekableByteChannel buildChannel(final String key) throws IOException {
964970
assertThat(Files.size(filePath), is(200L));
965971
final String partialFile = new String(Files.readAllBytes(filePath), Charset.forName("UTF-8"));
966972
final String expectedResult = new String(Files.readAllBytes(expectedResultPath), Charset.forName("UTF-8"));
967-
assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length() - 1))); // need the trim to remove a newline that is added by the os
973+
assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length())));
968974
} finally {
969975
deleteAllContents(client, bucketName);
970976
Files.delete(filePath);
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
antern, on the dark side of the street. One of the three entered the
2-
alley leading to the commissary's house. The one who marched at their
3-
head struck him as decidedly suspicious.
4-
5-
"Come, child,"
1+
lantern-post of the
2+
blind alley Genrot.
3+
4+
At that epoch there were no gas-jets in the streets of Paris. At
5+
nightfall lanterns placed at regular distances were lighted; they were
6+
ascended and descended

0 commit comments

Comments
 (0)