소스 검색

HDFS-3966. TestFileCreation should use JUnit4 to make assumeTrue work. Contributed by Jing Zhao.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1388722 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 13 년 전
부모
커밋
7d32fca5f1
2개의 변경된 파일19개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 0
      CHANGES.txt
  2. 16 1
      src/test/org/apache/hadoop/hdfs/TestFileCreation.java

+ 3 - 0
CHANGES.txt

@@ -574,6 +574,9 @@ Release 1.1.0 - unreleased
     HDFS-3466. Get HTTP kerberos principal from the web authentication keytab.
     (omalley)
 
+    HDFS-3966. TestFileCreation should use JUnit4 to make assumeTrue work.
+    (Jing Zhao via suresh)
+
 Release 1.0.4 - Unreleased
 
   NEW FEATURES

+ 16 - 1
src/test/org/apache/hadoop/hdfs/TestFileCreation.java

@@ -47,14 +47,16 @@ import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
 import org.apache.hadoop.hdfs.server.namenode.LeaseManager;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.log4j.Level;
+import org.junit.Test;
 
 import static org.junit.Assume.assumeTrue;
+import static org.junit.Assert.*;
 
 /**
  * This class tests that a file need not be closed before its
  * data can be read by another client.
  */
-public class TestFileCreation extends junit.framework.TestCase {
+public class TestFileCreation {
   static final String DIR = "/" + TestFileCreation.class.getSimpleName() + "/";
 
   {
@@ -172,11 +174,13 @@ public class TestFileCreation extends junit.framework.TestCase {
     stm.close();
   }
 
+  @Test
   public void testFileCreation() throws IOException {
     checkFileCreation(null, null);
   }
 
   /** Same test but the client should use DN hostname instead of IPs */
+  @Test
   public void testFileCreationByHostname() throws IOException {
     assumeTrue(System.getProperty("os.name").startsWith("Linux"));
 
@@ -188,6 +192,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   }
 
   /** Same test but the client should bind to a local interface */
+  @Test
   public void testFileCreationSetLocalInterface() throws IOException {
     assumeTrue(System.getProperty("os.name").startsWith("Linux"));
 
@@ -295,6 +300,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   /**
    * Test deleteOnExit
    */
+  @Test
   public void testDeleteOnExit() throws IOException {
     Configuration conf = new Configuration();
     if (simulatedStorage) {
@@ -357,6 +363,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   /**
    * Test file creation using createNonRecursive().
    */
+  @Test
   public void testFileCreationNonRecursive() throws IOException {
     Configuration conf = new Configuration();
     if (simulatedStorage) {
@@ -449,6 +456,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   /**
    * Test that file data does not become corrupted even in the face of errors.
    */
+  @Test
   public void testFileCreationError1() throws IOException {
     Configuration conf = new Configuration();
     conf.setInt("heartbeat.recheck.interval", 1000);
@@ -521,6 +529,7 @@ public class TestFileCreation extends junit.framework.TestCase {
    * Test that the filesystem removes the last block from a file if its
    * lease expires.
    */
+  @Test
   public void testFileCreationError2() throws IOException {
     long leasePeriod = 1000;
     System.out.println("testFileCreationError2 start");
@@ -590,6 +599,7 @@ public class TestFileCreation extends junit.framework.TestCase {
    * This test is currently not triggered because more HDFS work is 
    * is needed to handle persistent leases.
    */
+  //@Test
   public void xxxtestFileCreationNamenodeRestart() throws IOException {
     Configuration conf = new Configuration();
     final int MAX_IDLE_TIME = 2000; // 2s
@@ -731,6 +741,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   /**
    * Test that all open files are closed when client dies abnormally.
    */
+  @Test
   public void testDFSClientDeath() throws IOException, InterruptedException {
     Configuration conf = new Configuration();
     System.out.println("Testing adbornal client death.");
@@ -767,6 +778,7 @@ public class TestFileCreation extends junit.framework.TestCase {
 /**
  * Test that file data becomes available before file is closed.
  */
+  @Test
   public void testFileCreationSimulated() throws IOException {
     simulatedStorage = true;
     testFileCreation();
@@ -776,6 +788,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   /**
    * Test creating two files at the same time. 
    */
+  @Test
   public void testConcurrentFileCreation() throws IOException {
     Configuration conf = new Configuration();
     MiniDFSCluster cluster = new MiniDFSCluster(conf, 1, true, null);
@@ -810,6 +823,7 @@ public class TestFileCreation extends junit.framework.TestCase {
    * Then change lease period and wait for lease recovery.
    * Finally, read the block directly from each Datanode and verify the content.
    */
+  @Test
   public void testLeaseExpireHardLimit() throws Exception {
     System.out.println("testLeaseExpireHardLimit start");
     final long leasePeriod = 1000;
@@ -872,6 +886,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   }
 
   // test closing file system before all file handles are closed.
+  @Test
   public void testFsClose() throws Exception {
     System.out.println("test file system close start");
     final int DATANODE_NUM = 3;