HADOOP-13148. TestDistCpViewFs to include IOExceptions in test error reports. Contributed by Steve Loughran.

This commit is contained in:
Chris Nauroth 2016-05-16 11:53:17 -07:00
parent 81effb7dcd
commit b9685e85d5

View File

@ -73,13 +73,12 @@ public static void setup() throws URISyntaxException{
} }
@Test @Test
public void testSingleFileMissingTarget() { public void testSingleFileMissingTarget() throws IOException {
caseSingleFileMissingTarget(false); caseSingleFileMissingTarget(false);
caseSingleFileMissingTarget(true); caseSingleFileMissingTarget(true);
} }
private void caseSingleFileMissingTarget(boolean sync) throws IOException{
private void caseSingleFileMissingTarget(boolean sync) {
try { try {
addEntries(listFile, "singlefile1/file1"); addEntries(listFile, "singlefile1/file1");
@ -88,21 +87,18 @@ private void caseSingleFileMissingTarget(boolean sync) {
runTest(listFile, target, false, sync); runTest(listFile, target, false, sync);
checkResult(target, 1); checkResult(target, 1);
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testSingleFileTargetFile() { public void testSingleFileTargetFile() throws IOException{
caseSingleFileTargetFile(false); caseSingleFileTargetFile(false);
caseSingleFileTargetFile(true); caseSingleFileTargetFile(true);
} }
private void caseSingleFileTargetFile(boolean sync) { private void caseSingleFileTargetFile(boolean sync) throws IOException {
try { try {
addEntries(listFile, "singlefile1/file1"); addEntries(listFile, "singlefile1/file1");
@ -111,21 +107,18 @@ private void caseSingleFileTargetFile(boolean sync) {
runTest(listFile, target, false, sync); runTest(listFile, target, false, sync);
checkResult(target, 1); checkResult(target, 1);
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testSingleFileTargetDir() { public void testSingleFileTargetDir() throws IOException {
caseSingleFileTargetDir(false); caseSingleFileTargetDir(false);
caseSingleFileTargetDir(true); caseSingleFileTargetDir(true);
} }
private void caseSingleFileTargetDir(boolean sync) { private void caseSingleFileTargetDir(boolean sync) throws IOException {
try { try {
addEntries(listFile, "singlefile2/file2"); addEntries(listFile, "singlefile2/file2");
@ -135,21 +128,18 @@ private void caseSingleFileTargetDir(boolean sync) {
runTest(listFile, target, true, sync); runTest(listFile, target, true, sync);
checkResult(target, 1, "file2"); checkResult(target, 1, "file2");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testSingleDirTargetMissing() { public void testSingleDirTargetMissing() throws IOException{
caseSingleDirTargetMissing(false); caseSingleDirTargetMissing(false);
caseSingleDirTargetMissing(true); caseSingleDirTargetMissing(true);
} }
private void caseSingleDirTargetMissing(boolean sync) { private void caseSingleDirTargetMissing(boolean sync) throws IOException {
try { try {
addEntries(listFile, "singledir"); addEntries(listFile, "singledir");
@ -158,16 +148,13 @@ private void caseSingleDirTargetMissing(boolean sync) {
runTest(listFile, target, false, sync); runTest(listFile, target, false, sync);
checkResult(target, 1, "dir1"); checkResult(target, 1, "dir1");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testSingleDirTargetPresent() { public void testSingleDirTargetPresent() throws IOException{
try { try {
addEntries(listFile, "singledir"); addEntries(listFile, "singledir");
@ -177,16 +164,13 @@ public void testSingleDirTargetPresent() {
runTest(listFile, target, true, false); runTest(listFile, target, true, false);
checkResult(target, 1, "singledir/dir1"); checkResult(target, 1, "singledir/dir1");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testUpdateSingleDirTargetPresent() { public void testUpdateSingleDirTargetPresent() throws IOException {
try { try {
addEntries(listFile, "Usingledir"); addEntries(listFile, "Usingledir");
@ -196,21 +180,18 @@ public void testUpdateSingleDirTargetPresent() {
runTest(listFile, target, true, true); runTest(listFile, target, true, true);
checkResult(target, 1, "Udir1"); checkResult(target, 1, "Udir1");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testMultiFileTargetPresent() { public void testMultiFileTargetPresent() throws IOException {
caseMultiFileTargetPresent(false); caseMultiFileTargetPresent(false);
caseMultiFileTargetPresent(true); caseMultiFileTargetPresent(true);
} }
private void caseMultiFileTargetPresent(boolean sync) { private void caseMultiFileTargetPresent(boolean sync) throws IOException {
try { try {
addEntries(listFile, "multifile/file3", "multifile/file4", "multifile/file5"); addEntries(listFile, "multifile/file3", "multifile/file4", "multifile/file5");
@ -220,21 +201,18 @@ private void caseMultiFileTargetPresent(boolean sync) {
runTest(listFile, target, true, sync); runTest(listFile, target, true, sync);
checkResult(target, 3, "file3", "file4", "file5"); checkResult(target, 3, "file3", "file4", "file5");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testMultiFileTargetMissing() { public void testMultiFileTargetMissing() throws IOException {
caseMultiFileTargetMissing(false); caseMultiFileTargetMissing(false);
caseMultiFileTargetMissing(true); caseMultiFileTargetMissing(true);
} }
private void caseMultiFileTargetMissing(boolean sync) { private void caseMultiFileTargetMissing(boolean sync) throws IOException {
try { try {
addEntries(listFile, "multifile/file3", "multifile/file4", "multifile/file5"); addEntries(listFile, "multifile/file3", "multifile/file4", "multifile/file5");
@ -243,16 +221,13 @@ private void caseMultiFileTargetMissing(boolean sync) {
runTest(listFile, target, false, sync); runTest(listFile, target, false, sync);
checkResult(target, 3, "file3", "file4", "file5"); checkResult(target, 3, "file3", "file4", "file5");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testMultiDirTargetPresent() { public void testMultiDirTargetPresent() throws IOException {
try { try {
addEntries(listFile, "multifile", "singledir"); addEntries(listFile, "multifile", "singledir");
@ -262,16 +237,13 @@ public void testMultiDirTargetPresent() {
runTest(listFile, target, true, false); runTest(listFile, target, true, false);
checkResult(target, 2, "multifile/file3", "multifile/file4", "multifile/file5", "singledir/dir1"); checkResult(target, 2, "multifile/file3", "multifile/file4", "multifile/file5", "singledir/dir1");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testUpdateMultiDirTargetPresent() { public void testUpdateMultiDirTargetPresent() throws IOException {
try { try {
addEntries(listFile, "Umultifile", "Usingledir"); addEntries(listFile, "Umultifile", "Usingledir");
@ -281,16 +253,13 @@ public void testUpdateMultiDirTargetPresent() {
runTest(listFile, target, true, true); runTest(listFile, target, true, true);
checkResult(target, 4, "Ufile3", "Ufile4", "Ufile5", "Udir1"); checkResult(target, 4, "Ufile3", "Ufile4", "Ufile5", "Udir1");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testMultiDirTargetMissing() { public void testMultiDirTargetMissing() throws IOException {
try { try {
addEntries(listFile, "multifile", "singledir"); addEntries(listFile, "multifile", "singledir");
@ -301,16 +270,13 @@ public void testMultiDirTargetMissing() {
checkResult(target, 2, "multifile/file3", "multifile/file4", checkResult(target, 2, "multifile/file3", "multifile/file4",
"multifile/file5", "singledir/dir1"); "multifile/file5", "singledir/dir1");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testUpdateMultiDirTargetMissing() { public void testUpdateMultiDirTargetMissing() throws IOException {
try { try {
addEntries(listFile, "multifile", "singledir"); addEntries(listFile, "multifile", "singledir");
@ -320,16 +286,13 @@ public void testUpdateMultiDirTargetMissing() {
runTest(listFile, target, false, true); runTest(listFile, target, false, true);
checkResult(target, 4, "file3", "file4", "file5", "dir1"); checkResult(target, 4, "file3", "file4", "file5", "dir1");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
} }
} }
@Test @Test
public void testGlobTargetMissingSingleLevel() { public void testGlobTargetMissingSingleLevel() throws IOException {
try { try {
Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(), Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(),
@ -342,9 +305,6 @@ public void testGlobTargetMissingSingleLevel() {
checkResult(target, 2, "multifile/file3", "multifile/file4", "multifile/file5", checkResult(target, 2, "multifile/file3", "multifile/file4", "multifile/file5",
"singledir/dir2/file6"); "singledir/dir2/file6");
} catch (IOException e) {
LOG.error("Exception encountered while testing distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
TestDistCpUtils.delete(fs, "target/tmp1"); TestDistCpUtils.delete(fs, "target/tmp1");
@ -352,7 +312,7 @@ public void testGlobTargetMissingSingleLevel() {
} }
@Test @Test
public void testUpdateGlobTargetMissingSingleLevel() { public void testUpdateGlobTargetMissingSingleLevel() throws IOException {
try { try {
Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(), Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(),
@ -364,9 +324,6 @@ public void testUpdateGlobTargetMissingSingleLevel() {
runTest(listFile, target, false, true); runTest(listFile, target, false, true);
checkResult(target, 4, "file3", "file4", "file5", "dir2/file6"); checkResult(target, 4, "file3", "file4", "file5", "dir2/file6");
} catch (IOException e) {
LOG.error("Exception encountered while running distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
TestDistCpUtils.delete(fs, "target/tmp1"); TestDistCpUtils.delete(fs, "target/tmp1");
@ -374,7 +331,7 @@ public void testUpdateGlobTargetMissingSingleLevel() {
} }
@Test @Test
public void testGlobTargetMissingMultiLevel() { public void testGlobTargetMissingMultiLevel() throws IOException {
try { try {
Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(), Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(),
@ -388,9 +345,6 @@ public void testGlobTargetMissingMultiLevel() {
checkResult(target, 4, "file3", "file4", "file5", checkResult(target, 4, "file3", "file4", "file5",
"dir3/file7", "dir3/file8", "dir3/file9"); "dir3/file7", "dir3/file8", "dir3/file9");
} catch (IOException e) {
LOG.error("Exception encountered while running distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
TestDistCpUtils.delete(fs, "target/tmp1"); TestDistCpUtils.delete(fs, "target/tmp1");
@ -398,7 +352,7 @@ public void testGlobTargetMissingMultiLevel() {
} }
@Test @Test
public void testUpdateGlobTargetMissingMultiLevel() { public void testUpdateGlobTargetMissingMultiLevel() throws IOException {
try { try {
Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(), Path listFile = new Path("target/tmp1/listing").makeQualified(fs.getUri(),
@ -412,9 +366,6 @@ public void testUpdateGlobTargetMissingMultiLevel() {
checkResult(target, 6, "file3", "file4", "file5", checkResult(target, 6, "file3", "file4", "file5",
"file7", "file8", "file9"); "file7", "file8", "file9");
} catch (IOException e) {
LOG.error("Exception encountered while running distcp", e);
Assert.fail("distcp failure");
} finally { } finally {
TestDistCpUtils.delete(fs, root); TestDistCpUtils.delete(fs, root);
TestDistCpUtils.delete(fs, "target/tmp1"); TestDistCpUtils.delete(fs, "target/tmp1");