@Test public void outOfBandSingleFile_rename() throws Exception { //NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder5/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); Path srcFilePath = new Path("testFolder5/a/input/file"); assertTrue(fs.exists(srcFilePath)); Path destFilePath = new Path("testFolder5/file2"); fs.rename(srcFilePath, destFilePath); }
@Test public void outOfBandFolder_siblingCreate() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder3/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("testFolder3/a/input/file"))); Path targetFile = new Path("testFolder3/a/input/file2"); FSDataOutputStream s2 = fs.create(targetFile); s2.close(); }
@Test public void outOfBandFolder_rename_rootLevelFiles() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. CloudBlockBlob blob = testAccount.getBlobReference("fileX"); BlobOutputStream s = blob.openOutputStream(); s.close(); Path srcFilePath = new Path("/fileX"); assertTrue(fs.exists(srcFilePath)); Path destFilePath = new Path("/fileXrename"); fs.rename(srcFilePath, destFilePath); } }
@Test public void outOfBandFolder_rename() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder4/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); Path srcFilePath = new Path("testFolder4/a/input/file"); assertTrue(fs.exists(srcFilePath)); Path destFilePath = new Path("testFolder4/a/input/file2"); fs.rename(srcFilePath, destFilePath); }
@Test public void outOfBandFolder_uncleMkdirs() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder1/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("testFolder1/a/input/file"))); Path targetFolder = new Path("testFolder1/a/output"); assertTrue(fs.mkdirs(targetFolder)); }
@Test public void outOfBandFolder_parentDelete() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder2/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("testFolder2/a/input/file"))); Path targetFolder = new Path("testFolder2/a/input"); assertTrue(fs.delete(targetFolder, true)); }
@Test public void outOfBandFolder_firstLevelFolderDelete() throws Exception { CloudBlockBlob blob = testAccount.getBlobReference("folderW/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("/folderW"))); assertTrue(fs.exists(new Path("/folderW/file"))); assertTrue(fs.delete(new Path("/folderW"), true)); }
@Test public void outOfBandFolder_rootFileDelete() throws Exception { CloudBlockBlob blob = testAccount.getBlobReference("fileY"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("/fileY"))); assertTrue(fs.delete(new Path("/fileY"), true)); }
@Test public void outOfBandFolder_siblingCreate() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder3/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("testFolder3/a/input/file"))); Path targetFile = new Path("testFolder3/a/input/file2"); FSDataOutputStream s2 = fs.create(targetFile); s2.close(); }
@Test public void outOfBandSingleFile_rename() throws Exception { //NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder5/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); Path srcFilePath = new Path("testFolder5/a/input/file"); assertTrue(fs.exists(srcFilePath)); Path destFilePath = new Path("testFolder5/file2"); fs.rename(srcFilePath, destFilePath); }
@Test public void outOfBandFolder_rename() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder4/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); Path srcFilePath = new Path("testFolder4/a/input/file"); assertTrue(fs.exists(srcFilePath)); Path destFilePath = new Path("testFolder4/a/input/file2"); fs.rename(srcFilePath, destFilePath); }
@Test public void outOfBandFolder_uncleMkdirs() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder1/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("testFolder1/a/input/file"))); Path targetFolder = new Path("testFolder1/a/output"); assertTrue(fs.mkdirs(targetFolder)); }
@Test public void outOfBandFolder_parentDelete() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/"; CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder2/a/input/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("testFolder2/a/input/file"))); Path targetFolder = new Path("testFolder2/a/input"); assertTrue(fs.delete(targetFolder, true)); }
@Test public void outOfBandFolder_rename_rootLevelFiles() throws Exception { // NOTE: manual use of CloubBlockBlob targets working directory explicitly. // WASB driver methods prepend working directory implicitly. CloudBlockBlob blob = testAccount.getBlobReference("fileX"); BlobOutputStream s = blob.openOutputStream(); s.close(); Path srcFilePath = new Path("/fileX"); assertTrue(fs.exists(srcFilePath)); Path destFilePath = new Path("/fileXrename"); fs.rename(srcFilePath, destFilePath); } }
@Test public void outOfBandFolder_rootFileDelete() throws Exception { CloudBlockBlob blob = testAccount.getBlobReference("fileY"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("/fileY"))); assertTrue(fs.delete(new Path("/fileY"), true)); }
@Test public void testClose() throws URISyntaxException, StorageException, IOException { String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testblob"); CloudBlockBlob blockBlob = this.container.getBlockBlobReference(blobName); BlobOutputStream str = blockBlob.openOutputStream(); str.close(); try { str.close(); fail("Can't close twice."); } catch(IOException e) { assertEquals(SR.STREAM_CLOSED, e.getMessage()); } str = blockBlob.openOutputStream(); str.write(8); ArrayList<BlockEntry> blocks = blockBlob.downloadBlockList(BlockListingFilter.ALL, null, null, null); assertEquals(0, blocks.size()); str.close(); blocks = blockBlob.downloadBlockList(BlockListingFilter.COMMITTED, null, null, null); assertEquals(1, blocks.size()); }
@Test public void outOfBandFolder_firstLevelFolderDelete() throws Exception { CloudBlockBlob blob = testAccount.getBlobReference("folderW/file"); BlobOutputStream s = blob.openOutputStream(); s.close(); assertTrue(fs.exists(new Path("/folderW"))); assertTrue(fs.exists(new Path("/folderW/file"))); assertTrue(fs.delete(new Path("/folderW"), true)); }
private static CloudBlockBlob primeRootContainer(CloudBlobClient blobClient, String accountName, String blobName, int fileSize) throws Exception { // Create a container if it does not exist. The container name // must be lower case. CloudBlobContainer container = blobClient.getContainerReference("https://" + accountName + "/" + "$root"); container.createIfNotExists(); // Create a blob output stream. CloudBlockBlob blob = container.getBlockBlobReference(blobName); BlobOutputStream outputStream = blob.openOutputStream(); outputStream.write(new byte[fileSize]); outputStream.close(); // Return a reference to the block blob object. return blob; }
private static CloudBlockBlob primeRootContainer(CloudBlobClient blobClient, String accountName, String blobName, int fileSize) throws Exception { // Create a container if it does not exist. The container name // must be lower case. CloudBlobContainer container = blobClient.getContainerReference("https://" + accountName + "/" + "$root"); container.createIfNotExists(); // Create a blob output stream. CloudBlockBlob blob = container.getBlockBlobReference(blobName); BlobOutputStream outputStream = blob.openOutputStream(); outputStream.write(new byte[fileSize]); outputStream.close(); // Return a reference to the block blob object. return blob; }
@Test public void testEmpty() throws URISyntaxException, StorageException, IOException { String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testblob"); CloudBlockBlob blockBlob = this.container.getBlockBlobReference(blobName); BlobOutputStream str = blockBlob.openOutputStream(); str.close(); CloudBlockBlob blockBlob2 = this.container.getBlockBlobReference(blobName); blockBlob2.downloadAttributes(); assertEquals(0, blockBlob2.getProperties().getLength()); ArrayList<BlockEntry> blocks = blockBlob2.downloadBlockList(BlockListingFilter.ALL, null, null, null); assertEquals(0, blocks.size()); }