Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
8446c2d
If writing to a file fails, we throw an exception that prevents GetOb…
GraciesPadre Dec 6, 2016
43572f6
Allowing for subclassing UnrecoverableIOException.
GraciesPadre Dec 7, 2016
c5b5550
Adding a helper method to check for sufficient file space for custome…
GraciesPadre Dec 7, 2016
47c0c38
Addressing code review comments
GraciesPadre Dec 12, 2016
d953d31
Created request header wrapper that percent encodes metadata
RachelTucker Dec 13, 2016
1dc10c6
Implementing retry based on a network transfer where the content leng…
GraciesPadre Dec 14, 2016
ae5c491
Fixing an integration test I broke when I hijacked a file it needed f…
GraciesPadre Dec 14, 2016
e2594e1
Specified UTF-8 during encoding
RachelTucker Dec 14, 2016
ad7e7c5
No longer closing the request channel in GetObjectResponseParser, as …
GraciesPadre Dec 14, 2016
f43ffc9
Adding a RangeHelper to generate a new set of ranges form an existing…
GraciesPadre Dec 16, 2016
6df768d
Emitting failure event when we detect http content length mismatch
GraciesPadre Dec 16, 2016
be6729f
Updated unit tests
RachelTucker Dec 16, 2016
23fbf1b
Remove file we transferred to prevent breaking tests
GraciesPadre Dec 16, 2016
f264616
Merge pull request #400 from GraciesPadre/read_retry_bug
rpmoore Dec 16, 2016
93e97ea
This test broke when I introduced a change into the http proxy, where…
GraciesPadre Dec 19, 2016
a64e612
Merge pull request #403 from GraciesPadre/fix_java_integration_tests
Dec 19, 2016
2dce775
Fixing failing integration tests
GraciesPadre Dec 19, 2016
f47b47b
Updated RequestHeadersImpl and added unit tests
RachelTucker Dec 19, 2016
1d15c9c
Merge branch 'master' into JSDK_168
RachelTucker Dec 19, 2016
31f0041
Fixing integration tests that set directory permissions for the evil …
GraciesPadre Dec 20, 2016
43b9800
Fixing integration tests that set directory permissions for the evil …
GraciesPadre Dec 20, 2016
8a86d56
Fixing integration tests that set directory permissions for the evil …
Dec 20, 2016
ee14cda
Fixing integration tests that set directory permissions for the evil …
Dec 20, 2016
223cbd6
Fixing integration tests that set directory permissions for the evil …
Dec 20, 2016
baa04d0
Fixing failing unit tests
GraciesPadre Dec 21, 2016
99e320a
Fixing failing unit tests
GraciesPadre Dec 21, 2016
2996a0a
Beginning to merge from master
GraciesPadre Dec 21, 2016
26fc078
Beginning to merge from master
GraciesPadre Dec 21, 2016
8bd954c
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Dec 21, 2016
a7390cd
Replacing a literal with a named variable.
GraciesPadre Dec 21, 2016
064242c
Make it clearer what we base the destination channel offset on during…
GraciesPadre Dec 21, 2016
3af2e17
Make it clearer that this test is using a non-0 offset into the first…
GraciesPadre Dec 21, 2016
3b5af63
Multimap creation moved from AbstractRequest to RequestHeadersImpl
RachelTucker Dec 21, 2016
7d76335
Merge pull request #401 from RachelTucker/JSDK_168
rpmoore Dec 21, 2016
f01f677
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Dec 21, 2016
ca1a268
Updated getMultimap to return an immutable multimap
RachelTucker Dec 21, 2016
65ecc23
Restoring back to what the autogen code was before. Moving the chann…
GraciesPadre Dec 21, 2016
134b86e
Code review improvements
RachelTucker Dec 22, 2016
a87b12e
Merge pull request #406 from RachelTucker/JSDK_168_improvement
rpmoore Dec 22, 2016
a5369c8
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Dec 22, 2016
4069718
Merge branch 'master' into fix_java_windoze_integration_bug
GraciesPadre Dec 22, 2016
06fe8f3
Merge pull request #404 from GraciesPadre/fix_java_windoze_integratio…
rpmoore Dec 22, 2016
d2fc6be
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Dec 22, 2016
253d2bf
Removing unhygenic sleep from tests that exec a command on Windoze to…
GraciesPadre Dec 22, 2016
725a5a8
Fixing integration test with proxied builds
GraciesPadre Dec 23, 2016
a7c9db3
Merge pull request #408 from GraciesPadre/fix_proxied_builds
Dec 23, 2016
6780c2a
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Dec 23, 2016
4f022eb
Updated greek symbols to unicode representation in unit test
RachelTucker Dec 27, 2016
a34d50a
Updated symbols in integration test to use unicode format
RachelTucker Dec 27, 2016
7d7bdef
Merge branch 'master' into symbol_escape_test_update
RachelTucker Dec 27, 2016
abd1f8e
Added test for utf8 special symbols back in
RachelTucker Dec 29, 2016
bd787af
Merge pull request #411 from RachelTucker/symbol_escape_test_update
Jan 3, 2017
69776e1
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Jan 3, 2017
00e857d
Responding to code review comments.
GraciesPadre Jan 4, 2017
107794c
Fixing integration test failure
GraciesPadre Jan 4, 2017
4c9ad78
Merge pull request #416 from GraciesPadre/3_2_docker_file_fix
Jan 4, 2017
ce2b4c7
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Jan 5, 2017
f59a856
Specify SSL protocol TLSv1.2 when ignoring certificate to override de…
Jan 6, 2017
1b14375
statically define protocol TLSv1.2 string
Jan 6, 2017
a6a59a8
Merge pull request #418 from DenverM80/master_insecure_ssl_protocol
berkeleysquare Jan 6, 2017
8ddcc5f
Merge branch 'master' into partial_read_bug
GraciesPadre Jan 6, 2017
fac5562
Removing unnecessary imports
GraciesPadre Jan 6, 2017
09c2c83
Merge branch 'master' of https://github.com/SpectraLogic/ds3_java_sdk…
GraciesPadre Jan 6, 2017
940a05e
Merge branch 'partial_read_bug' of https://github.com/GraciesPadre/ds…
GraciesPadre Jan 6, 2017
f03fde1
Merge pull request #405 from GraciesPadre/partial_read_bug
rpmoore Jan 9, 2017
c619397
merging master
berkeleysquare Jan 9, 2017
b78cdf2
Had been making an unnecessary copy of a mutable list to get an immut…
GraciesPadre Jan 12, 2017
97bf9a6
Merge pull request #422 from GraciesPadre/eliminate_array_copy
rpmoore Jan 12, 2017
d788faa
Merge branch 'master' into merge190
berkeleysquare Jan 12, 2017
ade930d
Merge pull request #420 from berkeleysquare/merge190
rpmoore Jan 12, 2017
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
10 changes: 7 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM greyrocksoftware/javastandalone
FROM greyrocksoftware/javastandalone7

