chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r1611855 - in /chukwa/trunk/src/test/java/org/apache/hadoop/chukwa: analysis/salsa/fsm/TestFSMBuilder.java extraction/demux/TestDemux.java
Date Sat, 19 Jul 2014 07:24:44 GMT
Author: eyang
Date: Sat Jul 19 07:24:44 2014
New Revision: 1611855

URL: http://svn.apache.org/r1611855
Log:
CHUKWA-716. Fixed undefined System Properties for test cases and test case dependency.  (Eric
Yang)

Modified:
    chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/analysis/salsa/fsm/TestFSMBuilder.java
    chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/extraction/demux/TestDemux.java

Modified: chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/analysis/salsa/fsm/TestFSMBuilder.java
URL: http://svn.apache.org/viewvc/chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/analysis/salsa/fsm/TestFSMBuilder.java?rev=1611855&r1=1611854&r2=1611855&view=diff
==============================================================================
--- chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/analysis/salsa/fsm/TestFSMBuilder.java
(original)
+++ chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/analysis/salsa/fsm/TestFSMBuilder.java
Sat Jul 19 07:24:44 2014
@@ -28,11 +28,11 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.regex.*;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.chukwa.conf.ChukwaConfiguration;
 import org.apache.hadoop.chukwa.database.TableCreator;
-
 import org.apache.hadoop.chukwa.datacollection.DataFactory;
 import org.apache.hadoop.chukwa.datacollection.agent.ChukwaAgent;
 import org.apache.hadoop.chukwa.datacollection.agent.ChukwaAgent.AlreadyRunningException;
@@ -101,6 +101,8 @@ public class TestFSMBuilder extends Test
   private static String cluster = "demo";
   long[] timeWindow = {7, 30, 91, 365, 3650};
   long current = 1244617200000L;  // 2009-06-10
+  private String testBuildDir = System.getProperty("test.build.data", "/tmp");
+  private File dfsDataDir = new File(testBuildDir+"/dfs");
 
   public void setUp() {
     // Startup HDFS cluster - stored collector-ed JobHistory chunks
@@ -119,6 +121,9 @@ public class TestFSMBuilder extends Test
 
     // Startup HDFS cluster - stored collector-ed JobHistory chunks
     try {
+      if(dfsDataDir.exists()) {
+        FileUtils.deleteDirectory(dfsDataDir);        
+      }
       dfs = new MiniDFSCluster(conf, NUM_HADOOP_SLAVES, true, null);
       fileSys = dfs.getFileSystem();
       DEMUX_INPUT_PATH = new Path(fileSys.getUri().toString()+File.separator+dataSink); 
        
@@ -212,6 +217,9 @@ public class TestFSMBuilder extends Test
       jettyCollector.stop();
       mr.shutdown();
       dfs.shutdown();
+      if(dfsDataDir.exists()) {
+        FileUtils.deleteDirectory(dfsDataDir);        
+      }
       Thread.sleep(2000);
     } catch(Exception e) {
       e.printStackTrace();

Modified: chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/extraction/demux/TestDemux.java
URL: http://svn.apache.org/viewvc/chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/extraction/demux/TestDemux.java?rev=1611855&r1=1611854&r2=1611855&view=diff
==============================================================================
--- chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/extraction/demux/TestDemux.java (original)
+++ chukwa/trunk/src/test/java/org/apache/hadoop/chukwa/extraction/demux/TestDemux.java Sat
Jul 19 07:24:44 2014
@@ -18,8 +18,11 @@
 package org.apache.hadoop.chukwa.extraction.demux;
 
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Calendar;
+
+import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.mapred.JobConf;
@@ -29,6 +32,7 @@ import org.apache.hadoop.chukwa.ChukwaAr
 import org.apache.hadoop.chukwa.ChunkImpl;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.*;
+
 import junit.framework.TestCase;
 
 /**
@@ -112,7 +116,9 @@ public class TestDemux extends TestCase 
           + fileSys.getFileStatus(DEMUX_INPUT_PATH).getLen()
           + " bytes of temp test data");
       long ts_start = System.currentTimeMillis();
-      runDemux(mr.createJobConf(), DEMUX_INPUT_PATH, DEMUX_OUTPUT_PATH);
+      Path inputPath = new Path(fileSys.getUri().toString()+DEMUX_INPUT_PATH);
+      Path outputPath = new Path(fileSys.getUri().toString()+DEMUX_OUTPUT_PATH);
+      runDemux(mr.createJobConf(), inputPath, outputPath);
 
       long time = (System.currentTimeMillis() - ts_start);
       long bytes = fileSys.getContentSummary(DEMUX_OUTPUT_PATH).getLength();
@@ -120,6 +126,12 @@ public class TestDemux extends TestCase 
       System.out.println("processing took " + time + " milliseconds");
       System.out.println("aka " + time * 1.0 / LINES + " ms per line or "
           + time * 1000.0 / bytes + " ms per kilobyte of log data");
+      mr.shutdown();
+      dfs.shutdown();
+      String testBuildDir = System.getProperty("test.build.data", "/tmp");
+      String dfsPath = testBuildDir + "/dfs";
+      FileUtils.deleteDirectory(new File(dfsPath));
+      System.out.println(dfsPath);
 
     } catch (Exception e) {
       e.printStackTrace();



Mime
View raw message