Merge "Fix segment object naming that uploaded at qualified URL"

This commit is contained in:
Jenkins 2015-03-16 12:54:35 +00:00 committed by Gerrit Code Review
commit 4e8e7e5cd9
2 changed files with 37 additions and 1 deletions

View File

@ -133,7 +133,7 @@ public class SwiftNativeFileSystemStore {
InputStream inputStream, long length)
throws IOException {
String stringPath = path.toUri().toString();
String stringPath = path.toUri().getPath();
String partitionFilename = SwiftUtils.partitionFilenameFromNumber(
partNumber);
if (stringPath.endsWith("/")) {

View File

@ -439,4 +439,40 @@ public class TestSwiftFileSystemPartitionedUploads extends
}
/**
* Test writes partitioned file writing that path is qualified.
* @throws Throwable
*/
@Test(timeout = SWIFT_BULK_IO_TEST_TIMEOUT)
public void testQualifiedPath() throws Throwable {
final Path path = path("/test/qualifiedPath");
int len = PART_SIZE_BYTES * 4;
final byte[] src = SwiftTestUtils.dataset(len, 32, 144);
FSDataOutputStream out = fs.create(path,
false,
getBufferSize(),
(short) 1,
BLOCK_SIZE);
out.write(src, 0, src.length);
int expected =
getExpectedPartitionsWritten(len, PART_SIZE_BYTES, true);
out.close();
assertPartitionsWritten("write completed", out, expected);
assertEquals("too few bytes written", len,
SwiftNativeFileSystem.getBytesWritten(out));
assertEquals("too few bytes uploaded", len,
SwiftNativeFileSystem.getBytesUploaded(out));
//now we verify that the data comes back. If it
//doesn't, it means that the ordering of the partitions
//isn't right
byte[] dest = readDataset(fs, path, len);
//compare data
SwiftTestUtils.compareByteArrays(src, dest, len);
//finally, check the data
FileStatus[] stats = fs.listStatus(path);
assertEquals("wrong entry count in "
+ SwiftTestUtils.dumpStats(path.toString(), stats),
expected, stats.length);
}
}