|
@@ -25,12 +25,14 @@ import java.util.Random;
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.fs.FSDataInputStream;
|
|
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys;
|
|
|
|
|
|
+import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_TOLERATE_CONCURRENT_APPEND;
|
|
|
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
|
|
|
|
|
|
/**
|
|
@@ -66,7 +68,9 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
|
|
|
}
|
|
|
|
|
|
@Test (expected = IOException.class)
|
|
|
- public void testOOBWrites() throws Exception {
|
|
|
+ public void testOOBWritesAndReadFail() throws Exception {
|
|
|
+ Configuration conf = this.getRawConfiguration();
|
|
|
+ conf.setBoolean(AZURE_TOLERATE_CONCURRENT_APPEND, false);
|
|
|
final AzureBlobFileSystem fs = getFileSystem();
|
|
|
int readBufferSize = fs.getAbfsStore().getAbfsConfiguration().getReadBufferSize();
|
|
|
|
|
@@ -83,7 +87,6 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
|
|
|
try (FSDataInputStream readStream = fs.open(testFilePath)) {
|
|
|
assertEquals(readBufferSize,
|
|
|
readStream.read(bytesToRead, 0, readBufferSize));
|
|
|
-
|
|
|
try (FSDataOutputStream writeStream = fs.create(testFilePath)) {
|
|
|
writeStream.write(b);
|
|
|
writeStream.flush();
|
|
@@ -94,6 +97,36 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testOOBWritesAndReadSucceed() throws Exception {
|
|
|
+ Configuration conf = this.getRawConfiguration();
|
|
|
+ conf.setBoolean(AZURE_TOLERATE_CONCURRENT_APPEND, true);
|
|
|
+ final AzureBlobFileSystem fs = getFileSystem(conf);
|
|
|
+ int readBufferSize = fs.getAbfsStore().getAbfsConfiguration().getReadBufferSize();
|
|
|
+
|
|
|
+ byte[] bytesToRead = new byte[readBufferSize];
|
|
|
+ final byte[] b = new byte[2 * readBufferSize];
|
|
|
+ new Random().nextBytes(b);
|
|
|
+ final Path testFilePath = new Path(methodName.getMethodName());
|
|
|
+
|
|
|
+ try (FSDataOutputStream writeStream = fs.create(testFilePath)) {
|
|
|
+ writeStream.write(b);
|
|
|
+ writeStream.flush();
|
|
|
+ }
|
|
|
+
|
|
|
+ try (FSDataInputStream readStream = fs.open(testFilePath)) {
|
|
|
+ // Read
|
|
|
+ assertEquals(readBufferSize, readStream.read(bytesToRead, 0, readBufferSize));
|
|
|
+ // Concurrent write
|
|
|
+ try (FSDataOutputStream writeStream = fs.create(testFilePath)) {
|
|
|
+ writeStream.write(b);
|
|
|
+ writeStream.flush();
|
|
|
+ }
|
|
|
+
|
|
|
+ assertEquals(readBufferSize, readStream.read(bytesToRead, 0, readBufferSize));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testWriteWithBufferOffset() throws Exception {
|
|
|
final AzureBlobFileSystem fs = getFileSystem();
|