HADOOP-15715. ITestAzureBlobFileSystemE2E timing out with non-scale timeout of 10 min.

Contributed by Da Zhou
This commit is contained in:
Steve Loughran 2018-09-18 11:48:46 +01:00
parent 1cf38a38da
commit 524776625d
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0
2 changed files with 26 additions and 20 deletions

View File

@ -38,7 +38,6 @@ import static org.junit.Assert.assertArrayEquals;
* Test end to end between ABFS client and ABFS server. * Test end to end between ABFS client and ABFS server.
*/ */
public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest { public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
private static final Path TEST_FILE = new Path("testfile");
private static final int TEST_BYTE = 100; private static final int TEST_BYTE = 100;
private static final int TEST_OFFSET = 100; private static final int TEST_OFFSET = 100;
private static final int TEST_DEFAULT_BUFFER_SIZE = 4 * 1024 * 1024; private static final int TEST_DEFAULT_BUFFER_SIZE = 4 * 1024 * 1024;
@ -52,21 +51,16 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
@Test @Test
public void testWriteOneByteToFile() throws Exception { public void testWriteOneByteToFile() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); final Path testFilePath = new Path(methodName.getMethodName());
testWriteOneByteToFile(testFilePath);
try(FSDataOutputStream stream = fs.create(TEST_FILE)) {
stream.write(TEST_BYTE);
}
FileStatus fileStatus = fs.getFileStatus(TEST_FILE);
assertEquals(1, fileStatus.getLen());
} }
@Test @Test
public void testReadWriteBytesToFile() throws Exception { public void testReadWriteBytesToFile() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); final AzureBlobFileSystem fs = getFileSystem();
testWriteOneByteToFile(); final Path testFilePath = new Path(methodName.getMethodName());
try(FSDataInputStream inputStream = fs.open(TEST_FILE, testWriteOneByteToFile(testFilePath);
try(FSDataInputStream inputStream = fs.open(testFilePath,
TEST_DEFAULT_BUFFER_SIZE)) { TEST_DEFAULT_BUFFER_SIZE)) {
assertEquals(TEST_BYTE, inputStream.read()); assertEquals(TEST_BYTE, inputStream.read());
} }
@ -81,17 +75,17 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
final byte[] b = new byte[2 * readBufferSize]; final byte[] b = new byte[2 * readBufferSize];
new Random().nextBytes(b); new Random().nextBytes(b);
final Path testFilePath = new Path(methodName.getMethodName());
try(FSDataOutputStream writeStream = fs.create(TEST_FILE)) { try(FSDataOutputStream writeStream = fs.create(testFilePath)) {
writeStream.write(b); writeStream.write(b);
writeStream.flush(); writeStream.flush();
} }
try (FSDataInputStream readStream = fs.open(TEST_FILE)) { try (FSDataInputStream readStream = fs.open(testFilePath)) {
assertEquals(readBufferSize, assertEquals(readBufferSize,
readStream.read(bytesToRead, 0, readBufferSize)); readStream.read(bytesToRead, 0, readBufferSize));
try (FSDataOutputStream writeStream = fs.create(TEST_FILE)) { try (FSDataOutputStream writeStream = fs.create(testFilePath)) {
writeStream.write(b); writeStream.write(b);
writeStream.flush(); writeStream.flush();
} }
@ -104,15 +98,16 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
@Test @Test
public void testWriteWithBufferOffset() throws Exception { public void testWriteWithBufferOffset() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); final AzureBlobFileSystem fs = getFileSystem();
final Path testFilePath = new Path(methodName.getMethodName());
final byte[] b = new byte[1024 * 1000]; final byte[] b = new byte[1024 * 1000];
new Random().nextBytes(b); new Random().nextBytes(b);
try (FSDataOutputStream stream = fs.create(TEST_FILE)) { try (FSDataOutputStream stream = fs.create(testFilePath)) {
stream.write(b, TEST_OFFSET, b.length - TEST_OFFSET); stream.write(b, TEST_OFFSET, b.length - TEST_OFFSET);
} }
final byte[] r = new byte[TEST_DEFAULT_READ_BUFFER_SIZE]; final byte[] r = new byte[TEST_DEFAULT_READ_BUFFER_SIZE];
FSDataInputStream inputStream = fs.open(TEST_FILE, TEST_DEFAULT_BUFFER_SIZE); FSDataInputStream inputStream = fs.open(testFilePath, TEST_DEFAULT_BUFFER_SIZE);
int result = inputStream.read(r); int result = inputStream.read(r);
assertNotEquals(-1, result); assertNotEquals(-1, result);
@ -124,13 +119,14 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
@Test @Test
public void testReadWriteHeavyBytesToFileWithSmallerChunks() throws Exception { public void testReadWriteHeavyBytesToFileWithSmallerChunks() throws Exception {
final AzureBlobFileSystem fs = getFileSystem(); final AzureBlobFileSystem fs = getFileSystem();
final Path testFilePath = new Path(methodName.getMethodName());
final byte[] writeBuffer = new byte[5 * 1000 * 1024]; final byte[] writeBuffer = new byte[5 * 1000 * 1024];
new Random().nextBytes(writeBuffer); new Random().nextBytes(writeBuffer);
write(TEST_FILE, writeBuffer); write(testFilePath, writeBuffer);
final byte[] readBuffer = new byte[5 * 1000 * 1024]; final byte[] readBuffer = new byte[5 * 1000 * 1024];
FSDataInputStream inputStream = fs.open(TEST_FILE, TEST_DEFAULT_BUFFER_SIZE); FSDataInputStream inputStream = fs.open(testFilePath, TEST_DEFAULT_BUFFER_SIZE);
int offset = 0; int offset = 0;
while (inputStream.read(readBuffer, offset, TEST_OFFSET) > 0) { while (inputStream.read(readBuffer, offset, TEST_OFFSET) > 0) {
offset += TEST_OFFSET; offset += TEST_OFFSET;
@ -139,4 +135,14 @@ public class ITestAzureBlobFileSystemE2E extends AbstractAbfsIntegrationTest {
assertArrayEquals(readBuffer, writeBuffer); assertArrayEquals(readBuffer, writeBuffer);
inputStream.close(); inputStream.close();
} }
private void testWriteOneByteToFile(Path testFilePath) throws Exception {
final AzureBlobFileSystem fs = getFileSystem();
try(FSDataOutputStream stream = fs.create(testFilePath)) {
stream.write(TEST_BYTE);
}
FileStatus fileStatus = fs.getFileStatus(testFilePath);
assertEquals(1, fileStatus.getLen());
}
} }

View File

@ -35,7 +35,7 @@ public final class TestConfigurationKeys {
public static final String TEST_CONFIGURATION_FILE_NAME = "azure-test.xml"; public static final String TEST_CONFIGURATION_FILE_NAME = "azure-test.xml";
public static final String TEST_CONTAINER_PREFIX = "abfs-testcontainer-"; public static final String TEST_CONTAINER_PREFIX = "abfs-testcontainer-";
public static final int TEST_TIMEOUT = 10 * 60 * 1000; public static final int TEST_TIMEOUT = 15 * 60 * 1000;
private TestConfigurationKeys() {} private TestConfigurationKeys() {}
} }