|
43 | 43 | import com.spectralogic.ds3client.commands.GetBucketResponse; |
44 | 44 | import com.spectralogic.ds3client.commands.GetObjectRequest; |
45 | 45 | import com.spectralogic.ds3client.commands.GetObjectResponse; |
46 | | -import com.spectralogic.ds3client.commands.spectrads3.CancelJobSpectraS3Request; |
| 46 | +import com.spectralogic.ds3client.commands.spectrads3.*; |
47 | 47 | import com.spectralogic.ds3client.helpers.Ds3ClientHelpers; |
48 | 48 | import com.spectralogic.ds3client.helpers.FileObjectPutter; |
49 | 49 | import com.spectralogic.ds3client.helpers.FolderNameFilter; |
50 | 50 | import com.spectralogic.ds3client.models.ChecksumType; |
51 | 51 | import com.spectralogic.ds3client.models.Contents; |
| 52 | +import com.spectralogic.ds3client.models.VersioningLevel; |
52 | 53 | import com.spectralogic.ds3client.models.bulk.Ds3Object; |
53 | 54 | import com.spectralogic.ds3client.utils.Platform; |
54 | 55 | import com.spectralogic.ds3client.utils.ResourceUtils; |
@@ -90,10 +91,11 @@ public class FeatureIntegration_Test { |
90 | 91 | private static final Ds3ClientHelpers HELPERS = Ds3ClientHelpers.wrap(client); |
91 | 92 | private static final String TEST_ENV_NAME = "FeatureIntegration_Test"; |
92 | 93 | private static TempStorageIds envStorageIds; |
| 94 | + private static UUID envDataPolicyId; |
93 | 95 |
|
94 | 96 | @BeforeClass |
95 | 97 | public static void startup() throws IOException { |
96 | | - final UUID envDataPolicyId = TempStorageUtil.setupDataPolicy(TEST_ENV_NAME, false, ChecksumType.Type.MD5, client); |
| 98 | + envDataPolicyId = TempStorageUtil.setupDataPolicy(TEST_ENV_NAME, false, ChecksumType.Type.MD5, VersioningLevel.NONE, client); |
97 | 99 | envStorageIds = TempStorageUtil.setup(TEST_ENV_NAME, envDataPolicyId, client); |
98 | 100 | } |
99 | 101 |
|
@@ -260,7 +262,7 @@ public void getCompletedJob() throws Exception { |
260 | 262 |
|
261 | 263 | final String expectedBeginning = "JobId: " + readJob.getJobId() + " | Name: "; |
262 | 264 | final String expectedMiddle = "Status: COMPLETED | Bucket: " + bucketName + " | Type: GET | Priority:"; |
263 | | - final String expectedEnding = " | Total Size: " + objSize + " | Total Transferred: " ; |
| 265 | + final String expectedEnding = " | Total Size: " + objSize + " | Total Transferred: "; |
264 | 266 |
|
265 | 267 | assertTrue(getJobResponse.getMessage().startsWith(expectedBeginning)); |
266 | 268 | assertTrue(getJobResponse.getMessage().contains(expectedMiddle)); |
@@ -546,7 +548,7 @@ public void putBulkObjectWithPrefix() throws Exception { |
546 | 548 | "-c", "put_bulk", |
547 | 549 | "-b", bucketName, |
548 | 550 | "-d", Util.RESOURCE_BASE_NAME, |
549 | | - "-p" , prefix, |
| 551 | + "-p", prefix, |
550 | 552 | "--sync"}); |
551 | 553 | final CommandResponse response = Util.command(client, args); |
552 | 554 | assertThat(response.getMessage(), is(String.format("SUCCESS: Wrote all the files in %s to bucket %s", "." + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "books", bucketName))); |
@@ -720,6 +722,49 @@ public void metadataPut() throws Exception { |
720 | 722 | } |
721 | 723 | } |
722 | 724 |
|
| 725 | + @Test |
| 726 | + public void testPutObjectWithVersion() throws Exception { |
| 727 | + final String bucketName = "test_put_object_with_version"; |
| 728 | + final UUID setupDataPolicy = TempStorageUtil.setupDataPolicy(bucketName, false, ChecksumType.Type.CRC_32, VersioningLevel.KEEP_MULTIPLE_VERSIONS, client); |
| 729 | + final TempStorageIds tempStorageIds = TempStorageUtil.setup(bucketName, setupDataPolicy, client); |
| 730 | + |
| 731 | + try { |
| 732 | + client.putBucketSpectraS3(new PutBucketSpectraS3Request(bucketName).withDataPolicyId(setupDataPolicy.toString())); |
| 733 | + |
| 734 | + final Arguments args = new Arguments(new String[]{"--http", "-c", "put_object", "-b", bucketName, "-o", "src/test/resources/books/beowulf.txt"}); |
| 735 | + final CommandResponse response = Util.command(client, args); |
| 736 | + final CommandResponse responseAgain = Util.command(client, args); |
| 737 | + |
| 738 | + assertThat(response.getReturnCode(), is(0)); |
| 739 | + assertThat(responseAgain.getReturnCode(), is(0)); |
| 740 | + |
| 741 | + final Arguments getBucket = new Arguments(new String[]{"--http", "-c", "get_bucket", "-b", bucketName, "-v"}); |
| 742 | + final CommandResponse getBucketResponse = Util.command(client, getBucket); |
| 743 | + final String bucketMessage = getBucketResponse.getMessage(); |
| 744 | + final String[] lines = bucketMessage.split("\\n"); |
| 745 | + final String line9 = lines[9]; |
| 746 | + final String line10 = lines[10]; |
| 747 | + final String[] line9Split = line9.split("\\|"); |
| 748 | + final String[] line10Split = line10.split("\\|"); |
| 749 | + final String versionIdOne = line9Split[6].trim(); |
| 750 | + final String versionIdTwo = line10Split[6].trim(); |
| 751 | + assertThat(versionIdOne, not(versionIdTwo)); |
| 752 | + |
| 753 | + final Arguments getFirst = new Arguments(new String[]{"--http", "-c", "get_object", "-b", bucketName, "-o", "src/test/resources/books/beowulf.txt", "--versionId", versionIdOne}); |
| 754 | + final Arguments getSecond = new Arguments(new String[]{"--http", "-c", "get_object", "-b", bucketName, "-o", "src/test/resources/books/beowulf.txt", "--versionId", versionIdTwo}); |
| 755 | + final CommandResponse getFirstResponse = Util.command(client, getFirst); |
| 756 | + final CommandResponse getSecondResponse = Util.command(client, getSecond); |
| 757 | + |
| 758 | + assertThat(getFirstResponse.getReturnCode(), is(0)); |
| 759 | + assertThat(getSecondResponse.getReturnCode(), is(0)); |
| 760 | + } finally { |
| 761 | + client.deleteBucketSpectraS3(new DeleteBucketSpectraS3Request(bucketName).withForce(true)); |
| 762 | + TempStorageUtil.teardown(bucketName, tempStorageIds, client); |
| 763 | + client.modifyUserSpectraS3(new ModifyUserSpectraS3Request("Administrator") |
| 764 | + .withDefaultDataPolicyId(envDataPolicyId)); |
| 765 | + } |
| 766 | + } |
| 767 | + |
723 | 768 | @Test |
724 | 769 | public void testPutObjectWithFileMetadata() throws Exception { |
725 | 770 | Assume.assumeFalse(Platform.isWindows()); |
@@ -832,7 +877,7 @@ public void getPhysicalPlacement() throws Exception { |
832 | 877 | Util.createBucket(client, bucketName); |
833 | 878 | Util.loadBookTestData(client, bucketName); |
834 | 879 |
|
835 | | - final Arguments args = new Arguments(new String[]{"--http", "-c", "get_physical_placement", "-b", bucketName, "-o", "beowulf.txt" }); |
| 880 | + final Arguments args = new Arguments(new String[]{"--http", "-c", "get_physical_placement", "-b", bucketName, "-o", "beowulf.txt"}); |
836 | 881 | final CommandResponse response = Util.command(client, args); |
837 | 882 | assertTrue(response.getMessage().contains("| Object Name | ID | In Cache | Length | Offset | Latest | Version |")); |
838 | 883 | assertTrue(response.getMessage().contains("| beowulf.txt |")); |
@@ -901,7 +946,7 @@ public void getBulkWithPipeMissingFile() throws Exception { |
901 | 946 | } |
902 | 947 | } |
903 | 948 |
|
904 | | - @Test (expected = com.spectralogic.ds3client.helpers.JobRecoveryNotActiveException.class) |
| 949 | + @Test(expected = com.spectralogic.ds3client.helpers.JobRecoveryNotActiveException.class) |
905 | 950 | public void recoverGetBulk() throws Exception { |
906 | 951 | assumeThat(Util.getBlackPearlVersion(client), greaterThan(1.2)); |
907 | 952 |
|
@@ -1084,7 +1129,7 @@ private Path createAFile(final String fileName) throws Exception { |
1084 | 1129 | final Path filePath = Paths.get(fileName); |
1085 | 1130 | final Path createdFilePath = Files.createFile(filePath); |
1086 | 1131 |
|
1087 | | - write(createdFilePath, new byte[] { 0 }); |
| 1132 | + write(createdFilePath, new byte[]{0}); |
1088 | 1133 |
|
1089 | 1134 | return createdFilePath; |
1090 | 1135 | } |
|
0 commit comments