RUN apt-get update
# Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

RUN apt-get update && apt-get install -y \
git

RUN apt-get install git -y

ADD run_tests.sh /opt/

Expand Down
1 change: 1 addition & 0 deletions ds3-sdk-integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ dependencies {
compile 'commons-codec:commons-codec:1.10'
compile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
/*
* ****************************************************************************
* Copyright 2014-2016 Spectra Logic Corporation. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file.
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* ****************************************************************************
*/

package com.spectralogic.ds3client.helpers;

import com.spectralogic.ds3client.Ds3Client;
import com.spectralogic.ds3client.helpers.events.SameThreadEventRunner;
import com.spectralogic.ds3client.integration.Util;
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.bulk.Ds3Object;
import com.spectralogic.ds3client.utils.ResourceUtils;
import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import static com.spectralogic.ds3client.integration.Util.deleteAllContents;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;

public class FileSystemHelper_Test {
private static final Ds3Client client = Util.fromEnv();
private static final Ds3ClientHelpers HELPERS = Ds3ClientHelpers.wrap(client);
private static final String BUCKET_NAME = "File_System_Helper_Test";
private static final String TEST_ENV_NAME = "FileSystem_Helper_Test";
private static TempStorageIds envStorageIds;
private static UUID envDataPolicyId;

@BeforeClass
public static void startup() throws IOException {
envDataPolicyId = TempStorageUtil.setupDataPolicy(TEST_ENV_NAME, false, ChecksumType.Type.MD5, client);
envStorageIds = TempStorageUtil.setup(TEST_ENV_NAME, envDataPolicyId, client);
}

@Before
public void setupBucket() throws IOException {
HELPERS.ensureBucketExists(BUCKET_NAME, envDataPolicyId);
}

@AfterClass
public static void teardown() throws IOException {
TempStorageUtil.teardown(TEST_ENV_NAME, envStorageIds, client);
client.close();
}

@Test
public void testObjectsFitBucketThatHasContent() throws IOException, URISyntaxException {
putObjectThenRunVerification(new FileSystemHelperImpl(), new ResultVerifier() {
@Override
public void verifyResult(final ObjectStorageSpaceVerificationResult result, final long totalRequiredSize) {
assertEquals(ObjectStorageSpaceVerificationResult.VerificationStatus.OK, result.getVerificationStatus());
assertEquals(result.getRequiredSpace(), totalRequiredSize);
assertTrue(result.getAvailableSpace() > 0);
assertTrue(result.containsSufficientSpace());
assertNull(result.getIoException());
}
});
}

@Test
public void testObjectsFitBucketWithNonExistentBucket() {
final int maxNumBlockAllocationRetries = 1;
final int maxNumObjectTransferAttempts = 1;
final Ds3ClientHelpers ds3ClientHelpers = Ds3ClientHelpers.wrap(client,
maxNumBlockAllocationRetries,
maxNumObjectTransferAttempts);

final ObjectStorageSpaceVerificationResult result = ds3ClientHelpers.objectsFromBucketWillFitInDirectory(
"bad bucket name", Arrays.asList(new String[] {}), Paths.get("."));

assertEquals(ObjectStorageSpaceVerificationResult.VerificationStatus.BucketDoesNotExist, result.getVerificationStatus());
assertEquals(0, result.getRequiredSpace());
assertEquals(0, result.getAvailableSpace());
assertFalse(result.containsSufficientSpace());
assertNull(result.getIoException());
}

@Test
public void testObjectsFitBucketWithPathNotDirectory() throws IOException {
final int maxNumBlockAllocationRetries = 1;
final int maxNumObjectTransferAttempts = 1;
final Ds3ClientHelpers ds3ClientHelpers = Ds3ClientHelpers.wrap(client,
maxNumBlockAllocationRetries,
maxNumObjectTransferAttempts);

final Path textFile = Files.createFile(Paths.get("Gracie.txt"));

try {
final ObjectStorageSpaceVerificationResult result = ds3ClientHelpers.objectsFromBucketWillFitInDirectory(
"bad bucket name", Arrays.asList(new String[]{}), textFile);

assertEquals(ObjectStorageSpaceVerificationResult.VerificationStatus.PathIsNotADirectory, result.getVerificationStatus());
assertEquals(0, result.getRequiredSpace());
assertEquals(0, result.getAvailableSpace());
assertFalse(result.containsSufficientSpace());
assertNull(result.getIoException());
} finally {
Files.delete(textFile);
}
}

@Test
public void testObjectsFitBucketPathDoesNotExist() throws IOException {
final int maxNumBlockAllocationRetries = 1;
final int maxNumObjectTransferAttempts = 1;
final Ds3ClientHelpers ds3ClientHelpers = Ds3ClientHelpers.wrap(client,
maxNumBlockAllocationRetries,
maxNumObjectTransferAttempts);

final Path directory = Files.createDirectory(Paths.get("dir"));
FileUtils.deleteDirectory(directory.toFile());

final ObjectStorageSpaceVerificationResult result = ds3ClientHelpers.objectsFromBucketWillFitInDirectory(
"bad bucket name", Arrays.asList(new String[]{}), directory);

assertEquals(ObjectStorageSpaceVerificationResult.VerificationStatus.PathDoesNotExist, result.getVerificationStatus());
assertEquals(0, result.getRequiredSpace());
assertEquals(0, result.getAvailableSpace());
assertFalse(result.containsSufficientSpace());
assertNull(result.getIoException());
}

@Test
public void testObjectsFitBucketPathLacksAccess() throws IOException, InterruptedException {
final int maxNumBlockAllocationRetries = 1;
final int maxNumObjectTransferAttempts = 1;
final Ds3ClientHelpers ds3ClientHelpers = Ds3ClientHelpers.wrap(client,
maxNumBlockAllocationRetries,
maxNumObjectTransferAttempts);

final Path directory = Files.createDirectory(Paths.get("dir"));
if (org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS) {
// Deny write data access to everyone, making the directory unwritable
Runtime.getRuntime().exec("icacls dir /deny Everyone:(WD)").waitFor();
} else {
directory.toFile().setWritable(false);
}

try {
final ObjectStorageSpaceVerificationResult result = ds3ClientHelpers.objectsFromBucketWillFitInDirectory(
"bad bucket name", Arrays.asList(new String[]{}), directory);

assertEquals(ObjectStorageSpaceVerificationResult.VerificationStatus.PathLacksAccess, result.getVerificationStatus());
assertEquals(0, result.getRequiredSpace());
assertEquals(0, result.getAvailableSpace());
assertFalse(result.containsSufficientSpace());
assertNull(result.getIoException());
} finally {
if (org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS) {
// Grant write data access to everyone, making the directory writable, so we can delete it.
Runtime.getRuntime().exec("icacls dir /grant Everyone:(WD)").waitFor();
} else {
directory.toFile().setWritable(true);
}

FileUtils.deleteDirectory(directory.toFile());
}
}

@Test
public void testObjectsFitBucketPathLacksSpace() throws IOException, URISyntaxException {
putObjectThenRunVerification(new MockedFileSystemHelper(), new ResultVerifier() {
@Override
public void verifyResult(final ObjectStorageSpaceVerificationResult result,
final long totalRequiredSize)
{
assertEquals(ObjectStorageSpaceVerificationResult.VerificationStatus.PathLacksSufficientStorageSpace, result.getVerificationStatus());
assertEquals(totalRequiredSize, result.getRequiredSpace());
assertEquals(-1, result.getAvailableSpace());
assertFalse(result.containsSufficientSpace());
assertNull(result.getIoException());
}
});
}

private interface ResultVerifier {
void verifyResult(final ObjectStorageSpaceVerificationResult result, final long totalRequiredSize);
}

private void putObjectThenRunVerification(final FileSystemHelper fileSystemHelper,
final ResultVerifier resultVerifier)
throws IOException, URISyntaxException
{
try {
final String DIR_NAME = "largeFiles/";
final String[] FILE_NAMES = new String[]{"lesmis-copies.txt"};

final Path dirPath = ResourceUtils.loadFileResource(DIR_NAME);

final AtomicLong totalBookSizes = new AtomicLong(0);

final List<String> bookTitles = new ArrayList<>();
final List<Ds3Object> objects = new ArrayList<>();
for (final String book : FILE_NAMES) {
final Path objPath = ResourceUtils.loadFileResource(DIR_NAME + book);
final long bookSize = Files.size(objPath);
totalBookSizes.getAndAdd(bookSize);
final Ds3Object obj = new Ds3Object(book, bookSize);

bookTitles.add(book);
objects.add(obj);
}

final int maxNumBlockAllocationRetries = 1;
final int maxNumObjectTransferAttempts = 1;
final int retryDelay = -1;
final Ds3ClientHelpers ds3ClientHelpers = new Ds3ClientHelpersImpl(client,
maxNumBlockAllocationRetries,
maxNumObjectTransferAttempts,
retryDelay,
new SameThreadEventRunner(),
fileSystemHelper);

final AtomicInteger numTimesCallbackCalled = new AtomicInteger(0);

final Ds3ClientHelpers.Job writeJob = ds3ClientHelpers.startWriteJob(BUCKET_NAME, objects);
writeJob.attachObjectCompletedListener(new ObjectCompletedListener() {
@Override
public void objectCompleted(final String name) {
numTimesCallbackCalled.getAndIncrement();

final ObjectStorageSpaceVerificationResult result =
ds3ClientHelpers.objectsFromBucketWillFitInDirectory(BUCKET_NAME,
Arrays.asList(FILE_NAMES),
Paths.get("."));

resultVerifier.verifyResult(result, totalBookSizes.get());
}
});

writeJob.transfer(new FileObjectPutter(dirPath));

assertEquals(1, numTimesCallbackCalled.get());
} finally {
deleteAllContents(client, BUCKET_NAME);
}
}

private static class MockedFileSystemHelper extends FileSystemHelperImpl {
@Override
public long getAvailableFileSpace(final Path path) throws IOException {
return -1L;
}
}

@Test
public void testObjectsFitBucketPathThrows() throws IOException, URISyntaxException {
putObjectThenRunVerification(new MockedFileSystemHelperThrows(),
new ResultVerifier() {
@Override
public void verifyResult(final ObjectStorageSpaceVerificationResult result,
final long totalRequiredSize)
{
assertEquals(ObjectStorageSpaceVerificationResult.VerificationStatus.CaughtIOException, result.getVerificationStatus());
assertEquals(totalRequiredSize, result.getRequiredSpace());
assertEquals(0, result.getAvailableSpace());
assertFalse(result.containsSufficientSpace());
assertNotNull(result.getIoException());
}
});
}

private static class MockedFileSystemHelperThrows extends FileSystemHelperImpl {
@Override
public long getAvailableFileSpace(final Path path) throws IOException {
throw new IOException("IOExceptionAtor");
}
}
}
Loading