Skip to content

Commit 4d95540

Browse files
authored
Merge pull request #193 from scribe/five.0
Java CLI with all tests passing
2 parents 55336f1 + 72d66e1 commit 4d95540

File tree

12 files changed

+315
-298
lines changed

12 files changed

+315
-298
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ subprojects {
5252
compile 'ch.qos.logback:logback-core:1.2.3'
5353
compile 'ch.qos.logback:logback-classic:1.2.3'
5454
compile 'com.google.guava:guava:23.0-jre'
55-
compile 'com.spectralogic.ds3:ds3-sdk:3.5.4'
55+
compile 'com.spectralogic.ds3:ds3-sdk:5.0.2'
5656
compile 'com.google.inject:guice:4.2.0'
5757

5858
testCompile ('org.mockito:mockito-core:1.10.19') {

ds3-cli-certification/src/test/java/com/spectralogic/ds3cli/certification/Certification_Test.java

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.google.common.collect.Iterables;
2121
import com.spectralogic.ds3cli.CommandResponse;
2222
import com.spectralogic.ds3cli.exceptions.*;
23+
import com.spectralogic.ds3cli.helpers.TempStorageIds;
24+
import com.spectralogic.ds3cli.helpers.TempStorageUtil;
2325
import com.spectralogic.ds3cli.helpers.Util;
2426
import com.spectralogic.ds3client.Ds3Client;
2527
import com.spectralogic.ds3client.Ds3ClientBuilder;
@@ -30,10 +32,7 @@
3032
import com.spectralogic.ds3client.models.common.Credentials;
3133
import com.spectralogic.ds3client.networking.FailedRequestException;
3234
import org.apache.commons.io.FileUtils;
33-
import org.junit.AfterClass;
34-
import org.junit.BeforeClass;
35-
import org.junit.FixMethodOrder;
36-
import org.junit.Test;
35+
import org.junit.*;
3736
import org.junit.runners.MethodSorters;
3837
import org.slf4j.Logger;
3938
import org.slf4j.LoggerFactory;
@@ -45,6 +44,7 @@
4544
import java.util.*;
4645

4746
import static com.spectralogic.ds3cli.certification.CertificationUtil.*;
47+
import static com.spectralogic.ds3cli.helpers.TempStorageUtil.setupDataPolicy;
4848
import static com.spectralogic.ds3cli.helpers.TempStorageUtil.verifyAvailableTapePartition;
4949
import static junit.framework.TestCase.assertFalse;
5050
import static org.hamcrest.CoreMatchers.is;
@@ -56,10 +56,10 @@
5656

5757
/**
5858
* Implement tests to automate the BlackPearl Certification process for the JavaCLI.
59-
*
59+
* <p>
6060
* For details, refer to
61-
* https://developer.spectralogic.com/certification/
62-
* https://developer.spectralogic.com/test-plan/
61+
* https://developer.spectralogic.com/certification/
62+
* https://developer.spectralogic.com/test-plan/
6363
*/
6464
@FixMethodOrder(MethodSorters.NAME_ASCENDING) // Order only matters for manually verifying the results
6565

@@ -74,6 +74,7 @@ public class Certification_Test {
7474
private static UUID envDataPolicyId;
7575

7676
private final static Ds3ExceptionHandlerMapper EXCEPTION_MAPPER = Ds3ExceptionHandlerMapper.getInstance();
77+
7778
static {
7879
EXCEPTION_MAPPER.addHandler(FailedRequestException.class, new FailedRequestExceptionHandler());
7980
EXCEPTION_MAPPER.addHandler(RuntimeException.class, new RuntimeExceptionHandler());
@@ -133,7 +134,7 @@ public void test_7_2_1_invalid_credentials() throws Exception {
133134

134135
try {
135136
Util.command(invalid_client, "--http -c get_service");
136-
} catch(final FailedRequestException e) {
137+
} catch (final FailedRequestException e) {
137138
final String formattedException = FailedRequestExceptionHandler.format(e);
138139
OUT.insertPreformat(formattedException);
139140
final String expectedError = "permissions / authorization error";
@@ -155,7 +156,7 @@ public void test_7_2_2_invalid_endpoint() throws Exception {
155156
boolean success = false;
156157
try {
157158
Util.command(invalid_client, "--http -c get_service");
158-
} catch(final UnknownHostException uhe) {
159+
} catch (final UnknownHostException uhe) {
159160
final String formattedException = ExceptionFormatter.format(uhe);
160161
final String expectedError = "UnknownHost";
161162
assertThat(formattedException, containsString(expectedError));
@@ -177,7 +178,7 @@ public void test_7_3_1_list_nonexistent_bucket() throws Exception {
177178

178179
try {
179180
Util.command(client, "--http -c get_bucket -b " + bucketName);
180-
} catch(final CommandException ce) {
181+
} catch (final CommandException ce) {
181182
final String formattedException = ExceptionFormatter.format(ce);
182183
assertThat(formattedException, containsString("Error: Unknown bucket."));
183184
OUT.insertLog("CommandResponse for 7.3.1 failed attempt to list nonexistent bucket:");
@@ -212,7 +213,7 @@ public void test_7_3_2_access_bucket_wrong_user() throws Exception {
212213
// Attempt to access the bucket with the new user, which should fail
213214
final String listBucketCmd = "--http -c get_bucket -b " + bucketName;
214215
Util.command(invalid_client, listBucketCmd);
215-
} catch(final FailedRequestException e) {
216+
} catch (final FailedRequestException e) {
216217
final String formattedException = FailedRequestExceptionHandler.format(e);
217218
final String expectedError = "permissions / authorization error";
218219
assertThat(formattedException, containsString(expectedError));
@@ -250,7 +251,7 @@ public void test_7_4_get_nonexistent_object() throws Exception {
250251
final CommandResponse getNonExtandObjectResponse = Util.command(client, getNonExtantObject);
251252
OUT.insertCommand(getNonExtantObject, getNonExtandObjectResponse.getMessage());
252253

253-
} catch(final FailedRequestException fre) {
254+
} catch (final FailedRequestException fre) {
254255
final String formattedException = FailedRequestExceptionHandler.format(fre);
255256
final String expectedError = "not found";
256257
assertThat(formattedException, containsString(expectedError));
@@ -266,6 +267,7 @@ public void test_7_4_get_nonexistent_object() throws Exception {
266267

267268
/**
268269
* 7.5-7: Archive and Restore 3 objects larger than the chunk size to BP simultaneously.
270+
*
269271
* @throws Exception
270272
*/
271273
@Test
@@ -282,6 +284,7 @@ public void test_7_5_and_6_bulk_performance_3x110GB() throws Exception {
282284

283285
/**
284286
* 7.7-8: Archive 250 objects of approximately 1GB size to BP.
287+
*
285288
* @throws Exception
286289
*/
287290
@Test
@@ -323,7 +326,7 @@ private static boolean testBulkPutAndBulkGetPerformance(
323326

324327
OUT.insertLog("Bulk PUT from bucket " + bucketName);
325328
final long startPutTime = getCurrentTime();
326-
final String putBulkCmd = "--http -c put_bulk -b " + bucketName + " -d " + bulkPutLocalTempDir.toString();
329+
final String putBulkCmd = "--http -c put_bulk -b " + bucketName + " -d " + bulkPutLocalTempDir.toString();
327330
final CommandResponse putBulkResponse = Util.command(client, putBulkCmd);
328331
OUT.insertCommand(putBulkCmd, putBulkResponse.getMessage());
329332
final long endPutTime = getCurrentTime();
@@ -368,14 +371,20 @@ public void test_8_1_versioning() throws Exception {
368371
final Long fileSize = 1024L;
369372
final String bucketName = CertificationUtil.getBucketName(testDescription);
370373
boolean success = false;
374+
final UUID dataPolicy = setupDataPolicy(testDescription, false, ChecksumType.Type.MD5, client);
375+
final TempStorageIds tempStorageIds = TempStorageUtil.setup(testDescription, dataPolicy, client);
376+
371377

372378
OUT.startNewTest(testDescription);
373379
try {
380+
374381
OUT.insertLog("Set data policy to use versioning");
375-
final String enableDataPolicyVersioningCmd = "--http -c modify_data_policy --modify-params versioning:KEEP_LATEST -i " + envDataPolicyId;
382+
final String enableDataPolicyVersioningCmd = "--http -c modify_data_policy --modify-params versioning:KEEP_LATEST -i " + dataPolicy;
376383
final CommandResponse modifyDataPolicyResponse = Util.command(client, enableDataPolicyVersioningCmd);
377384
OUT.insertCommand(enableDataPolicyVersioningCmd, modifyDataPolicyResponse.getMessage());
378385
assertThat(modifyDataPolicyResponse.getReturnCode(), is(0));
386+
client.modifyUserSpectraS3(new ModifyUserSpectraS3Request("Administrator")
387+
.withDefaultDataPolicyId(dataPolicy));
379388

380389
// create and store one file
381390
Path bulkPutLocalTempDir = CertificationUtil.createTempFiles(bucketName, numFiles, fileSize);
@@ -407,11 +416,9 @@ public void test_8_1_versioning() throws Exception {
407416
} catch (final Exception e) {
408417
LOG.error("Exception: {}", e.getMessage(), e);
409418
} finally {
410-
Util.deleteBucket(client, bucketName);
411-
412-
// undo versioning
413-
Util.command(client, "--http -c modify_data_policy --modify-params versioning:NONE -i " + envDataPolicyId);
414-
419+
client.modifyUserSpectraS3(new ModifyUserSpectraS3Request("Administrator")
420+
.withDefaultDataPolicyId(envDataPolicyId));
421+
TempStorageUtil.teardown(testDescription, tempStorageIds, client);
415422
OUT.finishTest(testDescription, success);
416423
assertTrue(testDescription + " did not complete", success);
417424
}
@@ -432,7 +439,7 @@ public void test_8_2_partial_restore() throws Exception {
432439
try {
433440
final Path bulkPutLocalTempDir = CertificationUtil.createTempFiles(bucketName, numFiles, fileSize);
434441

435-
final String putBulkCmd = "--http -c put_bulk -b " + bucketName + " -d " + bulkPutLocalTempDir.toString();
442+
final String putBulkCmd = "--http -c put_bulk -b " + bucketName + " -d " + bulkPutLocalTempDir.toString();
436443
final CommandResponse putBulkResponse = Util.command(client, putBulkCmd);
437444
OUT.insertCommand(putBulkCmd, putBulkResponse.getMessage());
438445
assertThat(putBulkResponse.getReturnCode(), is(0));
@@ -445,7 +452,7 @@ public void test_8_2_partial_restore() throws Exception {
445452
OUT.insertPreformat(objectName);
446453

447454
// restore first 100 bytes
448-
final String getPartialObjectCmd = "--http -c get_object --range-offset 0 --range-length 100 -b " + bucketName + " -o " + objectName + " -d " + bulkPutLocalTempDir.toString();
455+
final String getPartialObjectCmd = "--http -c get_object --range-offset 0 --range-length 100 -b " + bucketName + " -o " + objectName + " -d " + bulkPutLocalTempDir.toString();
449456
final CommandResponse getPartialResponse = Util.command(client, getPartialObjectCmd);
450457
OUT.insertCommand(getPartialObjectCmd, getPartialResponse.getMessage());
451458
assertThat(getPartialResponse.getReturnCode(), is(0));
@@ -455,11 +462,11 @@ public void test_8_2_partial_restore() throws Exception {
455462
final com.spectralogic.ds3cli.util.FileUtils.ObjectsToPut objectsToPut = com.spectralogic.ds3cli.util.FileUtils.getObjectsToPut(filesToPut, bulkPutLocalTempDir, "", true);
456463
final Ds3Object obj = objectsToPut.getDs3Objects().get(0);
457464
assertTrue(obj.getSize() < 150);
458-
OUT.insertLog(obj.getName() + " size: " + Long.toString(obj.getSize()));
465+
OUT.insertLog(obj.getName() + " size: " + Long.toString(obj.getSize()));
459466
success = true;
460467

461468
} catch (final Exception e) {
462-
LOG.error("Exception in " + testDescription, e );
469+
LOG.error("Exception in " + testDescription, e);
463470
} finally {
464471
OUT.finishTest(testDescription, success);
465472
Util.deleteBucket(client, bucketName);
@@ -501,7 +508,7 @@ public void test_8_4_change_priorities() throws Exception {
501508
success = true;
502509

503510
} catch (final Exception e) {
504-
LOG.error("Exception in " + testDescription, e );
511+
LOG.error("Exception in " + testDescription, e);
505512
} finally {
506513
OUT.finishTest(testDescription, success);
507514
CertificationUtil.deleteJob(client, jobId);
@@ -551,7 +558,7 @@ public boolean apply(@Nullable final Tape tape) {
551558
assertTrue(postEjectResponse.getMessage().contains(ejectLocation));
552559
success = true;
553560
} catch (final Exception e) {
554-
LOG.error("Exception in " + testDescription, e );
561+
LOG.error("Exception in " + testDescription, e);
555562
} finally {
556563
CertificationUtil.cancelTapeEject(client, barcode);
557564
OUT.finishTest(testDescription, success);
@@ -587,7 +594,7 @@ public void test_8_6_fully_persisted() throws Exception {
587594
// Create temp files for BULK_PUT
588595
final Path bulkPutLocalTempDir = CertificationUtil.createTempFiles(bucketName, numFiles, fileSize);
589596

590-
final String putBulkCmd = "--http -c put_bulk -b " + bucketName + " -d " + bulkPutLocalTempDir.toString();
597+
final String putBulkCmd = "--http -c put_bulk -b " + bucketName + " -d " + bulkPutLocalTempDir.toString();
591598
final CommandResponse putBulkResponse = Util.command(client, putBulkCmd);
592599
assertThat(putBulkResponse.getReturnCode(), is(0));
593600

@@ -620,7 +627,7 @@ public void test_8_6_fully_persisted() throws Exception {
620627
final CommandResponse getPhysicalPlacementAfterResponse = Util.command(client, getPhysicalPlacementCmd);
621628
OUT.insertCommand(getPhysicalPlacementCmd, getPhysicalPlacementAfterResponse.getMessage());
622629
} catch (final Exception e) {
623-
LOG.error("Exception in " + testDescription, e );
630+
LOG.error("Exception in " + testDescription, e);
624631
} finally {
625632
OUT.finishTest(testDescription, success);
626633
Util.deleteBucket(client, bucketName);
@@ -642,16 +649,16 @@ public void test_8_7_large_list() throws Exception {
642649
boolean success = false;
643650
try {
644651
// Put 500 files into bucket
645-
final CommandResponse performanceResponse = Util.putPerformanceFiles(client, bucketName, numFiles, fileSize);
652+
final CommandResponse performanceResponse = Util.putPerformanceFiles(client, bucketName, numFiles, fileSize);
646653
assertThat(performanceResponse.getReturnCode(), is(0));
647654

648655
final String listBucketArgs = "--http -c get_bucket -b " + bucketName;
649-
final CommandResponse getBucketResponseAfterBulkPut = Util.command(client, listBucketArgs);
656+
final CommandResponse getBucketResponseAfterBulkPut = Util.command(client, listBucketArgs);
650657
OUT.insertCommand(listBucketArgs, getBucketResponseAfterBulkPut.getMessage());
651658
assertThat(getBucketResponseAfterBulkPut.getReturnCode(), is(0));
652659
success = true;
653660
} catch (final Exception e) {
654-
LOG.error("Exception in " + testDescription, e );
661+
LOG.error("Exception in " + testDescription, e);
655662
} finally {
656663
OUT.finishTest(testDescription, success);
657664
Util.deleteBucket(client, bucketName);

ds3-cli-integration/src/test/java/com/spectralogic/ds3cli/integration/FeatureIntegration_Test.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.spectralogic.ds3client.commands.GetBucketResponse;
4444
import com.spectralogic.ds3client.commands.GetObjectRequest;
4545
import com.spectralogic.ds3client.commands.GetObjectResponse;
46+
import com.spectralogic.ds3client.commands.spectrads3.CancelJobSpectraS3Request;
4647
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
4748
import com.spectralogic.ds3client.helpers.FileObjectPutter;
4849
import com.spectralogic.ds3client.helpers.FolderNameFilter;
@@ -833,9 +834,9 @@ public void getPhysicalPlacement() throws Exception {
833834

834835
final Arguments args = new Arguments(new String[]{"--http", "-c", "get_physical_placement", "-b", bucketName, "-o", "beowulf.txt" });
835836
final CommandResponse response = Util.command(client, args);
836-
assertTrue(response.getMessage().contains("| Object Name | ID | In Cache | Length | Offset | Latest | Version |"));
837+
assertTrue(response.getMessage().contains("| Object Name | ID | In Cache | Length | Offset | Latest | Version |"));
837838
assertTrue(response.getMessage().contains("| beowulf.txt |"));
838-
assertTrue(response.getMessage().contains("| true | 294059 | 0 | true | 1 |"));
839+
assertTrue(response.getMessage().contains("| true | 294059 | 0 | true |"));
839840

840841
} finally {
841842
Util.deleteBucket(client, bucketName);
@@ -1254,6 +1255,7 @@ public void testResettingDeadJobTimerWithModifyJob() throws Exception {
12541255
assertNotNull(response);
12551256
assertNotNull(response.getMessage());
12561257
assertFalse(response.getMessage().isEmpty());
1258+
client.cancelJobSpectraS3(new CancelJobSpectraS3Request(job.getJobId()));
12571259
} finally {
12581260
Util.deleteBucket(client, bucketName);
12591261
}

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/command/EjectStorageDomain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public CliCommand init(final Arguments args) throws Exception {
5454
public DefaultResult call() throws Exception {
5555

5656
final EjectStorageDomainSpectraS3Request request
57-
= new EjectStorageDomainSpectraS3Request(id)
57+
= new EjectStorageDomainSpectraS3Request(id.toString())
5858
.withBucketId(bucket).withEjectLabel(ejectLabel).withEjectLocation(ejectLocation);
5959

6060
this.getClient().ejectStorageDomainSpectraS3(request);

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/command/GetDetailedObjects.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void checkFilterParams() throws BadArgumentException {
9090
public GetDetailedObjectsResult call() throws Exception {
9191

9292
final FluentIterable<DetailedS3Object> detailedObjects = FluentIterable.from(new LazyIterable<>(
93-
new GetObjectsFullDetailsLoaderFactory(getClient(), this.bucketName, this.prefix, 100, 5, true)))
93+
new GetObjectsFullDetailsLoaderFactory(getClient(), this.bucketName, 100, 5, true)))
9494
.filter(Predicates.and(getDatePredicate(), getSizePredicate(), getNamePredicate(), getOwnerPredicate()));
9595

9696
return new GetDetailedObjectsResult(detailedObjects);

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/command/GetObjectsOnTape.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public GetObjectsOnTapeResult call() throws CommandException, IOException {
5656
try {
5757

5858
final GetBlobsOnTapeSpectraS3Response response
59-
= getClient().getBlobsOnTapeSpectraS3(new GetBlobsOnTapeSpectraS3Request(null, this.tapeId));
59+
= getClient().getBlobsOnTapeSpectraS3(new GetBlobsOnTapeSpectraS3Request(this.tapeId));
6060

6161
return new GetObjectsOnTapeResult(this.tapeId, response.getBulkObjectListResult().getObjects());
6262
} catch (final FailedRequestException e) {

ds3_java_cli/src/main/java/com/spectralogic/ds3cli/views/cli/GetDataPathBackendView.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public String render(final GetDataPathBackendResult obj) {
3939
return "No valid Data Path Backend on remote appliance";
4040
}
4141

42-
initTable(ImmutableList.of("Activated", "Auto Timeout", "Auto Inspect", "Conflict Resolution", "ID",
42+
initTable(ImmutableList.of("Activated", "Auto Timeout", "Auto Inspect", "ID",
4343
"Last Heartbeat", "Unavailable Media Policy", "Unavailable Pool Retry Mins", "Unavailable Partition Retry Mins"));
4444

4545
return ASCIITable.getInstance().getTable(getHeaders(), formatTableContents());
@@ -51,12 +51,11 @@ protected String[][] formatTableContents() {
5151
attributesArray[0] = nullGuardToString(dataPathBackend.getActivated());
5252
attributesArray[1] = nullGuardToString(dataPathBackend.getAutoActivateTimeoutInMins());
5353
attributesArray[2] = nullGuardToString(dataPathBackend.getAutoInspect());
54-
attributesArray[3] = nullGuardToString(dataPathBackend.getDefaultImportConflictResolutionMode());
55-
attributesArray[4] = nullGuardToString(dataPathBackend.getId());
56-
attributesArray[5] = nullGuardFromDate(dataPathBackend.getLastHeartbeat(), DATE_FORMAT);
57-
attributesArray[6] = nullGuardToString(dataPathBackend.getUnavailableMediaPolicy());
58-
attributesArray[7] = nullGuardToString(dataPathBackend.getUnavailablePoolMaxJobRetryInMins());
59-
attributesArray[8] = nullGuardToString(dataPathBackend.getUnavailableTapePartitionMaxJobRetryInMins());
54+
attributesArray[3] = nullGuardToString(dataPathBackend.getId());
55+
attributesArray[4] = nullGuardFromDate(dataPathBackend.getLastHeartbeat(), DATE_FORMAT);
56+
attributesArray[5] = nullGuardToString(dataPathBackend.getUnavailableMediaPolicy());
57+
attributesArray[6] = nullGuardToString(dataPathBackend.getUnavailablePoolMaxJobRetryInMins());
58+
attributesArray[7] = nullGuardToString(dataPathBackend.getUnavailableTapePartitionMaxJobRetryInMins());
6059
contents.add(attributesArray);
6160
return contents.toArray(new String[contents.size()][]);
6261
}

0 commit comments

Comments
 (0)